Skip to content

.lintr appears to be ignored for diagnostics when languageserver lints open documents #726

@wjdhamilton

Description

@wjdhamilton

I couldn't get R's language server to respect my .lintr file in Neovim. Eventually, ChatGPT fixed it for me. I got it to write the issue up, as follows:

I think languageserver may be bypassing lintr config for in-editor diagnostics.

What I’m seeing:

  • Neovim with R languageserver shows many default lintr style messages
  • my global/project .lintr disables those linters
  • plain lintr::lint(path) respects the .lintr config
  • but diagnostics published by languageserver in neovim still use the default linters

After debugging this, it looks like languageserver calls:

lintr::lint(path, text = content)

and on my setup this behaves differently from:

lintr::lint(path)

In particular, when text = content is supplied, .lintr settings do not seem to be applied unless parse_settings = TRUE is passed explicitly.

I was able to reproduce the difference outside the editor:

library(lintr)

lint("some_file.R")
# respects .lintr

txt <- readLines("functions_1.R", warn = FALSE)
lint("functions_1.R", text = txt, cache = FALSE)
# ignores .lintr and emits default style linters

On my machine, forcing parse_settings = TRUE for the text = ... call makes diagnostics match the expected .lintr behavior.

Expected behavior:

  • diagnostics produced through languageserver should honor project/global .lintr in the same way as normal lintr::lint(path) runs

Observed behavior:

  • languageserver diagnostics ignore disabled linters from .lintr and emit default style warnings

Environment:

  • languageserver 0.3.16
  • lintr 3.3.0.1
  • Neovim 0.11.6
  • macOS

Happy to provide a minimal repro if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions