Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): treesitter foldexpr calculate not work #249

Merged
merged 1 commit into from
Sep 29, 2024

Conversation

wenjinnn
Copy link
Contributor

When setup

vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()'

the fold level per lines not getting correct result, this means that zc zo will not work in result buffer. this commit fix it.
Related #128

When setup
``` lua
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
```
the fold level per lines not getting correct result, this means that
`zc` `zo` will not work in result buffer. this commit fix it.
Related mistweaverco#128
@gorillamoe gorillamoe self-assigned this Sep 29, 2024
@gorillamoe gorillamoe added the bug Something isn't working label Sep 29, 2024
@gorillamoe
Copy link
Member

Do we really need that replacement of buffer with this fix anymore? 😲 Would be awesome if this could be removed as well then 👌🏾👍🏾💪🏾

@gorillamoe
Copy link
Member

Seems like we still need that replace buffer 🤷

@gorillamoe gorillamoe merged commit bfbb7b2 into mistweaverco:main Sep 29, 2024
2 checks passed
@wenjinnn
Copy link
Contributor Author

Well, I don't understand why we don't need this. Many http request return a lot of content. Using treesitter foldexpr to calculate folding can conveniently fold the content according to the syntax tree. It's useful for response content of json or xml type.
image

Imagine that your request returns thousands of lines of HTML like this, including hundreds of lines of head tag. You want to quickly view the content in the body tag. In this case, the best way is to move the cursor to the head tag and then fold the content by type `zc'. Without this fix, it will not work :).

@gorillamoe
Copy link
Member

It's already merged into main. I never said we don't need this. I was just thinking if we still need to replace the buffer everytime :)

@wenjinnn
Copy link
Contributor Author

wenjinnn commented Sep 29, 2024

Just saw it merged when I posting the previous comment. Yes I think we need it :). Thanks for the explain.

gorillamoe pushed a commit to rcasia/kulala.nvim that referenced this pull request Oct 7, 2024
When setup
``` lua
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
```
the fold level per lines not getting correct result, this means that
`zc` `zo` will not work in result buffer. this commit fix it.
Related mistweaverco#128
iamxiaojianzheng pushed a commit to iamxiaojianzheng/kulala.nvim that referenced this pull request Oct 24, 2024
When setup
``` lua
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
```
the fold level per lines not getting correct result, this means that
`zc` `zo` will not work in result buffer. this commit fix it.
Related mistweaverco#128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants