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.
This commit is contained in:
Riley Bruins
2025-01-28 12:22:25 -08:00
committed by GitHub
parent b88874d33c
commit 6711fa27ca

View File

@ -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()