languageserver
languageserver copied to clipboard
No completion for workspace variables in rmarkdown
Hi,
Everything works fine in a normal R file. But in rmd file, it cannot complete workspace variables (See below) after updated to the newest version of Rlanguageserver. This used to work in the version 0.3.12.
I am using Emacs, and both eglot and lsp-mode have this issue in rmarkdown.

cannot reproduce
maybe because the name a is too short?
I am using neovim with builtin lsp
I have the same problem in Sublime Text. Everything works fine in R-scripts, but in .Rmd files LSP does not recognize workspace variables and functions (even those with longer names). The error that is displayed when trying to rename a variable using LSP is "invalid response payload", if that helps.
EDIT: It works now! I had the "DictionaryAutoComplete" plugin runing in Sublime Text which pushed back the content provided by LSP. I managed to deactivate the dictionary suggestions and now it works!
Looks like I landed back here. This time it doesn't work, even on a fresh install of SublimeText. I do not get any symbols from the workspace, nor from the packages that I load.
Two things I have noticed:
- I still get completions and help for functions form the
base,statsandutilspacakges etc. Just not from any I load myself. - Interestingly, if I create a file
test.Rmdand only write R code, such as my import and the start of a function name from that library (for examplelibrary(tidyr)andpivfor "pivot_longer"), I will get the correct completion and help! The languageserver seems to treat it like it's a normal R script, despite the .Rmd filename and thetext.html.markdown.rmarkdownscope. But as soon as I add a YAML header and/or a code fence, things are broken again.
Does anyone have a clue of what is happening here? Is my languageserver borked somehow? I'm thankful for any help!
2. Interestingly, if I create a file
test.Rmdand only write R code, such as my import and the start of a function name from that library (for examplelibrary(tidyr)andpivfor "pivot_longer"), I will get the correct completion and help! The languageserver seems to treat it like it's a normal R script, despite the .Rmd filename and thetext.html.markdown.rmarkdownscope. But as soon as I add a YAML header and/or a code fence, things are broken again
I believe that's how this server works. Currently, I force my editor treat YAML header and code fences as comments, which is not the best solution (slow), but works fine.
I don't think so.
Rmarkdown seems to be handled at multiple locations in the code of the languageserver and you yourself mentioned in your original post here that it used to work just fine on Rmd files...
Plus I myself also had it working once. It would be quite the downgrade to just quietly drop support for Rmarkdown.