✨ Feature: Fold bullet lists
Closed this issue · 5 comments
The nature of the feature:
- Parser(syntax, conceal etc. related)
- Renderer(style, options etc. related)
- Support(plugin support, language support etc. related)
- Other
Description:
Since markview.nvim is becoming the default markdown plugin for neovim , i gonna suggest here (dont know if im doing wrong) a way to properly fold bullet lists in neovim .
Treesitter have a known bug to not work properly with bullet lists folding. And fold bullets is a thing that i miss a lot from standard markdown editors
Create a file named folds.scm
in ~/.config/nvim/queries/markdown/
.
Add this to the file.
((list) @fold)
Use this in your config.
vim.o.foldmethod = "expr";
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()";
-- Optional, This gets rid of the fold text and shows the actual line.
vim.o.foldtext = "";
Tip
Put the options in ~/.config/nvim/after/ftplugin/markdown.lua
to only use them in markdown files.
Also, you don't even need to do this.
Just this should be enough,
vim.o.foldmethod = "expr";
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()";
-- Optional, This gets rid of the fold text and shows the actual line.
vim.o.foldtext = "";
could you nest sublists, like in your last image, could you nest "1. Nest 4" into "Nest 3" without folding all the list ?
You mean something like this?
exactly this , mine is folding wrong
it dont do like yours (the correct way)
i have this im my init.lua :
vim.o.foldmethod = "expr";
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()";
vim.opt_local.foldtext = "getline(v:foldstart)"
vim.opt_local.foldlevel = 99
where do i add this ?
((list) @fold
(#offset! 0 0 -1 0))