updates to dap and golangci-lint detection
This commit is contained in:
@ -1,31 +1,19 @@
|
||||
local M = {
|
||||
filetypes = { 'go', 'gomod' },
|
||||
}
|
||||
return {
|
||||
enable = function() -- disable lsp if wrong version installed
|
||||
local enable = true
|
||||
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()
|
||||
|
||||
-- disable lsp if wrong version installed
|
||||
function M.enable()
|
||||
local enable = true
|
||||
|
||||
if
|
||||
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)
|
||||
then
|
||||
return enable
|
||||
else
|
||||
return false -- disable if golangci-lint isn't available
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
end,
|
||||
}
|
||||
|
||||
@ -31,16 +31,13 @@ function M.setup()
|
||||
local lspconfig = require 'lspconfig'
|
||||
|
||||
for server, config in pairs(servers) do
|
||||
if require('lsp.utils').check_ft(server, config) then
|
||||
if config['enable'] then
|
||||
if not config['enable']() then
|
||||
vim.notify('Disabling language server ' .. server, vim.log.levels.WARN)
|
||||
goto continue
|
||||
end
|
||||
if config['enable'] then
|
||||
if not config.enable() then
|
||||
vim.notify('Disabling language server ' .. server, vim.log.levels.WARN)
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
goto continue
|
||||
end
|
||||
|
||||
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
||||
config.on_attach = require 'lsp.on_attach'
|
||||
vim.lsp.enable(server)
|
||||
|
||||
Reference in New Issue
Block a user