|
|
|
@ -12,7 +12,6 @@ local path_sep = require"navigator.util".path_sep()
|
|
|
|
|
local mk_handler = require"navigator.util".mk_handler
|
|
|
|
|
local path_cur = require"navigator.util".path_cur()
|
|
|
|
|
diagnostic_list[vim.bo.filetype] = {}
|
|
|
|
|
|
|
|
|
|
local function clear_diag_VT(bufnr) -- important for clearing out when no more errors
|
|
|
|
|
log(bufnr, _NG_VT_DIAG_NS)
|
|
|
|
|
if bufnr == nil or _NG_VT_DIAG_NS == nil then
|
|
|
|
@ -172,7 +171,7 @@ end
|
|
|
|
|
|
|
|
|
|
local update_err_marker_async = function()
|
|
|
|
|
local debounce = require'navigator.debounce'.debounce_trailing
|
|
|
|
|
return debounce(200, error_marker)
|
|
|
|
|
return debounce(400, error_marker)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local diag_hdlr = mk_handler(function(err, result, ctx, config)
|
|
|
|
@ -194,6 +193,7 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local client_id = ctx.client_id
|
|
|
|
|
local bufnr = ctx.bufnr or 0
|
|
|
|
|
if result.diagnostics ~= nil and result.diagnostics ~= {} then
|
|
|
|
|
trace('diagnostic', result.diagnostics, ctx, config)
|
|
|
|
|
end
|
|
|
|
@ -206,6 +206,13 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
|
|
|
|
|
vim.lsp.diagnostic.on_publish_diagnostics(err, _, result, ctx.client_id, _, config)
|
|
|
|
|
end
|
|
|
|
|
local uri = result.uri
|
|
|
|
|
|
|
|
|
|
local diag_cnt = get_count(bufnr, [[Error]]) + get_count(bufnr, [[Warning]])
|
|
|
|
|
|
|
|
|
|
if result.diagnostics == {} and diag_cnt > 0 then
|
|
|
|
|
log("no result? ", diag_cnt)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- trace("diag: ", mode, result, ctx, config)
|
|
|
|
|
if result and result.diagnostics then
|
|
|
|
|
local item_list = {}
|
|
|
|
@ -216,7 +223,7 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
|
|
|
|
|
item.lnum = v.range.start.line + 1
|
|
|
|
|
item.col = v.range.start.character + 1
|
|
|
|
|
item.uri = uri
|
|
|
|
|
trace(item)
|
|
|
|
|
-- trace(item)
|
|
|
|
|
local head = _NgConfigValues.icons.diagnostic_head
|
|
|
|
|
if v.severity == 1 then
|
|
|
|
|
head = _NgConfigValues.icons.diagnostic_head_severity_1
|
|
|
|
@ -227,6 +234,16 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
|
|
|
|
|
if v.severity > 2 then
|
|
|
|
|
head = _NgConfigValues.icons.diagnostic_head_severity_3
|
|
|
|
|
end
|
|
|
|
|
if v.relatedInformation and v.relatedInformation[1] then
|
|
|
|
|
local info = v.relatedInformation[1]
|
|
|
|
|
-- trace(info)
|
|
|
|
|
if info.message then
|
|
|
|
|
v.releated_msg = info.message
|
|
|
|
|
end
|
|
|
|
|
if info.location and info.location.range then
|
|
|
|
|
v.releated_lnum = info.location.range.start.line
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local bufnr1 = vim.uri_to_bufnr(uri)
|
|
|
|
|
local loaded = vim.api.nvim_buf_is_loaded(bufnr1)
|
|
|
|
|
if _NgConfigValues.diagnostic_load_files then
|
|
|
|
@ -239,18 +256,29 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
|
|
|
|
|
local line = (vim.api.nvim_buf_get_lines(bufnr1, row, row + 1, false) or {""})[1]
|
|
|
|
|
if line ~= nil then
|
|
|
|
|
item.text = head .. line .. _NgConfigValues.icons.diagnostic_head_description .. v.message
|
|
|
|
|
table.insert(item_list, item)
|
|
|
|
|
else
|
|
|
|
|
error("diagnostic result empty line", v, row, bufnr1)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
item.text = head .. _NgConfigValues.icons.diagnostic_head_description .. v.message
|
|
|
|
|
table.insert(item_list, item)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if v.releated_msg then
|
|
|
|
|
item.text = item.text .. '; ' .. item.releated_msg
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if v.releated_lnum then
|
|
|
|
|
item.text = item.text .. ":" .. tostring(item.releated_lnum)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
table.insert(item_list, item)
|
|
|
|
|
end
|
|
|
|
|
-- local old_items = vim.fn.getqflist()
|
|
|
|
|
diagnostic_list[ft][uri] = item_list
|
|
|
|
|
trace(uri, ft, item_list)
|
|
|
|
|
if diagnostic_list[ft][uri] == nil then
|
|
|
|
|
diagnostic_list[ft][uri] = {}
|
|
|
|
|
end
|
|
|
|
|
diagnostic_list[ft][uri][tostring(client_id)] = item_list
|
|
|
|
|
trace(uri, ft, diagnostic_list)
|
|
|
|
|
if not result.uri then
|
|
|
|
|
result.uri = uri
|
|
|
|
|
end
|
|
|
|
@ -265,6 +293,11 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
local diag_hdlr_async = function()
|
|
|
|
|
local debounce = require'navigator.debounce'.debounce_trailing
|
|
|
|
|
return debounce(100, diag_hdlr)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
local diagnostic_cfg = {
|
|
|
|
|
-- Enable underline, use default values
|
|
|
|
@ -307,9 +340,11 @@ M.show_buf_diagnostics = function()
|
|
|
|
|
-- vim.fn.setqflist({}, " ", {title = "LSP", items = diagnostic_list[vim.bo.filetype]})
|
|
|
|
|
local results = diagnostic_list[vim.bo.filetype]
|
|
|
|
|
local display_items = {}
|
|
|
|
|
for _, items in pairs(results) do
|
|
|
|
|
for _, it in pairs(items) do
|
|
|
|
|
table.insert(display_items, it)
|
|
|
|
|
for _, client_items in pairs(results) do
|
|
|
|
|
for _, items in pairs(client_items) do
|
|
|
|
|
for _, it in pairs(items) do
|
|
|
|
|
table.insert(display_items, it)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- log(display_items)
|
|
|
|
|