aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
diff options
context:
space:
mode:
authorMaria Solano <majosolano99@gmail.com>2025-11-25 21:00:00 -0800
committerGitHub <noreply@github.com>2025-11-25 21:00:00 -0800
commit7e09fedf43fa191dcebbe131928aa8df3930888d (patch)
tree5b9fe06c5b9f34285044c283ce0756fd08bd59ec /runtime/lua/vim/diagnostic.lua
parent0a0c349b6fee01a8365e13e5a9dc194fcad4fd0a (diff)
downloadrneovim-7e09fedf43fa191dcebbe131928aa8df3930888d.tar.gz
rneovim-7e09fedf43fa191dcebbe131928aa8df3930888d.tar.bz2
rneovim-7e09fedf43fa191dcebbe131928aa8df3930888d.zip
feat(diagnostic): config.status #36693
Problem: `diagnostic.status()` is configured via `config.signs`, but users may want diagnostics only in statusline, not in the gutter (signs). Solution: Add `config.status`.
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index de51b3a84b..a0c37eea80 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -94,6 +94,9 @@ end
--- Options for floating windows. See |vim.diagnostic.Opts.Float|.
--- @field float? boolean|vim.diagnostic.Opts.Float|fun(namespace: integer, bufnr:integer): vim.diagnostic.Opts.Float
---
+--- Options for the statusline component.
+--- @field status? vim.diagnostic.Opts.Status
+---
--- Update diagnostics in Insert mode
--- (if `false`, diagnostics are updated on |InsertLeave|)
--- (default: `false`)
@@ -184,6 +187,11 @@ end
--- Overrides the setting from |vim.diagnostic.config()|.
--- @field suffix? string|table|(fun(diagnostic:vim.Diagnostic,i:integer,total:integer): string, string)
+--- @class vim.diagnostic.Opts.Status
+---
+--- A table mapping |diagnostic-severity| to the text to use for each severity section.
+--- @field text? table<vim.diagnostic.Severity,string>
+
--- @class vim.diagnostic.Opts.Underline
---
--- Only underline diagnostics matching the given
@@ -2887,10 +2895,10 @@ local hl_map = {
--- The severities with 0 diagnostics are left out.
--- Example `E:2 W:3 I:4 H:5`
---
---- To customise appearance, set diagnostic signs text with
+--- To customise appearance, set diagnostic text for each severity with
--- ```lua
--- vim.diagnostic.config({
---- signs = { text = { [vim.diagnostic.severity.ERROR] = 'e', ... } }
+--- status = { text = { [vim.diagnostic.severity.ERROR] = 'e', ... } }
--- })
--- ```
---@param bufnr? integer Buffer number to get diagnostics from.
@@ -2901,7 +2909,7 @@ function M.status(bufnr)
vim.validate('bufnr', bufnr, 'number', true)
bufnr = bufnr or 0
local counts = M.count(bufnr)
- local user_signs = vim.tbl_get(M.config() --[[@as vim.diagnostic.Opts]], 'signs', 'text') or {}
+ local user_signs = vim.tbl_get(M.config() --[[@as vim.diagnostic.Opts]], 'status', 'text') or {}
local signs = vim.tbl_extend('keep', user_signs, { 'E', 'W', 'I', 'H' })
local result_str = vim
.iter(pairs(counts))