This was a little tough to figure out for me as well. What really made it click was the linked comment on the github issue (1).
Replicating here - to figure out your server’s capabilities, you can do (in the vim commandline):
lua =vim.lsp.get_active_clients()[1].name
to figure out which language server you’re trying to check, then
lua =vim.lsp.get_active_clients()[1].server_capabilities
to list its capabilities. The field names now reflect the language server protocol, so they are named things like hoverProvider. Find the field you would like to disable for your provider, then it its setup pass a custom on_attach function (e.g. my config for pylsp that disables its formatting, hover, and renaming):
lspconfig['pylsp'].setup({
enable = true,
-- disable several capabilities in favor of pyright
on_attach = function (client, buffer)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.hoverProvider = false
client.server_capabilities.renameProvider = false
end,
settings = {
pylsp = {
configurationSources = { "flake8", "mypy" },
plugins = {
flake8 = { enabled = true },
mypy = { enabled = true },
},
},
},
})
references:
- resolved_capabilities is deprecated, update your plugins or configuration to access client.server_capabilities i nstead.The new key/value pairs in server_capabilities directly match those defined in the language server protocol · Issue #1891 · neovim/nvim-lspconfig · GitHub
- Automatically choose one language server to format code when using multiple language servers - #2 by mjlbach