Skip to content

Commit

Permalink
feat(diagnostic): don't open quickfix/loclist if no diagnostics neovi…
Browse files Browse the repository at this point in the history
  • Loading branch information
leaxoy committed Dec 30, 2022
1 parent 849f544 commit 4ace9e7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion runtime/lua/vim/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,17 @@ local function set_list(loclist, opts)
-- numbers beyond the end of the buffer
local diagnostics = get_diagnostics(bufnr, opts, false)
local items = M.toqflist(diagnostics)
if next(items) == nil then
vim.notify('No diagnostics available')
return
end
if loclist then
vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items })
else
vim.fn.setqflist({}, ' ', { title = title, items = items })
end
if open then
api.nvim_command(loclist and 'lopen' or 'botright copen')
api.nvim_command(loclist and 'lwindow' or 'botright cwindow')
end
end

Expand Down

0 comments on commit 4ace9e7

Please sign in to comment.