Skip to content

Commit

Permalink
feat(diagnostics): added sort option (closes #851)
Browse files Browse the repository at this point in the history
Use `:FzfLua lsp_workspace_diagnostics sort=true` to sort
descending from highest priority first (error, warn, etc).

Use `:FzfLua lsp_workspace_diagnostics sort=2` to sort in
ascending order (hint, info, warn, etc).
  • Loading branch information
ibhagwan committed Aug 21, 2023
1 parent 78dd693 commit dd5b97a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lua/fzf-lua/providers/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ M.diagnostics = function(opts)
opts.diag_all and vim.lsp.diagnostic.get_all() or
{ [curbuf] = vim.lsp.diagnostic.get(curbuf, opts.client_id) }

if opts.sort then
if opts.sort == 2 or opts.sort == "2" then
-- ascending: hint, info, warn, error
table.sort(diag_results, function(a, b) return a.severity > b.severity end)
else
-- descending: error, warn, info, hint
table.sort(diag_results, function(a, b) return a.severity < b.severity end)
end
end

local has_diags = false
if vim.diagnostic then
-- format: { <diag array> }
Expand Down

0 comments on commit dd5b97a

Please sign in to comment.