feat(folding): open every heading fold by default on file open
Heading-block folds were computed but all collapsed on file open, so users had to `zR` after every `:edit`. Set `foldlevel=99` once at ftplugin attach so the fold structure is still there (closeable with `zc`/`zM`) but the buffer renders fully expanded. `foldlevel` is window-local; we set it on initial attach only — not in the Lua BufWinEnter re-apply — so closing folds with `zc` in a window survives navigating away and back to that buffer. Split windows still get the same value because Vim copies window-local options to the new window when splitting. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -221,7 +221,11 @@ if !has('nvim')
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=nuwiki#folding#expr()
|
||||
setlocal foldtext=nuwiki#folding#foldtext()
|
||||
let b:undo_ftplugin .= ' | setlocal foldmethod< foldexpr< foldtext<'
|
||||
" Start with every heading-block fold open; the user can still close
|
||||
" them with `zc` and that state survives because `foldlevel` only
|
||||
" controls the initial state, not subsequent manual fold operations.
|
||||
setlocal foldlevel=99
|
||||
let b:undo_ftplugin .= ' | setlocal foldmethod< foldexpr< foldtext< foldlevel<'
|
||||
endif
|
||||
|
||||
" Text objects — vimwiki parity (matches lua/nuwiki/textobjects.lua).
|
||||
|
||||
Reference in New Issue
Block a user