feat(options): per-buffer 'busy' status #34493

Problem:
Plugins cannot mark a buffer as "busy".

Solution:
- Add a buffer-local 'busy' option.
- Show a busy indicator in the default 'statusline'.
This commit is contained in:
Shadman
2025-07-07 05:17:06 +06:00
committed by GitHub
parent 6fd2a3040f
commit 5973328eda
10 changed files with 77 additions and 6 deletions

View File

@ -12,6 +12,7 @@
#include "nvim/option_defs.h"
#include "nvim/os/fs_defs.h"
#include "nvim/statusline_defs.h"
#include "nvim/types_defs.h"
#include "nvim/undo_defs.h"
/// Reference to a buffer that stores the value of buf_free_count.
@ -522,6 +523,7 @@ struct file_buffer {
int b_p_bomb; ///< 'bomb'
char *b_p_bh; ///< 'bufhidden'
char *b_p_bt; ///< 'buftype'
OptInt b_p_busy; ///< 'busy'
int b_has_qf_entry; ///< quickfix exists for buffer
int b_p_bl; ///< 'buflisted'
OptInt b_p_channel; ///< 'channel'

View File

@ -4681,6 +4681,8 @@ void *get_varp_from(vimoption_T *p, buf_T *buf, win_T *win)
return &(buf->b_p_bt);
case kOptBuflisted:
return &(buf->b_p_bl);
case kOptBusy:
return &(buf->b_p_busy);
case kOptChannel:
return &(buf->b_p_channel);
case kOptCopyindent:

View File

@ -280,6 +280,7 @@ EXTERN char *p_bsk; ///< 'backupskip'
EXTERN char *p_breakat; ///< 'breakat'
EXTERN char *p_bh; ///< 'bufhidden'
EXTERN char *p_bt; ///< 'buftype'
EXTERN OptInt p_busy; ///< 'busy'
EXTERN char *p_cmp; ///< 'casemap'
EXTERN unsigned cmp_flags;
EXTERN char *p_enc; ///< 'encoding'

View File

@ -950,6 +950,21 @@ local options = {
type = 'string',
varname = 'p_bt',
},
{
defaults = 0,
desc = [=[
Sets a buffer "busy" status. Indicated in the default statusline.
When busy status is larger then 0 busy flag is shown in statusline.
The semantics of "busy" are arbitrary, typically decided by the plugin that owns the buffer.
]=],
full_name = 'busy',
redraw = { 'statuslines' },
noglob = true,
scope = { 'buf' },
short_desc = N_('buffer is busy'),
type = 'number',
varname = 'p_busy',
},
{
abbreviation = 'cmp',
defaults = 'internal,keepascii',
@ -8640,6 +8655,7 @@ local options = {
'%=',
"%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}",
"%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}",
"%{% &busy > 0 ? '◐ ' : '' %}",
"%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}",
}),
desc = [=[