From 7e09fedf43fa191dcebbe131928aa8df3930888d Mon Sep 17 00:00:00 2001 From: Maria Solano Date: Tue, 25 Nov 2025 21:00:00 -0800 Subject: 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`. --- runtime/lua/vim/diagnostic.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'runtime/lua/vim') 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 + --- @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)) -- cgit