From 9d5b79838584e19dade47480ea86b0cabc62762b Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 15 Apr 2024 21:52:48 +0100 Subject: [PATCH] Cleanup conditional language server installs --- lua/plugins/completions.lua | 71 ++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index b5ba7db..06c4863 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -1,3 +1,42 @@ +-- Language servers +local ensure_installed = { + 'clangd', -- C/C++ + 'lua_ls', -- Lua + 'opencl_ls', -- OpenCL +} + +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 + '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 + 'pyright', -- Python + 'ruff_lsp', -- Python + } + for _, package in ipairs(ensure_install_from_pip) 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 = { @@ -33,38 +72,6 @@ return { config = function() require('mason').setup() - local ensure_installed = { - -- Language servers - 'clangd', -- C/C++ - 'cmake', -- CMake - 'lua_ls', -- Lua - 'opencl_ls', -- OpenCL - } - if vim.fn.executable('npm') == 1 then - local npm_ensure_installed = { - -- Language servers - 'ansiblels', -- Ansible - 'bashls', -- Bash - 'docker_compose_language_service', -- Docker Compose - 'dockerls', -- Dockerfile - 'html', -- HTML - 'jsonls', -- JSON - 'vimls', -- VimScript - 'yamlls', -- YAML - } - for _, package in ipairs(npm_ensure_installed) do - table.insert(ensure_installed, package) - end - end - -- TODO: Where to put these? - -- Language servers - -- 'esbonio', -- Sphinx - -- 'pyright', -- Python - -- 'ruff_lsp', -- Python - -- 'lemminx', -- XML - if vim.fn.has('win32') then - table.insert(ensure_installed, 'powershell_es') - end require('mason-lspconfig').setup({ automatic_installation = false, ensure_installed = ensure_installed,