'how to disable linter in pylsp?

My neovim(0.6.1) use nvim-lint manage pylint, use pylsp for completion.

When edit a python file, use numpy, scipy etc, the code competion, hover, signature is slow, and cpu use 100%. The code have same lint notion twice. I want disable linter in pylsp, but it not work. How can i do?

This is my config: pylsp.lua

opts = {
    cmd = { "pylsp" },
    filetypes = { "python" },
    root_dir = function()
        return vim.fn.getcwd()
    end,
    single_file_support = true,
    configurationSources = {""},  -- default is pycodestyle
    rope = {extensionModules = "", ropeFolder = {} },
    plugins = {
        jedi_completion = {
            enabled = true,
            eager = true,
            cache_for = {"numpy", "scipy"}
        },
        jedi_definition = {
            enabled = true,
            follow_imports = true,
            follow_builtin_imports = true,
        },
        jedi_hover = { enabled = true },
        jedi_references = { enabled = true },
        jedi_signature_help = { enabled = true },
        jedi_symbols = { enabled = true, all_scopes = true, include_import_symbols = true },
        preload = { enabled = true, modules = {"numpy", "scipy"} },
        mccabe = { enabled = false },
        mypy = { enabled = false },
        isort = { enabled = false },
        spyder = { enabled = false },
        memestra = { enabled = false },
        pycodestyle = { enabled = false },  -- not work
        flake8 = { enabled = false },
        pyflakes = { enabled = false },
        yapf = { enabled = false },
        pylint = {
            enabled = false,
            args = {
                "-f",
                "json",
                "--rcfile=" .. "~/.pylintrc"
            }
        },
        rope = { enabled = false },
        rope_completion = { enabled = false, eager = false },
    },
}
pylsp.setup(opts)


Solution 1:[1]

I managed to disable pylst linters in lspconfig setup:

For example, if you use the suggested configuration of nvim-lspconfig, you can change the lspconfig.pylsp.setup and configure any plugin you like:

-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  -- Enable completion triggered by <c-x><c-o>
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

  -- Mappings.
  -- See `:help vim.lsp.*` for documentation on any of the below functions
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end

require('lspconfig').pylsp.setup {
  on_attach = on_attach,
  flags = {
    -- This will be the default in neovim 0.7+
    debounce_text_changes = 150,
  }
  settings = {
    -- configure plugins in pylsp
    pylsp = {
      plugins = {
        pyflakes = {enabled = false},
        pylint = {enabled = false},
      },
    },
  },
}

Hope it works!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community