neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 6711fa27ca6e822bfd2394ec513671617cc53efd
parent b88874d33c15bb0fd7a421230f8bf819056d7665
Author: Riley Bruins <ribru17@hotmail.com>
Date:   Tue, 28 Jan 2025 12:22:25 -0800

fix(treesitter): recalculate folds on VimEnter #32240

**Problem:** In the case where the user sets the treesitter foldexpr upon startup in
their `init.lua`, the fold info will be calculated before the parser has
been loaded in, meaning folds will be properly calculated until edits or
`:e`.

**Solution:** Refresh fold information upon `VimEnter` as a sanity check
to ensure that a parser really doesn't exist before always returning
`'0'` in the foldexpr.
Diffstat:
Mruntime/lua/vim/treesitter/_fold.lua | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runtime/lua/vim/treesitter/_fold.lua b/runtime/lua/vim/treesitter/_fold.lua @@ -380,7 +380,7 @@ function M.foldexpr(lnum) if not foldinfos[bufnr] then foldinfos[bufnr] = FoldInfo.new(bufnr) - api.nvim_create_autocmd('BufUnload', { + api.nvim_create_autocmd({ 'BufUnload', 'VimEnter' }, { buffer = bufnr, once = true, callback = function()