aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/nvim/lua/plugins/lsp.lua
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-14 11:43:18 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-14 11:43:18 +0100
commit719d4c5518bda64bd0f8ab8b20d9cb2fe84b5666 (patch)
tree5caab134776d67b83906c3305caa2c20d84dd714 /dot_config/nvim/lua/plugins/lsp.lua
parentfc30488896710667e5d4fd970de81d9daa3cdf88 (diff)
downloaddotfiles-719d4c5518bda64bd0f8ab8b20d9cb2fe84b5666.tar.gz
dotfiles-719d4c5518bda64bd0f8ab8b20d9cb2fe84b5666.tar.bz2
dotfiles-719d4c5518bda64bd0f8ab8b20d9cb2fe84b5666.zip
fix(nvim): skip Mason install for tools already on PATH
Mason's installer tries one source per package. For tools that we already provide via the system package manager (Arch pkgs on the host) or nix-profile (on the remote-dev VM), Mason will keep trying to (re-)install via cargo/pip/etc. and report failures — but conform.nvim/nvim-lint resolve their binary from PATH anyway, so the Mason install is redundant. Filter ensure_installed at startup against vim.fn.executable(). Keeps behaviour identical on a fresh host (Mason still pulls everything), but silences spurious failures for tools that the user has chosen to provide system-wide (shellharden via nix-profile being the immediate case).
Diffstat (limited to 'dot_config/nvim/lua/plugins/lsp.lua')
-rw-r--r--dot_config/nvim/lua/plugins/lsp.lua101
1 files changed, 57 insertions, 44 deletions
diff --git a/dot_config/nvim/lua/plugins/lsp.lua b/dot_config/nvim/lua/plugins/lsp.lua
index 1a115db..69f8163 100644
--- a/dot_config/nvim/lua/plugins/lsp.lua
+++ b/dot_config/nvim/lua/plugins/lsp.lua
@@ -19,50 +19,63 @@ require("mason-lspconfig").setup({
},
})
require("mason-tool-installer").setup({
- ensure_installed = {
- "actionlint",
- "autotools-language-server",
- "basedpyright",
- "bash-language-server",
- "clangd",
- "codelldb",
- "codespell",
- "css-lsp",
- "dockerfile-language-server",
- "gh",
- "gh-actions-language-server",
- "groovy-language-server",
- "hadolint",
- "html-lsp",
- "jq",
- "json-lsp",
- "jsonlint",
- "just-lsp",
- "lua-language-server",
- "markdownlint",
- "mdformat",
- "neocmakelsp",
- "nginx-config-formatter",
- "nginx-language-server",
- "npm-groovy-lint",
- "prettier",
- "ruff",
- "rust-analyzer",
- "selene",
- "shellcheck",
- "shellharden",
- "shfmt",
- "stylelint",
- "stylua",
- "systemd-lsp",
- "systemdlint",
- "taplo",
- "typescript-language-server",
- "typos",
- "yaml-language-server",
- "yamllint",
- "yq",
- },
+ ensure_installed = (function()
+ local tools = {
+ "actionlint",
+ "autotools-language-server",
+ "basedpyright",
+ "bash-language-server",
+ "clangd",
+ "codelldb",
+ "codespell",
+ "css-lsp",
+ "dockerfile-language-server",
+ "gh",
+ "gh-actions-language-server",
+ "groovy-language-server",
+ "hadolint",
+ "html-lsp",
+ "jq",
+ "json-lsp",
+ "jsonlint",
+ "just-lsp",
+ "lua-language-server",
+ "markdownlint",
+ "mdformat",
+ "neocmakelsp",
+ "nginx-config-formatter",
+ "nginx-language-server",
+ "npm-groovy-lint",
+ "prettier",
+ "ruff",
+ "rust-analyzer",
+ "selene",
+ "shellcheck",
+ "shellharden",
+ "shfmt",
+ "stylelint",
+ "stylua",
+ "systemd-lsp",
+ "systemdlint",
+ "taplo",
+ "typescript-language-server",
+ "typos",
+ "yaml-language-server",
+ "yamllint",
+ "yq",
+ }
+ -- Skip Mason install when the tool is already on PATH from the system
+ -- (e.g. shellharden via nix-profile on the remote-dev VM, where Mason's
+ -- cargo-build install path would fail). Mason's runners still discover
+ -- PATH binaries, so conform.nvim/nvim-lint keep working.
+ local filtered = {}
+ for _, name in ipairs(tools) do
+ if vim.fn.executable(name) ~= 1 then
+ table.insert(filtered, name)
+ end
+ end
+ return filtered
+ end)(),
})
vim.api.nvim_create_autocmd("LspAttach", {