Closed gbonett closed 9 months ago
Sorry, it does not. I will fix the documentation.
The challenge to implementing folding for Rmarkdown or Quarto is that #
is the comment string in R.
I've found that this works on Neovim:
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
set nofoldenable
If using init.lua
:
vim.o.foldmethod = "expr"
vim.o.foldexpr = "nvim_treesitter#foldexpr()"
vim.o.foldenable = false
@jalvesaq: Nice! Is there any way Nvim-R could set those automagically (for Rmd files)?
I tested it with both Quarto and Rmd file types, and it worked with no need for additional configuration. You should not set the option nofoldenable
if you prefer all folds closed on startup. You should use auto commands if you want specific configurations for different file types.
Thank you!
I set those options and now it is folding, but the folds seem to be totally random. It's not neatly folding code blocks or markdown sections - just apparently random chunks. This is probably user error on my part.
Did you do the following commands?
:TSInstall r
:TSInstall markdown
Perhaps I have done something in the past that has made it work, but I don't know what it was. Maybe the above commands will help.
I just need folding of the chunks:
vim.cmd([[
autocmd FileType rmd set foldmarker=```{,```
autocmd FileType rmd setlocal foldmethod=marker
]])
Nvim-R is being superseded by R.nvim, a new project that will be inaugurated in a week at the R-nvim organization. Please, check out tmp-Nvim-R and help us to find the last remaining bugs before R.nvim inauguration. When the project is officially started, you will be able to open issues there and request new features.
Nvim-R will remain alive as a feature-frozen project for Vim users. If you want to know the reason, please, see this discussion.
Anyway, folding is not a feature under the responsibility of Nvim-R or the future R.nvim...
Hi,
Thank you for providing this great tool.
Does this plug-in support folding by section header of rmarkdown documents? The documentation says that one of the main features is that it can "Fold code when foldmethod=syntax", but after setting foldmethod=syntax I am not able to see any folding when pressing "zc" (on either section headers or R code). I get the error: "E490: No fold found"
Thanks in advance for any help.