feat(statusline): vim.diagnostic.status() #33723

Problem:
Not easy to get a status string for diagnostics.

Solution:
- Add vim.diagnostic.status().
- Add it to the default 'statusline'.
This commit is contained in:
Anton Kastritskii
2025-07-30 02:53:57 +01:00
committed by GitHub
parent 807a65b2da
commit b79ff967ac
9 changed files with 145 additions and 12 deletions

View File

@@ -8706,15 +8706,19 @@ local options = {
{
abbreviation = 'stl',
cb = 'did_set_statusline',
defaults = table.concat({
'%<',
'%f %h%w%m%r ',
'%=',
"%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}",
"%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}",
"%{% &busy > 0 ? '◐ ' : '' %}",
"%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}",
}),
defaults = {
if_true = table.concat({
'%<',
'%f %h%w%m%r ',
'%=',
"%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}",
"%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}",
"%{% &busy > 0 ? '◐ ' : '' %}",
"%(%{luaeval('(pcall(require, ''vim.diagnostic'') and vim.diagnostic.status()) or '''' ')} %)",
"%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}",
}),
doc = 'is very long',
},
desc = [=[
Sets the |status-line|.