languageserver
languageserver copied to clipboard
Autocomplete does not work for all R files
on my windows laptop I use gvim 9.0. I set up coc-r-lsp with languageserver. The autocomplete works on some R file, but not work on all R files. On thing I noticed that, if R file in git repository, autocomplete does not works.
When R file in other directory, it works
when R file in git repo, it does not work
have you setup the root directory in coc-settings.json correctly? It should be either the home directory or the root of the git repo.
here is the coc-settings.json file content of my windows which is not working correctly.
"languageserver": {
"R": {
"enable": true,
"command": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe",
"r.lsp.path": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe",
"r.lsp.debug": true,
"args": [
"--slave",
"-e",
"languageserver::run()"
],
"filetypes": [
"r"
]
}
}
not sure how to setup correctly.
but on my mac, this is the coc-settings.json file. and autocomplete working fine in any R file whether it is home directory or in a git directory.
"languageserver": {
"R": {
"enable": true,
"command": "/usr/local/bin/R",
"args" : [ "--slave", "-e", "languageserver::run()"],
"filetypes" : ["r"]
}
}
here is the coc-settings.json file content of my windows which is not working correctly.
"languageserver": { "R": { "enable": true, "command": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe", "r.lsp.path": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe", "r.lsp.debug": true, "args": [ "--slave", "-e", "languageserver::run()" ], "filetypes": [ "r" ] } }
not sure how to setup correctly.
but on my mac, this is the coc-settings.json file. and autocomplete working fine in any R file whether it is home directory or in a git directory.
"languageserver": { "R": { "enable": true, "command": "/usr/local/bin/R", "args" : [ "--slave", "-e", "languageserver::run()"], "filetypes" : ["r"] } }
I don't use windows, so I have no idea what is happening. Neovim builtin lsp works fine though. This is the default configuration of the R lsp in neovim:
https://github.com/neovim/nvim-lspconfig/blob/1028360e0f2f724d93e876df3d22f63c1acd6ff9/lua/lspconfig/server_configurations/r_language_server.lua#L8
You can see that the root directory is either home directory or git root.
However I do have some impression that I once tried to modify the root directory specs and the completion does not work. So I just used the default way of nvim-lspconfig
which handles root directory works just fine.
@milanglacier Thank you so much for directing me to nvim lspconfig. It was quite easy to set up for R and python. I spent quite bit of time on nvim-R and coc-vim but could not figure out how to set up properly for windows which is my working laptop. I was using vim, now I am using neovim. The telescope plugin really cool. Thanks