dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit 93c112feb3397b704df836c5c750071a3de243f0
parent a07dea04f01747dd349bb4a7b8c6853c51e978bd
Author: Chris Bracken <chris@bracken.jp>
Date:   Wed, 28 Aug 2024 07:37:44 -0700

vim: only set up language servers if installed

If a language server hasn't been ported to, for example OpenBSD, or
isn't installed on a given machine, leave it disabled.

Diffstat:
M.config/nvim/lua/plugins/languages.lua | 32+++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/.config/nvim/lua/plugins/languages.lua b/.config/nvim/lua/plugins/languages.lua @@ -56,19 +56,29 @@ return { event = { "BufReadPre", "BufNewFile" }, config = function() local lspconfig = require('lspconfig') - lspconfig.clangd.setup({}) - lspconfig.dartls.setup({}) - lspconfig.lua_ls.setup({}) - lspconfig.rust_analyzer.setup({}) - lspconfig.sourcekit.setup({ - capabilities = { - workspace = { - didChangeWatchedFiles = { - dynamicRegistration = true, + if vim.fn.executable('clangd') == 1 then + lspconfig.clangd.setup({}) + end + if vim.fn.executable('dart') == 1 then + lspconfig.dartls.setup({}) + end + if vim.fn.executable('lua-language-server') == 1 then + lspconfig.lua_ls.setup({}) + end + if vim.fn.executable('rust-analyzer') == 1 then + lspconfig.rust_analyzer.setup({}) + end + if vim.fn.executable('sourcekit-lsp') == 1 then + lspconfig.sourcekit.setup({ + capabilities = { + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = true, + }, }, }, - }, - }) + }) + end vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}),