languageserver icon indicating copy to clipboard operation
languageserver copied to clipboard

No completion for workspace variables in rmarkdown

Open zhenhua-wang opened this issue 3 years ago • 5 comments
trafficstars

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.

Screenshot_20221020_141859

zhenhua-wang avatar Oct 20 '22 19:10 zhenhua-wang

cannot reproduce

Screen Shot 2022-11-16 at 01 12 55

maybe because the name a is too short?

I am using neovim with builtin lsp

milanglacier avatar Nov 16 '22 06:11 milanglacier

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!

ktrutmann avatar Mar 23 '23 09:03 ktrutmann

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:

  1. I still get completions and help for functions form the base, stats and utils pacakges etc. Just not from any I load myself.
  2. Interestingly, if I create a file test.Rmd and only write R code, such as my import and the start of a function name from that library (for example library(tidyr) and piv for "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 the text.html.markdown.rmarkdown scope. 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!

ktrutmann avatar Mar 25 '24 20:03 ktrutmann

2. Interestingly, if I create a file test.Rmd and only write R code, such as my import and the start of a function name from that library (for example library(tidyr) and piv for "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 the text.html.markdown.rmarkdown scope. 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.

zhenhua-wang avatar Mar 26 '24 14:03 zhenhua-wang

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.

ktrutmann avatar Mar 26 '24 15:03 ktrutmann