diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index 26f7a35..93b0c9a 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -1,54 +1,3 @@ --- Language servers -local ensure_installed = { - 'clangd', -- C/C++ - 'lua_ls', -- Lua - 'opencl_ls', -- OpenCL - 'harper_ls', -- Spelling & grammar - 'marksman', -- Markdown - 'tinymist', -- Typst -} - -if vim.fn.executable('npm') == 1 then - local ensure_install_from_npm = { - 'ansiblels', -- Ansible - 'bashls', -- Bash - 'docker_compose_language_service', -- Docker Compose - 'dockerls', -- Dockerfile - 'html', -- HTML - 'jsonls', -- JSON - 'pyright', -- Python - 'vimls', -- VimScript - 'yamlls', -- YAML - } - for _, package in ipairs(ensure_install_from_npm) do - table.insert(ensure_installed, package) - end -end - -if vim.fn.executable('pip') == 1 then - local ensure_install_from_pip = { - 'cmake', -- CMake - 'esbonio', -- Sphinx - 'ruff', -- Python - } - for _, package in ipairs(ensure_install_from_pip) do - table.insert(ensure_installed, package) - end -end - -if vim.fn.executable('go') == 1 then - local ensure_installed_from_go = { - 'gopls', -- Go - } - for _, package in ipairs(ensure_installed_from_go) do - table.insert(ensure_installed, package) - end -end - -if vim.fn.has('win32') == 1 then - table.insert(ensure_installed, 'powershell_es') -end - return { 'neovim/nvim-lspconfig', dependencies = { @@ -131,9 +80,48 @@ return { end require('mason').setup() + + local language_servers = { + 'clangd', -- C/C++ + 'lua_ls', -- Lua + 'opencl_ls', -- OpenCL + 'harper_ls', -- Spelling & grammar + 'marksman', -- Markdown + 'tinymist', -- Typst + } + + if vim.fn.executable('npm') == 1 then + for _, package in ipairs({ + 'ansiblels', -- Ansible + 'bashls', -- Bash + 'docker_compose_language_service', -- Docker Compose + 'dockerls', -- Dockerfile + 'html', -- HTML + 'jsonls', -- JSON + 'pyright', -- Python + 'vimls', -- VimScript + 'yamlls', -- YAML + }) do table.insert(language_servers, package) end + end + + if vim.fn.executable('pip') == 1 then + for _, package in ipairs({ + 'cmake', -- CMake + 'esbonio', -- Sphinx + 'ruff', -- Python + }) do table.insert(language_servers, package) end + end + + if vim.fn.executable('go') == 1 then + table.insert(language_servers, 'gopls') -- Go + end + + if vim.fn.has('win32') == 1 then + table.insert(language_servers, 'powershell_es') -- PowerShell + end + require('mason-lspconfig').setup({ - automatic_enable = true, - ensure_installed = ensure_installed, + ensure_installed = language_servers, }) -- (Dis|en)able harper-ls when spell mode is (dis|en)enabled. @@ -266,10 +254,10 @@ return { local mason_registry = require('mason-registry') if mason_registry.is_installed('harper-ls') then -- Disable builtin spell mode highlighting - vim.cmd.highlight('SpellBad', 'NONE') - vim.cmd.highlight('SpellCap', 'NONE') + vim.cmd.highlight('SpellBad', 'NONE') + vim.cmd.highlight('SpellCap', 'NONE') vim.cmd.highlight('SpellLocal', 'NONE') - vim.cmd.highlight('SpellRare', 'NONE') + vim.cmd.highlight('SpellRare', 'NONE') end end }