From 3639b9e46ba6956b921efdeb13e3877876347f28 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 12 Sep 2024 15:52:21 +0200 Subject: [PATCH] nvim: lsp: allow server configuration to override lsp features. --- nvim/lua/user/plugins/lang/php.lua | 6 +++++- nvim/lua/user/plugins/lsp.lua | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/nvim/lua/user/plugins/lang/php.lua b/nvim/lua/user/plugins/lang/php.lua index faee12a..16bb396 100644 --- a/nvim/lua/user/plugins/lang/php.lua +++ b/nvim/lua/user/plugins/lang/php.lua @@ -1,5 +1,9 @@ local lspservers = { - phpactor = {}, + phpactor = { + inlay_hints = { + enabled = false + } + }, } return { diff --git a/nvim/lua/user/plugins/lsp.lua b/nvim/lua/user/plugins/lsp.lua index 561f215..e6d1825 100644 --- a/nvim/lua/user/plugins/lsp.lua +++ b/nvim/lua/user/plugins/lsp.lua @@ -60,20 +60,27 @@ return { has_cmp and cmp_lsp.default_capabilities() or {}) 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 bufnr number local on_attach = function(client, 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 }) 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) 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) end