local M = {} local enable = { ['golangci_lint_ls'] = function() local enable = true local ok, _ = pcall(function() vim .system({ 'golangci-lint', '--version' }, { text = true }, function(out) if out.code ~= 0 then enable = false return end if out.stdout:match ' 1%.%d+%.%d+' then enable = false return end end) :wait() end) return enable and ok end, } function M.setup() local servers = { ts_ls = { filetypes = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' } }, gopls = { filetypes = { 'go', 'gomod' } }, rust_analyzer = { filetypes = { 'rust' }, settings = { ['rust-analyzer'] = { check = { command = 'clippy', extraArgs = { '--', '-Dclippy::correctness', '-Wclippy::complexity', '-Wclippy::pedantic', '-Wclippy::perf', '-Aclippy::missing_errors_doc', '-Aclippy::missing_panics_doc', }, }, }, }, }, golangci_lint_ls = { filetypes = { 'go' }, on_init = function(client) local name = client.name if enable[name] then if not enable[name]() then vim.notify('Disabling language server ' .. name, vim.log.levels.WARN) vim.lsp.enable(client.name, false) return end end end, }, erlangls = { cmd = { '/home/fergusmolloy/.local/bin/erlang_ls' }, filetypes = { 'erlang' } }, elixirls = { cmd = { 'elixir-ls' }, filetypes = { 'elixir' } }, lua_ls = require 'plugins.lsp.lua_ls', } for server, config in pairs(servers) do config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities) config.on_attach = require 'plugins.lsp.on_attach' vim.lsp.enable(server) vim.lsp.config(server, config) end end return M