2021-07-12 04:25:07 +00:00
|
|
|
-- hdlr alternatively, use lua vim.lsp.diagnostic.set_loclist({open_loclist = false})
|
|
|
|
-- true to open loclist
|
2021-09-04 04:51:43 +00:00
|
|
|
-- local diag_hdlr = function(err, method, result, client_id, bufnr, config)
|
|
|
|
-- New signature on_publish_diagnostics({_}, {result}, {ctx}, {config})
|
|
|
|
debug = debug or nil
|
2022-06-01 11:29:13 +00:00
|
|
|
local vfn = vim.fn
|
2021-09-04 04:51:43 +00:00
|
|
|
|
|
|
|
local function hdlr(result)
|
2021-07-12 04:25:07 +00:00
|
|
|
if result and result.diagnostics then
|
|
|
|
local item_list = {}
|
|
|
|
local s = result.uri
|
|
|
|
local fname = s
|
|
|
|
for _, v in ipairs(result.diagnostics) do
|
2022-11-25 02:16:51 +00:00
|
|
|
local _, j = string.find(s, 'file://')
|
2021-07-12 04:25:07 +00:00
|
|
|
if j then
|
|
|
|
fname = string.sub(s, j + 1)
|
|
|
|
end
|
|
|
|
table.insert(item_list, {
|
|
|
|
filename = fname,
|
|
|
|
lnum = v.range.start.line + 1,
|
|
|
|
col = v.range.start.character + 1,
|
2022-02-15 09:30:42 +00:00
|
|
|
text = v.message,
|
2021-07-12 04:25:07 +00:00
|
|
|
})
|
|
|
|
end
|
2022-06-01 11:29:13 +00:00
|
|
|
local old_items = vfn.getqflist()
|
2021-07-12 04:25:07 +00:00
|
|
|
for _, old_item in ipairs(old_items) do
|
|
|
|
if vim.uri_from_bufnr(old_item.bufnr) ~= result.uri then
|
|
|
|
table.insert(item_list, old_item)
|
|
|
|
end
|
|
|
|
end
|
2022-11-25 02:16:51 +00:00
|
|
|
vfn.setqflist({}, ' ', { title = 'LSP', items = item_list })
|
2021-07-12 04:25:07 +00:00
|
|
|
end
|
|
|
|
end
|
2021-09-04 04:51:43 +00:00
|
|
|
|
|
|
|
local diag_hdlr_0_6 = function(err, result, ctx, config)
|
2022-06-01 11:29:13 +00:00
|
|
|
-- vim.lsp.diagnostic.clear(vfn.bufnr(), client.id, nil, nil)
|
2021-09-04 04:51:43 +00:00
|
|
|
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
|
|
|
|
hdlr(result)
|
|
|
|
end
|
|
|
|
|
2022-12-20 11:00:06 +00:00
|
|
|
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(diag_hdlr_0_6, {
|
2022-02-15 09:30:42 +00:00
|
|
|
-- Enable underline, use default values
|
2022-09-27 22:28:05 +00:00
|
|
|
underline = _GO_NVIM_CFG.lsp_diag_underline,
|
2022-02-15 09:30:42 +00:00
|
|
|
-- Enable virtual text, override spacing to 0
|
|
|
|
virtual_text = _GO_NVIM_CFG.lsp_diag_virtual_text,
|
|
|
|
-- Use a function to dynamically turn signs off
|
|
|
|
-- and on, using buffer local variables
|
|
|
|
signs = _GO_NVIM_CFG.lsp_diag_signs,
|
|
|
|
-- Disable a feature
|
|
|
|
update_in_insert = _GO_NVIM_CFG.lsp_diag_update_in_insert,
|
|
|
|
})
|