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:
@@ -35,6 +35,10 @@ local function setup_folding(bufnr, folding_mode)
|
||||
-- ftplugin). Also re-apply on any future split that views this
|
||||
-- buffer, so `<C-w>v` / `:split` preserves the fold method.
|
||||
apply()
|
||||
-- Start with every heading-block fold open. `foldlevel` is window-local
|
||||
-- but only sets the initial state; once the user closes folds with `zc`
|
||||
-- those stay closed, so we don't re-apply this on BufWinEnter.
|
||||
vim.opt_local.foldlevel = 99
|
||||
vim.api.nvim_create_autocmd('BufWinEnter', {
|
||||
buffer = bufnr,
|
||||
group = vim.api.nvim_create_augroup('nuwiki_folding_' .. bufnr, { clear = true }),
|
||||
|
||||
Reference in New Issue
Block a user