Pylsp config is not taken into account

Hi,

I have been unable to change any of the settings or activate/deactivate plugins in my pylsp setup.
I’ve detailed my issue on the pylsp repo and on the lspconfig repo, and was finally directed here.

My setup:

NVIM v0.6.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

and a simplified version of my config:

local lspconfig = require "lspconfig"
local util = require "lspconfig.util"

local servers = {
  pylsp = {
    cmd = {"pylsp"},
    root_dir = function(fname)
      local root_files = {
        'pyproject.toml',
        'setup.py',
        'setup.cfg',
        'requirements.txt',
        'Pipfile',
      }
      return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
    end,
    settings = {
      configurationSources = {"pylint"},
      plugins = {
        pylint = { enabled = true },
        flake8 = { enabled = false },
        pycodestyle = { enabled = false },
        pyflakes = { enabled = false },
      }
    }
  }
}

local client_capabilities = vim.lsp.protocol.make_client_capabilities()
client_capabilities.textDocument.completion.completionItem.snippetSupport = true
client_capabilities.textDocument.completion.completionItem.resolveSupport = {
  properties = { 'documentation', 'detail', 'additionalTextEdits' },
}
-- for nvim_cmp
client_capabilities = require('cmp_nvim_lsp').update_capabilities(client_capabilities)

for server, config in pairs(servers) do
  if type(config) == 'function' then
    config = config()
  end
  config.on_attach = on_attach
  config.capabilities = vim.tbl_deep_extend(
    'keep',
    config.capabilities or {},
    client_capabilities
  )
  lspconfig[server].setup(config)
end

Does this config appear reasonable, and if so would you know where I can go from here?

Thanks in advance for your support!

Like I mentioned on your issue, you need to have a nested pylsp table under settings (according to their documentation)

local servers = {
  pylsp = {
    cmd = {"pylsp"},
    root_dir = function(fname)
      local root_files = {
        'pyproject.toml',
        'setup.py',
        'setup.cfg',
        'requirements.txt',
        'Pipfile',
      }
      return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
    end,
    settings = {
      pylsp = {
      configurationSources = {"pylint"},
      plugins = {
        pylint = { enabled = true },
        flake8 = { enabled = false },
        pycodestyle = { enabled = false },
        pyflakes = { enabled = false },
      }
    }
    }
  }
}

I noticed the difference in the config you show right after submitting – the nesting was subtle and I missed it the first time around. Thanks for your help, my config now works!