commit b6b80824cc71fb9f32ddf2e9a96205633342827e
parent 2c76a50e20ded88b1767562455d2999fd2faa0de
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sat, 4 Oct 2025 07:53:29 +0800
vim-patch:9.1.1819: Cannot configure the inner foldlevel indicator (#36010)
Problem: Cannot configure the inner foldlevel indicator for the
foldcolumn
Solution: Add "foldinner" suboption value to the 'fillchar' option
(Maria José Solano).
closes: vim/vim#18365
https://github.com/vim/vim/commit/1a691afd2717732c6f42dfe3278a9540db0d8110
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Diffstat:
9 files changed, 65 insertions(+), 24 deletions(-)
diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt
@@ -585,7 +585,8 @@ A closed fold is indicated with a '+'.
These characters can be changed with the 'fillchars' option.
Where the fold column is too narrow to display all nested folds, digits are
-shown to indicate the nesting level.
+shown to indicate the nesting level. To override this behavior you can use
+the "foldinner" character of the 'fillchars' option.
The mouse can also be used to open and close folds by clicking in the
fold column:
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
@@ -285,6 +285,7 @@ OPTIONS
• 'completeopt' flag "nearest" sorts completion results by distance to cursor.
• 'diffanchors' specifies addresses to anchor a diff.
• 'diffopt' `inline:` configures diff highlighting for changes within a line.
+• 'fillchars' has new flag "foldinner".
• 'grepformat' is now a |global-local| option.
• 'maxsearchcount' sets maximum value for |searchcount()| and defaults to 999.
• 'pummaxwidth' sets maximum width for the completion popup menu.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
@@ -2860,7 +2860,10 @@ A jump table for the options with a short description can be found at |Q_op|.
fold '·' or '-' filling 'foldtext'
foldopen '-' mark the beginning of a fold
foldclose '+' show a closed fold
- foldsep '│' or '|' open fold middle marker
+ foldsep '│' or '|' open fold middle marker
+ foldinner none character to show instead of the
+ numeric foldlevel when it would be
+ repeated in a narrow 'foldcolumn'
diff '-' deleted lines of the 'diff' option
msgsep ' ' message separator 'display'
eob '~' empty lines at the end of a buffer
diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua
@@ -2578,7 +2578,10 @@ vim.bo.ft = vim.bo.filetype
--- fold '·' or '-' filling 'foldtext'
--- foldopen '-' mark the beginning of a fold
--- foldclose '+' show a closed fold
---- foldsep '│' or '|' open fold middle marker
+--- foldsep '│' or '|' open fold middle marker
+--- foldinner none character to show instead of the
+--- numeric foldlevel when it would be
+--- repeated in a narrow 'foldcolumn'
--- diff '-' deleted lines of the 'diff' option
--- msgsep ' ' message separator 'display'
--- eob '~' empty lines at the end of a buffer
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
@@ -1077,6 +1077,7 @@ typedef struct {
schar_T foldopen; ///< when fold is open
schar_T foldclosed; ///< when fold is closed
schar_T foldsep; ///< continuous fold marker
+ schar_T foldinner;
schar_T diff;
schar_T msgsep;
schar_T eob;
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
@@ -517,6 +517,8 @@ void fill_foldcolumn(win_T *wp, foldinfo_T foldinfo, linenr_T lnum, int attr, in
symbol = wp->w_p_fcs_chars.foldopen;
} else if (first_level == 1) {
symbol = wp->w_p_fcs_chars.foldsep;
+ } else if (wp->w_p_fcs_chars.foldinner != NUL) {
+ symbol = wp->w_p_fcs_chars.foldinner;
} else if (first_level + i <= 9) {
symbol = schar_from_ascii('0' + first_level + i);
} else {
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
@@ -3261,7 +3261,10 @@ local options = {
fold '·' or '-' filling 'foldtext'
foldopen '-' mark the beginning of a fold
foldclose '+' show a closed fold
- foldsep '│' or '|' open fold middle marker
+ foldsep '│' or '|' open fold middle marker
+ foldinner none character to show instead of the
+ numeric foldlevel when it would be
+ repeated in a narrow 'foldcolumn'
diff '-' deleted lines of the 'diff' option
msgsep ' ' message separator 'display'
eob '~' empty lines at the end of a buffer
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
@@ -2246,26 +2246,27 @@ struct chars_tab {
static fcs_chars_T fcs_chars;
static const struct chars_tab fcs_tab[] = {
- CHARSTAB_ENTRY(&fcs_chars.stl, "stl", " ", NULL),
- CHARSTAB_ENTRY(&fcs_chars.stlnc, "stlnc", " ", NULL),
- CHARSTAB_ENTRY(&fcs_chars.wbr, "wbr", " ", NULL),
- CHARSTAB_ENTRY(&fcs_chars.horiz, "horiz", "─", "-"),
- CHARSTAB_ENTRY(&fcs_chars.horizup, "horizup", "┴", "-"),
- CHARSTAB_ENTRY(&fcs_chars.horizdown, "horizdown", "┬", "-"),
- CHARSTAB_ENTRY(&fcs_chars.vert, "vert", "│", "|"),
- CHARSTAB_ENTRY(&fcs_chars.vertleft, "vertleft", "┤", "|"),
- CHARSTAB_ENTRY(&fcs_chars.vertright, "vertright", "├", "|"),
- CHARSTAB_ENTRY(&fcs_chars.verthoriz, "verthoriz", "┼", "+"),
- CHARSTAB_ENTRY(&fcs_chars.fold, "fold", "·", "-"),
- CHARSTAB_ENTRY(&fcs_chars.foldopen, "foldopen", "-", NULL),
- CHARSTAB_ENTRY(&fcs_chars.foldclosed, "foldclose", "+", NULL),
- CHARSTAB_ENTRY(&fcs_chars.foldsep, "foldsep", "│", "|"),
- CHARSTAB_ENTRY(&fcs_chars.diff, "diff", "-", NULL),
- CHARSTAB_ENTRY(&fcs_chars.msgsep, "msgsep", " ", NULL),
- CHARSTAB_ENTRY(&fcs_chars.eob, "eob", "~", NULL),
- CHARSTAB_ENTRY(&fcs_chars.lastline, "lastline", "@", NULL),
- CHARSTAB_ENTRY(&fcs_chars.trunc, "trunc", ">", NULL),
- CHARSTAB_ENTRY(&fcs_chars.truncrl, "truncrl", "<", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.stl, "stl", " ", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.stlnc, "stlnc", " ", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.wbr, "wbr", " ", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.horiz, "horiz", "─", "-"),
+ CHARSTAB_ENTRY(&fcs_chars.horizup, "horizup", "┴", "-"),
+ CHARSTAB_ENTRY(&fcs_chars.horizdown, "horizdown", "┬", "-"),
+ CHARSTAB_ENTRY(&fcs_chars.vert, "vert", "│", "|"),
+ CHARSTAB_ENTRY(&fcs_chars.vertleft, "vertleft", "┤", "|"),
+ CHARSTAB_ENTRY(&fcs_chars.vertright, "vertright", "├", "|"),
+ CHARSTAB_ENTRY(&fcs_chars.verthoriz, "verthoriz", "┼", "+"),
+ CHARSTAB_ENTRY(&fcs_chars.fold, "fold", "·", "-"),
+ CHARSTAB_ENTRY(&fcs_chars.foldopen, "foldopen", "-", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.foldclosed, "foldclose", "+", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.foldsep, "foldsep", "│", "|"),
+ CHARSTAB_ENTRY(&fcs_chars.foldinner, "foldinner", NULL, NULL),
+ CHARSTAB_ENTRY(&fcs_chars.diff, "diff", "-", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.msgsep, "msgsep", " ", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.eob, "eob", "~", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.lastline, "lastline", "@", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.trunc, "trunc", ">", NULL),
+ CHARSTAB_ENTRY(&fcs_chars.truncrl, "truncrl", "<", NULL),
};
static lcs_chars_T lcs_chars;
diff --git a/test/old/testdir/test_display.vim b/test/old/testdir/test_display.vim
@@ -343,6 +343,32 @@ func Test_fold_fillchars()
\ ]
call assert_equal(expected, lines)
+ " check setting foldinner
+ set fdc=1 foldmethod=indent foldlevel=10
+ call setline(1, ['one', ' two', ' two', ' three', ' three', 'four'])
+ let lines = ScreenLines([1, 6], 22)
+ let expected = [
+ \ ' one ',
+ \ '[ two ',
+ \ '- two ',
+ \ '[ three',
+ \ '2 three',
+ \ ' four ',
+ \ ]
+ call assert_equal(expected, lines)
+
+ set fillchars+=foldinner:\
+ let lines = ScreenLines([1, 6], 22)
+ let expected = [
+ \ ' one ',
+ \ '[ two ',
+ \ '- two ',
+ \ '[ three',
+ \ ' three',
+ \ ' four ',
+ \ ]
+ call assert_equal(expected, lines)
+
%bw!
set fillchars& fdc& foldmethod& foldenable&
endfunc