-
Notifications
You must be signed in to change notification settings - Fork 21
lintr
The lintr
package allows you to check your R code for common style issues.
Before using the lintr
capabilities, you first need to configure the R languageserver
R package which is used to provide the linting capabilities.
To use the languageserver
in NeoVim, we first need to configure nvim-lspconfig
. This can be done by using this in your lspconfig.lua
file (or whatever it is named):
config = function()
vim.g.LanguageClient_serverCommands = {
r = { "R", "--slave", "-e", "languageserver::run()" },
}
end
lintr
can be configured per project by creating a .lintr
file in the project root or globally.
The canonical way to configure R projects and packages for linting is to create a .lintr file in the project root. This is a file in debian control format (?read.dcf), each value of which is evaluated as R code by lintr when reading the settings. A minimal .lintr file can be generated by running use_lintr() in the project directory. Lintr supports per-project configuration of the following fields.
The location of the .lintr
file can be set in the .Rprofile
file:
lintr.linter_file = "~/.lintr",
Here is a minimal .lintr
file that set the maximum line length to 120 characters and disables the commented code linter:
linters: linters_with_defaults(
line_length_linter(120),
commented_code_linter = NULL
)