|
|
@ -464,24 +464,38 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
function M.get_line_diagnostic()
|
|
|
|
function M.get_line_diagnostic()
|
|
|
|
local lnum = api.nvim_win_get_cursor(0)[1] - 1
|
|
|
|
local lnum = api.nvim_win_get_cursor(0)[1] - 1
|
|
|
|
return diagnostic.get(api.nvim_get_current_buf(), { lnum = lnum })
|
|
|
|
local diags = diagnostic.get(api.nvim_get_current_buf(), { lnum = lnum })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table.sort(diags, function(diag1, diag2)
|
|
|
|
|
|
|
|
return diag1.severity < diag2.severity
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
return diags
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M.show_diagnostics(pos)
|
|
|
|
function M.show_diagnostics(pos)
|
|
|
|
local bufnr = api.nvim_get_current_buf()
|
|
|
|
local bufnr = api.nvim_get_current_buf()
|
|
|
|
local lnum = api.nvim_win_get_cursor(0)[1] - 1
|
|
|
|
|
|
|
|
local opt = { border = 'single' }
|
|
|
|
local lnum, col = unpack(api.nvim_win_get_cursor(0))
|
|
|
|
if diagnostic.open_float and type(diagnostic.open_float) == 'function' then
|
|
|
|
lnum = lnum - 1
|
|
|
|
|
|
|
|
local opt = { border = 'single', severity_sort = true }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if pos ~= nil and type(pos) == 'number' then
|
|
|
|
|
|
|
|
opt.scope = 'buffer'
|
|
|
|
|
|
|
|
else
|
|
|
|
if pos == true then
|
|
|
|
if pos == true then
|
|
|
|
opt.scope = 'cursor'
|
|
|
|
opt.scope = 'cursor'
|
|
|
|
else
|
|
|
|
else
|
|
|
|
opt.scope = 'line'
|
|
|
|
opt.scope = 'line'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
diagnostic.open_float(bufnr, opt)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
-- deprecated
|
|
|
|
|
|
|
|
diagnostic.show_line_diagnostics(opt, bufnr, lnum)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local diags = M.get_line_diagnostic()
|
|
|
|
|
|
|
|
if diags == nil or next(diags) == nil then
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local diag1 = diags[1]
|
|
|
|
|
|
|
|
opt.offset_x = -1 * (col - diag1.col)
|
|
|
|
|
|
|
|
diagnostic.open_float(bufnr, opt)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M.treesitter_and_diag_panel()
|
|
|
|
function M.treesitter_and_diag_panel()
|
|
|
|