From 938ed458e2818b7840e9c4eaf298c5a7af8d79ea Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Fri, 17 Sep 2021 14:59:30 -0600 Subject: fix(diagnostic): change default severity_sort order When severity_sort is true, higher severities should be displayed before lower severities (e.g. ERROR is displayed over WARN). Also improved the test case for this. --- runtime/lua/vim/diagnostic.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime/lua') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 6547188594..18a2023b50 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -452,7 +452,9 @@ end --- - update_in_insert: (default false) Update diagnostics in Insert mode (if false, --- diagnostics are updated on InsertLeave) --- - severity_sort: (default false) Sort diagnostics by severity. This affects the order in ---- which signs and virtual text are displayed. Options: +--- which signs and virtual text are displayed. When true, higher severities +--- are displayed before lower severities (e.g. ERROR is displayed before WARN). +--- Options: --- * reverse: (boolean) Reverse sort order ---@param namespace number|nil Update the options for the given namespace. When omitted, update the --- global diagnostic options. @@ -998,9 +1000,9 @@ function M.show(namespace, bufnr, diagnostics, opts) if vim.F.if_nil(opts.severity_sort, false) then if type(opts.severity_sort) == "table" and opts.severity_sort.reverse then - table.sort(diagnostics, function(a, b) return a.severity > b.severity end) - else table.sort(diagnostics, function(a, b) return a.severity < b.severity end) + else + table.sort(diagnostics, function(a, b) return a.severity > b.severity end) end end -- cgit