mirror of
https://github.com/pnx/dotfiles
synced 2026-06-18 20:10:03 +02:00
nvim/lua/user/plugins/lsp.lua: remove unused server capabilities options and add server_capabilities field that server config can override.
This commit is contained in:
parent
a56f3652b5
commit
176f522a49
1 changed files with 11 additions and 17 deletions
|
|
@ -56,11 +56,17 @@ return {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
--- @class LSPServerOptions : LSPFeatures
|
--- @class LSPServerOptions : LSPFeatures
|
||||||
|
--- @field server_capabilities? lsp.ServerCapabilities
|
||||||
--- @field on_save function | nil
|
--- @field on_save function | nil
|
||||||
|
|
||||||
|
--- @class LSPFeatures
|
||||||
|
--- @field document_highlight? { enabled: boolean }
|
||||||
|
--- @field codelens? { enabled: boolean }
|
||||||
|
--- @field inlay_hints? { enabled: boolean, exclude?: table }
|
||||||
|
|
||||||
--- @class LSPOptions
|
--- @class LSPOptions
|
||||||
opts = {
|
opts = {
|
||||||
--- @class LSPFeatures
|
--- @type LSPFeatures
|
||||||
features = {
|
features = {
|
||||||
document_highlight = {
|
document_highlight = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
|
|
@ -72,9 +78,6 @@ return {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
exclude = {},
|
exclude = {},
|
||||||
},
|
},
|
||||||
diagnostics = true,
|
|
||||||
hover = true,
|
|
||||||
definition = true,
|
|
||||||
},
|
},
|
||||||
--- @type { string: LSPServerOptions }
|
--- @type { string: LSPServerOptions }
|
||||||
servers = {},
|
servers = {},
|
||||||
|
|
@ -106,19 +109,10 @@ return {
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
|
|
||||||
-- disable diagnostics
|
-- Override any server capabilities.
|
||||||
if server_opts.diagnostics == false then
|
client.server_capabilities = vim.tbl_extend("force",
|
||||||
client.server_capabilities.diagnosticProvider = false
|
client.server_capabilities,
|
||||||
end
|
server_opts.server_capabilities or {})
|
||||||
|
|
||||||
-- disable hover
|
|
||||||
if server_opts.hover == false then
|
|
||||||
client.server_capabilities.hoverProvider = false
|
|
||||||
end
|
|
||||||
|
|
||||||
if server_opts.definition == false then
|
|
||||||
client.server_capabilities.definitionProvider = false
|
|
||||||
end
|
|
||||||
|
|
||||||
if server_opts.inlay_hints.enabled and client.supports_method("textDocument/inlayHint") then
|
if server_opts.inlay_hints.enabled and client.supports_method("textDocument/inlayHint") then
|
||||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue