diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index e122bc0..e311da7 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -82,44 +82,50 @@ return { }, config = function() - local lspconfig_default_opts = { - -- Broadcast full client capabilities to language servers - capabilities = vim.tbl_deep_extend( - 'force', vim.lsp.protocol.make_client_capabilities(), - require('cmp_nvim_lsp').default_capabilities()), - } + local capabilities = vim.tbl_deep_extend( + 'force', vim.lsp.protocol.make_client_capabilities(), + require('cmp_nvim_lsp').default_capabilities()) - require('mason').setup() - require('mason-lspconfig').setup({ - automatic_installation = false, - ensure_installed = ensure_installed, - }) + local server_opts = { + clangd = { + cmd = { 'clangd', '--completion-style=detailed' }, + }, - vim.lsp.config('clangd', { - cmd = { 'clangd', '--completion-style=detailed' }, - }) - - vim.lsp.config('lua_ls', { - settings = { - Lua = { - diagnostics = { - disable = { 'missing-fields', }, - globals = { 'vim', }, + lua_ls = { + settings = { + Lua = { + diagnostics = { + disable = { 'missing-fields', }, + globals = { 'vim', }, + }, }, }, }, - }) - vim.lsp.config('pyright', { - settings = { - pyright = { - disableOrganizeImports = true, + pyright = { + settings = { + pyright = { + disableOrganizeImports = true, + }, }, }, - }) - vim.lsp.config('harper_ls', { - filetypes = {}, -- Disable for all filetypes + harper_ls = { + filetypes = {}, -- Disable for all filetypes + }, + } + + for server, opts in pairs(server_opts) do + -- Broadcast full client capabilities to language servers + opts.capabilities = vim.tbl_deep_extend( + 'force', {}, capabilities, opts.capabilities or {}) + vim.lsp.config(server, opts) + end + + require('mason').setup() + require('mason-lspconfig').setup({ + automatic_enable = true, + ensure_installed = ensure_installed, }) -- (Dis|en)able harper-ls when spell mode is (dis|en)enabled.