I've just fresh-installed LazyVim and I'm having troubles configuring code folding to my liking.
For the languages for which I have no nvim-treesitter parser installed I would like to use
:set foldmethod=syntax(presumably Neovim already knows how to parse these languages at a basic level).On the other hand, for the languages for which I have a nvim-treesitter parser installed and configured I would like to use
:set foldmethod=expr foldexpr=nvim_treesitter#foldexpr().
The reason for this is that in both circumstances if I use the opposite configuration then code folding will not work at all.
My idea is to default to :set foldmethod=syntax and have an autocommand switch it to expr when opening a buffer with nvim-treesitter support, however I have no idea how to achieve that (I don't know what event to listen to and how to detect whether a nvim-treesitter parser gets loaded for the current buffer). Maybe there is some other way to achieve this, by directly configuring nvim-treesitter to do the switching; I don't know.
Does anybody have a solution?