feat(folding): open every heading fold by default on file open
CI / cargo fmt --check (push) Failing after 32s
CI / cargo clippy (push) Successful in 15s
CI / cargo test (push) Successful in 21s
CI / editor keymaps (push) Successful in 1m6s

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:
2026-05-26 23:02:17 -03:00
parent 0dfe0910fc
commit 59b48b4786
3 changed files with 15 additions and 1 deletions
+5 -1
View File
@@ -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).