Xinqi Bao's Git

style(nvim): render compact indented fold summaries
[dotfiles.git] / .config / nvim / init.vim
index e002a88..32c39ac 100644 (file)
@@ -33,10 +33,14 @@ set noshowmode
 set wildmenu
 set colorcolumn=120
 highlight ColorColumn ctermbg=0 guibg=lightgrey
 set wildmenu
 set colorcolumn=120
 highlight ColorColumn ctermbg=0 guibg=lightgrey
-" Fallback for filetypes without a Tree-sitter parser.
-set foldmethod=indent
+" Create folds only after a Tree-sitter parser is started.
+set foldmethod=expr
+set foldexpr=0
 set foldlevelstart=99
 set foldlevel=99
 set foldlevelstart=99
 set foldlevel=99
+" Indent summaries one level past the retained first line, not a continuation.
+let &foldtext = 'repeat(" ", indent(v:foldstart - 1) + shiftwidth()) . printf("… %d lines …", v:foldend - v:foldstart + 1)'
+set fillchars+=fold:\  " Leave the rest of the summary line blank.
 
 " Interaction and persistence
 set mouse=a
 
 " Interaction and persistence
 set mouse=a