LSP: show diagnostic in qf/loclist #11777
instead of the content of the file at this line. ref https://github.com/neovim/nvim-lsp/issues/69
This commit is contained in:
parent
b2062368e7
commit
e956ea7672
|
@ -704,7 +704,7 @@ do
|
||||||
end
|
end
|
||||||
|
|
||||||
local position_sort = sort_by_key(function(v)
|
local position_sort = sort_by_key(function(v)
|
||||||
return {v.line, v.character}
|
return {v.start.line, v.start.character}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Returns the items with the byte position calculated correctly and in sorted
|
-- Returns the items with the byte position calculated correctly and in sorted
|
||||||
|
@ -721,17 +721,21 @@ function M.locations_to_items(locations)
|
||||||
for _, d in ipairs(locations) do
|
for _, d in ipairs(locations) do
|
||||||
local start = d.range.start
|
local start = d.range.start
|
||||||
local fname = assert(vim.uri_to_fname(d.uri))
|
local fname = assert(vim.uri_to_fname(d.uri))
|
||||||
table.insert(grouped[fname], start)
|
table.insert(grouped[fname], {start = start, msg= d.message })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local keys = vim.tbl_keys(grouped)
|
local keys = vim.tbl_keys(grouped)
|
||||||
table.sort(keys)
|
table.sort(keys)
|
||||||
-- TODO(ashkan) I wish we could do this lazily.
|
-- TODO(ashkan) I wish we could do this lazily.
|
||||||
for _, fname in ipairs(keys) do
|
for _, fname in ipairs(keys) do
|
||||||
local rows = grouped[fname]
|
local rows = grouped[fname]
|
||||||
|
|
||||||
table.sort(rows, position_sort)
|
table.sort(rows, position_sort)
|
||||||
local i = 0
|
local i = 0
|
||||||
for line in io.lines(fname) do
|
for line in io.lines(fname) do
|
||||||
for _, pos in ipairs(rows) do
|
for _, temp in ipairs(rows) do
|
||||||
|
local pos = temp.start
|
||||||
local row = pos.line
|
local row = pos.line
|
||||||
if i == row then
|
if i == row then
|
||||||
local col
|
local col
|
||||||
|
@ -744,7 +748,7 @@ function M.locations_to_items(locations)
|
||||||
filename = fname,
|
filename = fname,
|
||||||
lnum = row + 1,
|
lnum = row + 1,
|
||||||
col = col + 1;
|
col = col + 1;
|
||||||
text = line;
|
text = temp.msg;
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue