From ff2aa976d49b5b8d9ddc25ecd08eee8bb96edd72 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Wed, 9 Sep 2026 13:00:29 +0200 Subject: Benutze ansiblels nur wenn alle Programme installiert sind --- nvim/lua/plugins/lsp.lua | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'nvim/lua/plugins/lsp.lua') diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index e0ad450..1e552d4 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -1,3 +1,12 @@ +-- Prueft, ob alle genannten Kommandos im PATH liegen. +local function have_all(commands) + for _, command in ipairs(commands) do + if vim.fn.executable(command) == 0 then return false end + end + + return true +end + return { { "neovim/nvim-lspconfig", @@ -97,6 +106,9 @@ return { filetypes = { "yaml.ansible" }, -- Erkennung: siehe config.filetypes settings = { ansible = { + python = { + interpreterPath = "python3", + }, validation = { lint = { enabled = true, @@ -107,8 +119,7 @@ return { }, } - vim.lsp.enable({ - "ansiblels", -- npm install -g @ansible/ansible-language-server & (brew install ansible-lint, pkg install sysutils/py-ansible-lint) + local servers = { "basedpyright", -- npm install -g basedpyright, brew install basedpyright "bashls", -- npm install -g bash-language-server, pkg install hs-ShellCheck "clangd", -- pkg install llvm @@ -117,7 +128,13 @@ return { "lua_ls", -- pkg install lua-language-server, brew install lua-language-server "prismals", -- npm install -g @prisma/language-server "vtsls", -- npm install -g @vtsls/language-server - }) + } + + if have_all({ "ansible-language-server", "ansible-lint", "ansible" }) then + table.insert(servers, 1, "ansiblels") -- npm install -g @ansible/ansible-language-server; brew install ansible-lint ansible, pkg install sysutils/py-ansible-lint sysutils/ansible + end + + vim.lsp.enable(servers) end, }, } -- cgit v1.3