HiPhish / rainbow-delimiters.nvim

Rainbow delimiters for Neovim with Tree-sitter
https://gitlab.com/HiPhish/rainbow-delimiters.nvim
Apache License 2.0
470 stars 35 forks source link

[Question]: highlights do not keep when fold text #71

Closed gh-liu closed 5 months ago

gh-liu commented 7 months ago

when use vim.treesitter.foldtext() to show the fold text, the highlights of rainbow-delimiters.nvim do not show, is there a way to fix this?

vim.o.foldmethod = "expr"
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.o.foldtext = "v:lua.vim.treesitter.foldtext()"[
Snipaste_2023-11-30_16-36-07
HiPhish commented 7 months ago

I don't know if this is possible. This requires some way of preserving extmarks in the replacement text and letting them "shine through" to the surface. I will need to look into how the highlighting is preserved in Treesitter. Maybe it can be done, maybe not.

Danielkonge commented 7 months ago

I don't know if this is possible. This requires some way of preserving extmarks in the replacement text and letting them "shine through" to the surface. I will need to look into how the highlighting is preserved in Treesitter. Maybe it can be done, maybe not.

I think this is an upstream issue, where the folding functions will need to be able to preserve extmarks. This doesn't only affect rainbow-delimiters. (That was the reason I made an upstream issue in neovim/neovim#26350 )

Danielkonge commented 5 months ago

This seems to be worked on upstream. You can check the progress here: https://github.com/neovim/neovim/pull/20750

When that is merged, you will get the folding you are asking for (from what I understand).

gh-liu commented 5 months ago

This seems to be worked on upstream. You can check the progress here: neovim/neovim#20750

When that is merged, you will get the folding you are asking for (from what I understand).

Thanks