Skip to content

languageserver does not respect lintr file #700

Closed

Description

@grimmjulian

Hello,

I want to use tabs as indentation. I have the following file test.R with tabs as indentation:

result <- map_lgl(
	xs,
	function(x) {
		is.logical(x) && length(x) == 1L && !is.na(x)
	}
)

Also I added the following .lintr file:

linters: linters_with_defaults(
    line_length_linter = line_length_linter(120L),
    whitespace_linter = NULL,
    indentation_linter = NULL
  )

The file structure basically is the .lintr file and test.R in a folder.

lintr::lint_dir() does not return any problems. But when use the languageserver in Neovim, the whitespace_linter complains. Do I need to set further options?

Activity

  1. CharlesBordet commented on Dec 1, 2025

    @CharlesBordet

    I noticed the same behavior today on a new project, despite having used the combination of languageserver with VSCode for a few years now.

    I noticed that the lintr package had been upgraded a few days ago: https://github.com/r-lib/lintr/releases/tag/v3.3.0-1

    I downgraded to lintr v3.2.0 and this fixed the issue.

    It might not be related to @grimmjulian issue as it was published before the lintr release. In any case, I'm posting my fix here in case it can help other people.

  2. Yousa-Mirage commented on Dec 2, 2025

    @Yousa-Mirage

    I noticed the same behavior today on a new project, despite having used the combination of languageserver with VSCode for a few years now.今天我在一个新项目中也发现了同样的问题,尽管我已经使用 languageserver 和 VSCode 的组合好几年了。

    I noticed that the lintr package had been upgraded a few days ago: r-lib/lintr@v3.3.0-1 (release)我注意到 lintr 包几天前已经升级了: r-lib/lintr@ v3.3.0-1 (release)

    I downgraded to lintr v3.2.0 and this fixed the issue.我将 lintr 降级到 v3.2.0,问题就解决了。

    It might not be related to @grimmjulian issue as it was published before the lintr release. In any case, I'm posting my fix here in case it can help other people.这可能与此问题无关,因为它是在 lintr 发布_之前_发布的。无论如何,我在这里发布我的修复方法,希望能对其他人有所帮助。

    The same problem, and downgrade can solve. I have reported this to lintr, but I don't know this is a problem of lintr or languageserver, but it will always be solved.

  3. andyluooo commented on Dec 3, 2025

    @andyluooo

    I noticed the same behavior today on a new project, despite having used the combination of languageserver with VSCode for a few years now.

    I noticed that the lintr package had been upgraded a few days ago: https://github.com/r-lib/lintr/releases/tag/v3.3.0-1

    I downgraded to lintr v3.2.0 and this fixed the issue.

    It might not be related to @grimmjulian issue as it was published before the lintr release. In any case, I'm posting my fix here in case it can help other people.

    The core change is that the latest version of lintr no longer automatically reads settings when calling lintr::lint(). To restore the previous behavior, you need to explicitly set parse_settings = TRUE. Since languageserver uses dynamic linting without specifying this parameter, it ignores all user-defined settings and falls back to defaults.

    Until languageserver is updated, the only workaround is to downgrade lintr to version 3.2.0.

    lint() no longer picks up settings automatically in ad hoc invocations like lint("text\n") or lint(text = "str"). You should set parse_settings=TRUE to force settings to be read. Emacs ESS users may need to update to a recent version, e.g. ESS>20251003.

  4. heavywatal commented on Dec 4, 2025

    @heavywatal
    Contributor

    Another workaround is now available thanks to @pascal-sauer #706: pak::pak("REditorSupport/languageserver#706"), with which we can enjoy the other features of the latest lintr 3.3.

  5. jpasquier commented on Dec 4, 2025

    @jpasquier

    Just tested the workaround and can confirm it works for me as well.

    remotes::install_github("REditorSupport/languageserver@pull/706/head")

    After installing this PR build, the language server correctly picks up the .lintr configuration and the dynamic linting behaves as expected. Thanks again for the fix in #706!

  6. moises-sls commented on Dec 14, 2025

    @moises-sls

    I was facing the same problem when using the r-languageserver in Neovim, and the fix in #706 solved it.

    It was not as simple as downgrading the "lintr" version or using

    remotes::install_github("REditorSupport/languageserver@pull/706/head")
    

    in the R terminal.

    When installing r-languageserver with ":MasonInstall" inside Neovim, the package "languageserver" and all of its dependencies are installed in an isolated library; you can find it somewhere in:

    "~/.local/share/nvim/mason/packages/r-languageserver/build"
    
    Image

    To resolve the problem, we have to install the fix for the "languageserver" package inside the library that Mason created, meaning we have to update the specific "languageserver" that Mason interacts with.

    The fix that worked for me was

    1. We need to first set the path to the library that Mason created and uses for the LSP in Neovim. R will use this path to install the fix, so we will not install the fix in the usual place R installs its packages; we will rather install the fix in the correct directory for Mason to read.
    
    2. You can set the path to the Mason LSP library by doing the following: 
    
              RLS_LIB_PATH="~/.local/share/nvim/mason/packages/r-languageserver/build"
    
    3. Create a new vanilla R session and install the fix in #706:
    
              R --vanilla -e "remotes::install_github('REditorSupport/languageserver@pull/706/head', lib='${RLS_LIB_PATH}', force=TRUE)"
    
    4. This will tell R to install the fix in the correct isolated library that Mason utilizes.
    5.  You can also check the "lintr" version that Mason installed doing:
              R --vanilla -e "print(utils::packageVersion('lintr', lib.loc = '${RLS_LIB_PATH}'))"
         > print(utils::packageVersion('lintr', lib.loc = '/home/msales/.local/share/nvim/mason/packages/r-languageserver/build')) 
            [1] ‘3.3.0.1’
    

    Hope this will help someone else.

  7. mcanouil commented on Jan 29, 2026

    @mcanouil

    Because there does not seem to be any traction on the pull request, here is an ugly approach to overload lintr::lint and restore previous parse_settings value.

    Place in your .Rprofile

    if (nzchar(system.file(package = "lintr"))) {
      setHook(packageEvent("lintr", "onLoad"), function(...) {
        original_lint <- lintr::lint
        assignInNamespace(
          "lint",
          function(..., parse_settings = TRUE) {
            original_lint(..., parse_settings = parse_settings)
          },
          ns = "lintr"
        )
      })
    }

    It's quite unclear from lintr changelog the reason behind this breaking change in the first place, but it seems to be related to emacs users, so it should be safe as in no bad side effects for all other users.

    Warning

    Do not use the above code in a "production" setting.

  8. renkun-ken commented on Feb 6, 2026

    @renkun-ken
    Member

    Closing via #706

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions