I want to configure my Python language server (pylsp) in Neovim in a Lua config (init.lua). I just transitioned from a Vimscript to a Lua config with basically zero Lua knowledge and this is causing some headaches. Additionally, I took as my starting point the kickstart.nvim repo so lsp is handled by mason which also is a new tool for me.
The basic setup of pylsp is handled via:
local servers = {
pylsp = {},
sumneko_lua = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
}
-- Setup neovim lua configuration
require('neodev').setup()
--
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Setup mason so it can manage external tooling
require('mason').setup()
-- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig'
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}
mason_lspconfig.setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
}
end,
}
Based on the sumneko_lua config (4th line in the above code block) as well as e.g. https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#pylsp I tried to e.g. configure pycodestyle by replacing:
pylsp = {},
with:
pylsp = {
plugins = {
pycodestyle = {
ignore = {'W391'},
maxLineLength = 100
}
}
},
However the changes seem to not have any effect. When I open a Lua file and run inside nvim:
:lua print(vim.inspect(vim.lsp.get_active_clients()))
I see that the sumneko_lua variable values are altered. However, when I run the same command in a Python file, I don't even see the 'plugins' and any fields of interest.
So, what am I doing wrong and how can I fix it? Eventually I'm interested in trying out 3rd party plugins listed here but to do that I would have to disable some of those active by default in the config.