Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add R Markdown support #170

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ If you like LT<sub>E</sub>X, but are not able to contribute in any of these ways
1. Install VS Code, Git, and Apache Maven.
2. Fork ltex-ls on GitHub.
3. Clone the fork: `git clone https://github.com/<YOUR_USERNAME>/ltex-ls.git`
4. Build the project: `cd ltex-ls && mvn verify`
4. Build the project:
- `cd ltex-ls`
- `python -u tools/createCompletionLists.py`
- `mvn verify`
5. It's recommended to use IntelliJ IDEA to debug ltex-ls.

## How to Contribute Code
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Find more information (how to install, how to use, etc.) at the [website of LT<s

## Features

- **Supported markup languages:** BibT<sub>E</sub>X, ConT<sub>E</sub>Xt, Git commit messages, L<sup>A</sup>T<sub>E</sub>X, Markdown, Org, reStructuredText, R Sweave, XHTML
- **Supported markup languages:** BibT<sub>E</sub>X, ConT<sub>E</sub>Xt, Git commit messages, L<sup>A</sup>T<sub>E</sub>X, Markdown, Org, R Markdown, reStructuredText, R Sweave, XHTML
- Comment checking in **many popular programming languages** (optional, opt-in)
- Comes with **everything included,** no need to install Java or LanguageTool
- **Offline checking:** Does not upload anything to the internet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ abstract class CodeAnnotatedTextBuilder(
"rsweave",
"tex",
-> LatexAnnotatedTextBuilder(codeLanguageId)
"markdown" -> MarkdownAnnotatedTextBuilder(codeLanguageId)
"rmd",
"markdown",
-> MarkdownAnnotatedTextBuilder(codeLanguageId)
"nop" -> NopAnnotatedTextBuilder(codeLanguageId)
"org" -> OrgAnnotatedTextBuilder(codeLanguageId)
"plaintext" -> PlaintextAnnotatedTextBuilder(codeLanguageId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ abstract class CodeFragmentizer(
"rsweave",
"tex",
-> LatexFragmentizer(codeLanguageId)
"markdown" -> MarkdownFragmentizer(codeLanguageId)
"markdown",
"rmd",
-> MarkdownFragmentizer(codeLanguageId)
"nop" -> NopFragmentizer(codeLanguageId)
"org" -> OrgFragmentizer(codeLanguageId)
"plaintext" -> PlaintextFragmentizer(codeLanguageId)
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ data class Settings(
"html",
"markdown",
"org",
"rmd",
"restructuredtext",
"rsweave",
)
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/org/bsplines/ltexls/tools/FileIo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ object FileIo {
"python"
} else if (fileName.endsWith(".r")) {
"r"
} else if (fileName.endsWith(".Rmd")
|| fileName.endsWith(".rmd")) {
"rmd"
} else if (fileName.endsWith(".rst")) {
"restructuredtext"
} else if (fileName.endsWith(".Rnw")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ class MarkdownFragmentizerTest {
)
}

@Test
fun testOtherLanguages() {
assertFragmentizer(
"rmd",
"""
Sentence 1

<!-- ltex: language=de-DE-->

Sentence 2

<!-- ltex: language=en-US -->

Sentence 3

""".trimIndent(),
)
}

@Test
fun testWrongSettings() {
val fragmentizer: CodeFragmentizer = CodeFragmentizer.create("markdown")
Expand Down