use on_init to check golangci_lint_ls version
also ensure language servers are compatible with navbuddy before registering them
This commit is contained in:
@ -1,21 +0,0 @@
|
|||||||
return {
|
|
||||||
enable = function() -- disable lsp if wrong version installed
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
@ -1,5 +1,7 @@
|
|||||||
return function(client, bufnr)
|
return function(client, bufnr)
|
||||||
|
if client.server_capabilities.documentSymbolProvider then
|
||||||
require('nvim-navbuddy').attach(client, bufnr)
|
require('nvim-navbuddy').attach(client, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
local nmap = function(keys, func, desc)
|
local nmap = function(keys, func, desc)
|
||||||
if desc then
|
if desc then
|
||||||
|
|||||||
@ -1,5 +1,25 @@
|
|||||||
local M = {}
|
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()
|
function M.setup()
|
||||||
local servers = {
|
local servers = {
|
||||||
ts_ls = { filetypes = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' } },
|
ts_ls = { filetypes = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' } },
|
||||||
@ -21,29 +41,29 @@ function M.setup()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
golangci_lint_ls = require 'plugins.lsp.golangci_lint_ls',
|
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' } },
|
erlangls = { cmd = { '/home/fergusmolloy/.local/bin/erlang_ls' }, filetypes = { 'erlang' } },
|
||||||
elixirls = { cmd = { 'elixir-ls' }, filetypes = { 'elixir' } },
|
elixirls = { cmd = { 'elixir-ls' }, filetypes = { 'elixir' } },
|
||||||
lua_ls = require 'plugins.lsp.lua_ls',
|
lua_ls = require 'plugins.lsp.lua_ls',
|
||||||
}
|
}
|
||||||
|
|
||||||
local on_attach = require 'plugins.lsp.on_attach'
|
|
||||||
local lspconfig = require 'lspconfig'
|
|
||||||
|
|
||||||
for server, config in pairs(servers) do
|
for server, config in pairs(servers) do
|
||||||
if config['enable'] then
|
|
||||||
if not config.enable() then
|
|
||||||
vim.notify('Disabling language server ' .. server, vim.log.levels.WARN)
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
||||||
config.on_attach = require 'plugins.lsp.on_attach'
|
config.on_attach = require 'plugins.lsp.on_attach'
|
||||||
vim.lsp.enable(server)
|
vim.lsp.enable(server)
|
||||||
vim.lsp.config(server, config)
|
vim.lsp.config(server, config)
|
||||||
|
|
||||||
::continue::
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user