diff --git a/nvim/lua/darcula/config/init.lua b/nvim/lua/darcula/config/init.lua index 3229595..5e2c9c8 100644 --- a/nvim/lua/darcula/config/init.lua +++ b/nvim/lua/darcula/config/init.lua @@ -29,6 +29,8 @@ NV_DARCULA_COLOR_SCHEME = NV_DARCULA_TERMGUI_COLORS = utils.parse_env("NV_DARCULA_TERMGUI_COLORS", utils.detect_termguicolors()) NV_DARCULA_ENABLE_COC = utils.parse_env("NV_DARCULA_ENABLE_COC", true) +NV_DARCULA_USE_SYSTEM_BASH_LS = + utils.parse_env("NV_DARCULA_USE_SYSTEM_BASH_LS", false) NV_DARCULA_ENABLE_CODE_LENS = utils.parse_env("NV_DARCULA_ENABLE_CODE_LENS", false) NV_DARCULA_ENABLE_DAP = utils.parse_env("NV_DARCULA_ENABLE_DAP", true) @@ -165,7 +167,6 @@ NV_DARCULA_MASON_INST_LIST = utils.parse_env_list( "NV_DARCULA_MASON_INST_LIST", { - "bashls", "clangd", "cmake", "cspell_ls", diff --git a/nvim/lua/darcula/setup/050_mason.lua b/nvim/lua/darcula/setup/050_mason.lua index 35b532b..fc57885 100644 --- a/nvim/lua/darcula/setup/050_mason.lua +++ b/nvim/lua/darcula/setup/050_mason.lua @@ -35,6 +35,12 @@ require("mason").setup { local ensure_installed = vim.deepcopy(NV_DARCULA_MASON_INST_LIST) vim.list_extend(ensure_installed, NV_DARCULA_MASON_TOOL_LIST) +-- When not using the system-installed bash-language-server, let mason install +-- and manage bashls like any other server. +if not NV_DARCULA_USE_SYSTEM_BASH_LS then + table.insert(ensure_installed, "bashls") +end + local installer = require("mason-tool-installer") installer.setup { ensure_installed = ensure_installed, diff --git a/nvim/lua/darcula/setup/100_mason.lua b/nvim/lua/darcula/setup/100_mason.lua index 1181664..3531ac9 100644 --- a/nvim/lua/darcula/setup/100_mason.lua +++ b/nvim/lua/darcula/setup/100_mason.lua @@ -24,10 +24,25 @@ end ---@diagnostic disable-next-line: deprecated local unpacker = table.unpack or unpack +-- Servers whose binaries are installed on the system (not managed by mason). +-- mason-lspconfig's automatic_enable only enables servers whose mason package +-- is installed, so these must be excluded there and enabled explicitly below. +local system_installed = {"vala_ls"} + +-- When using the system-installed bash-language-server (Dockerfile.extra), +-- bashls must be enabled explicitly rather than via mason. +if NV_DARCULA_USE_SYSTEM_BASH_LS then + table.insert(system_installed, "bashls") +end + -- Exclude servers that are not managed by mason (e.g., system-installed) -local mason_lsp_auto_enable = vim.tbl_filter(function(name) - return not vim.tbl_contains({"vala_ls"}, name) -end, NV_DARCULA_MASON_LSP_LIST) +local mason_lsp_auto_enable = + vim.tbl_filter( + function(name) + return not vim.tbl_contains(system_installed, name) + end, + NV_DARCULA_MASON_LSP_LIST +) require("mason-lspconfig").setup { automatic_enable = mason_lsp_auto_enable @@ -148,6 +163,10 @@ for _, name in pairs(NV_DARCULA_MASON_LSP_LIST) do } } ) + elseif name == "bashls" and NV_DARCULA_USE_SYSTEM_BASH_LS then + -- system-installed (Dockerfile.extra); mason does not manage it + vim.lsp.config(name, {}) + vim.lsp.enable(name) elseif name == "vala_ls" then vim.lsp.config(name, {}) vim.lsp.enable(name)