Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable Ruff linter in AstroNvim LSP? #12795

Closed
memeLordo opened this issue Aug 10, 2024 · 12 comments
Closed

How to disable Ruff linter in AstroNvim LSP? #12795

memeLordo opened this issue Aug 10, 2024 · 12 comments
Labels
question Asking for support or clarification

Comments

@memeLordo
Copy link

Is there anyway to disable ruff linting completely and leave it only for formattiong? I'm using a NeoVim configuration with Mason. What I have is a double display for linting in basedpyright and ruff:
Error

@memeLordo
Copy link
Author

My previous attemts to set up configuration using help from #12514 and #12778 had no effect.

@MichaReiser
Copy link
Member

MichaReiser commented Aug 10, 2024

Have you tried setting lint.enable

If you need more help, please share your neovim configuration.

@memeLordo
Copy link
Author

Sent request. My config is used by AstroNvim. I tried to put the code at different places, but still nothing seems to work.

@dhruvmanila
Copy link
Member

Can you share your Neovim config? I'm specifically interested in how you've setup basedpyright and Ruff. Which plugins are you using to set them up? Is it just nvim-lspconfig or do you have any other plugins as well?

@dhruvmanila dhruvmanila added the question Asking for support or clarification label Aug 11, 2024
@memeLordo
Copy link
Author

memeLordo commented Aug 11, 2024

Basically, basedpyright and ruff installed via Mason, and it configures using AstroNmiv nested structure. Unfortunately, I haven't been able to find the same configuration for ruff, because it implies that user would be using it as a main linter, instead of basedpyright. Here is an example: astral-sh/ruff-lsp#384 (comment)
ruff works from the package, and I can't manage to configure it inside my nvim-config.

My basedpyright_config.lua:

-- if true then return {} end -- INFO: REMOVE THIS LINE TO ACTIVATE THIS FILE
return {
  "AstroNvim/astrolsp",
  opts = {

    servers = {
      "basedpyright",
    },

    ---@diagnostic disable: missing-fields
    config = {
      basedpyright = {
        before_init = function(_, c)
          if not c.settings then c.settings = {} end
          if not c.settings.python then c.settings.python = {} end
          c.settings.python.pythonPath = vim.fn.exepath "python"
        end,
        settings = {
          basedpyright = {
            analysis = {
              -- ignore = { "*" },
              -- autoImportCompletions = true,
              -- autoSearchPaths = true,
              diagnosticMode = "openFilesOnly",
              useLibraryCodeForTypes = true,
              -- reportMissingImports = true,
              typeCheckingMode = "standard",
            },
          },
        },
      },
    },
  },
}

@dhruvmanila
Copy link
Member

Unfortunately, I haven't been able to find the same configuration for ruff, because it implies that user would be using it as a main linter, instead of basedpyright.

I'm not familiar with AstroNvim but are you saying that Ruff is configured to be the default linter in that framework and you're interested in using Ruff only as a formatter? I couldn't find any references to "ruff" in the repository (https://github.com/search?q=repo:AstroNvim/AstroNvim%20ruff&type=code). It's a bit difficult to help without knowing the way you've configured Ruff in your editor 😅

@memeLordo
Copy link
Author

memeLordo commented Aug 13, 2024

That's the point, it isn't configured at all, but still works. I will ask in a forum of AstroNvim for this and provide the answer once it's gotten here.

@memeLordo
Copy link
Author

memeLordo commented Aug 13, 2024

Have you tried setting lint.enable

If you need more help, please share your neovim configuration.

Here how you, presumably, can configure the same code in AstroNvim:

.../plugins/ruff_config.lua:

return {
  "AstroNvim/astrolsp",
  opts = {
    config = {
      ruff_lsp = {
        settings = {
          ruff = {
            lint = {
              enable = false,
            },
          },
        },
      },
    },
  },
}

@memeLordo
Copy link
Author

But still I get the same double-linting. Will be waiting for the reply from AstroTeam.

@dhruvmanila
Copy link
Member

Can you confirm (via docs?) the name of the Ruff server as defined in the plugin? Is it ruff_lsp or ruff (native server)? Either way, it should be init_options instead of settings if these are the server settings.

@mehalter
Copy link

This was resolved by correctly adding the code from the ruff documentation.

No issue here on the ruff side 😄

return {
  "AstroNvim/astrolsp",
  opts = {
    config = {
      ruff = {
        init_options = {
          settings = {
            lint = { enable = false },
          },
        },
      },
    },
  },
}

@memeLordo
Copy link
Author

memeLordo commented Aug 13, 2024

Yeah, it's true. Thank you a lot!

@dhruvmanila dhruvmanila changed the title Disable Ruff lint How to disable Ruff linter in AstroNvim LSP? Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

4 participants