Closed yujinyuz closed 2 months ago
It was a bug in my config..
My config contains
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
Removing that resolves this error.
Can you look if this fixes your issue? https://github.com/neovim/neovim/issues/23964#issuecomment-1584411926\
/edit:
Tried that, didn't work, even if it's supposed to work :see_no_evil:
Okay, you should change your config part to something like this:
local function enable_foldexpr()
vim.opt_local.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt_local.foldmethod = "expr"
end
vim.api.nvim_create_autocmd("FileType", {
callback = function(ev)
local has_treesitter = pcall(function()
vim.treesitter.get_parser(ev.buf)
end)
if has_treesitter then
enable_foldexpr()
end
end,
})
This makes sure, that only on buffers with a treesitter parser attached to it your config will get applied.
Then v3.0.1
should work for you :)
Thanks @gorillamoe works for me
EDIT:
I don't think that the method you provided is necessary since the foldmethod
and foldexpr
is local to the window. So if there are 2 buffers in the window 1 supports TS while the other one does not, it would still set the foldexpr
and foldmethod
.
But the v3.0.1 works just fine so everything is good
Still have some issue here. the fold level of the result buffer view didn't calculate correctly. so zc
zo
not work here.
update: opened a PR to fix that, tested on my machine.
I'm getting this error when running
toggle_view()
This happens when switching from Body to Header view
Here's my config if it helps