I have read the documentation on foldexpr
, and I have read through Possible to set `foldexpr` using a function reference?.
I have tried this:
vim.o.foldexpr = function()
return "1"
end
which clearly does not work, giving the following error:
Error detected while processing ftplugin/markdown.lua:
E5113: Error while calling lua chunk: ftplugin/markdown.lua:13: Invalid 'foldexpr': expected Integer/Boolean/String, got Function
stack traceback:
[C]: in function '__newindex'
ftplugin/markdown.lua:13: in main chunk
I see this: https://www.jmaguire.tech/posts/treesitter_folding/ which tells me to do
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
using the opt
dict instead of the o
one, and setting it to the function via a string - however, this will only work when the function is defined in vimscript not in lua. Do I need to have a shim and define my function in vim (even if the vim function is just one :lua
command defining a function??) or can I use a pure lua reference.