diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/diagnostic.txt | 4 | ||||
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 9ed75e1356..199c04be98 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -239,7 +239,9 @@ config({opts}, {namespace}) *vim.diagnostic.config()* • severity_sort: (default false) Sort diagnostics by severity. This affects the order in which signs and virtual text are - displayed. Options: + displayed. When true, higher severities are + displayed before lower severities (e.g. + ERROR is displayed before WARN). Options: • reverse: (boolean) Reverse sort order {namespace} number|nil Update the options for the given namespace. When omitted, update the global 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 |