issue #389 handler for diagnostic is incorrect

pull/390/head
ray-x 8 months ago
parent 000a433b37
commit 668875294d

@ -47,6 +47,7 @@ _GO_NVIM_CFG = {
underline = true,
-- virtual text setup
virtual_text = { space = 0, prefix = '' },
update_in_insert = false,
signs = true,
},
-- deprecated setups
@ -190,16 +191,11 @@ function go.setup(cfg)
end
if _GO_NVIM_CFG.diagnostic then
vim.diagnostic.config({
underline = _GO_NVIM_CFG.diagnostic.underline,
virtual_text = _GO_NVIM_CFG.diagnostic.virtual_text,
signs = _GO_NVIM_CFG.diagnostic.signs,
update_in_insert = _GO_NVIM_CFG.diagnostic.update_in_insert,
})
if _GO_NVIM_CFG.diagnostic ~= false then
require('go.lsp_diag').setup()
end
local cfg = vim.tbl_extend('force', {}, _GO_NVIM_CFG.diagnostic)
cfg.hdlr = nil
vim.diagnostic.config(cfg)
require('go.lsp_diag').setup()
end
vim.defer_fn(function()
require('go.coverage').setup()

@ -174,7 +174,7 @@ local extend_config = function(gopls, opts)
gopls[key] = vim.tbl_deep_extend('force', gopls[key], value)
else
if type(gopls[key]) ~= type(value) and key ~= 'handlers' then
vim.notify('gopls setup for ' .. key .. ' is not ' .. type(value))
vim.notify('gopls setup for ' .. key ..' type:' .. type(gopls[key]) .. ' is not ' .. type(value) .. vim.inspect(value))
end
gopls[key] = value
end

@ -33,21 +33,14 @@ end
return {
setup = function()
local _diag_hdlr
if _GO_NVIM_CFG.diagnostic.hdlr == true then
_diag_hdlr = function(err, result, ctx, config)
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(
function(err, result, ctx, config)
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
hdlr(result)
end
else
diag_hdlr = vim.lsp.diagnostic.on_publish_diagnostics
end
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(diag_hdlr, {
underline = _GO_NVIM_CFG.diagnostic.underline,
virtual_text = _GO_NVIM_CFG.diagnostic.virtual_text,
signs = _GO_NVIM_CFG.diagnostic.signs,
update_in_insert = _GO_NVIM_CFG.diagnostic.update_in_insert,
})
if _GO_NVIM_CFG.diagnostic.hdlr then
hdlr(result)
end
end,
{}
)
end,
handler = diag_hdlr,
}

Loading…
Cancel
Save