languageserver
languageserver copied to clipboard
lsp sees things that lintr doesnt
I might have a function defined in a separate file of functions that I source in the script. the linter warns about no global function definition
, but if I use the jump to definition capability it takes me exactly where I need to go. so the lsp knows the function exists but the linter provided by lintr
doesn't. I might turn off that linter capability in my .lintr
file but I wish it worked properly for cases where the function is actually not available.
Are you using the latest lintr (3.0.x)?
I also have this issue and commented here: https://github.com/REditorSupport/vscode-R/issues/729#issuecomment-1218416818
I noticed that on https://github.com/REditorSupport/languageserver/blob/9f0e29af3d6c8e4e61eb672d9b04d4ec2ca06706/R/diagnostics.R#L87
languageserver only calls lintr::lint()
, but according to the lintr 3.0.x docs "‘lint()’ lints a single file." I know the LSP previously had a distinction between lintr::lint()
and lintr::lint_package()
; is that no longer needed?
After doing some more digging, this is due to not all objects being captured in the environment where the LSP is running (https://github.com/r-lib/lintr/issues/1137#issuecomment-1127828843). A solution is to do devtools::load_all()
, but doing that in a connected R console in VSCode does not resolve the object names.
@renkun-ken I am using the latest version of lintr. I see the links posted by @psanker but I'm not an advanced-enough user to understand them. for context, using the languageserver
package in neovim with coc.
@jam1015 You might want to try remotes::install_github("REditorSupport/languageserver#568")
and see if it works for you.