mirror of
https://github.com/pnx/dotfiles
synced 2026-07-03 06:53:40 +02:00
nvim: lsp: allow server configuration to override lsp features.
This commit is contained in:
parent
8f78a1b7d1
commit
3639b9e46b
2 changed files with 15 additions and 4 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
local lspservers = {
|
local lspservers = {
|
||||||
phpactor = {},
|
phpactor = {
|
||||||
|
inlay_hints = {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -60,20 +60,27 @@ return {
|
||||||
has_cmp and cmp_lsp.default_capabilities() or {})
|
has_cmp and cmp_lsp.default_capabilities() or {})
|
||||||
|
|
||||||
for name, server_opts in pairs(opts.servers) do
|
for name, server_opts in pairs(opts.servers) do
|
||||||
|
|
||||||
|
local features = vim.tbl_deep_extend("force", {
|
||||||
|
codelens = opts.codelens,
|
||||||
|
inlay_hints = opts.inlay_hints,
|
||||||
|
document_highlight = opts.document_highlight
|
||||||
|
}, server_opts)
|
||||||
|
|
||||||
---@param client vim.lsp.Client
|
---@param client vim.lsp.Client
|
||||||
---@param bufnr number
|
---@param bufnr number
|
||||||
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 })
|
||||||
|
|
||||||
if (opts.inlay_hints.enabled or false) and client.server_capabilities.inlayHintProvider then
|
if features.inlay_hints.enabled and client.server_capabilities.inlayHintProvider then
|
||||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.codelens.enabled and client.server_capabilities.codeLensProvider then
|
if features.codelens.enabled and client.server_capabilities.codeLensProvider then
|
||||||
utils.codelens(augroup, bufnr)
|
utils.codelens(augroup, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.document_highlight.enabled and client.server_capabilities.documentHighlightProvider then
|
if features.document_highlight.enabled and client.server_capabilities.documentHighlightProvider then
|
||||||
utils.document_highlight(bufnr)
|
utils.document_highlight(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue