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

Setting foldmethod and foldexpr to treesitter affect terminal buffer #28688

Open
asmodeus812 opened this issue May 10, 2024 · 1 comment
Open
Labels
enhancement feature request terminal built-in :terminal or :shell

Comments

@asmodeus812
Copy link

asmodeus812 commented May 10, 2024

Problem

Terminal buffers receiving streaming data foldexpr set to treesitter lock up the main thread, rendering nvim virtually inoperable.

Minimal repro

pcall(vim.treesitter.start)
vim.cmd.split()
vim.cmd.term()
vim.wo.foldmethod = "expr" -- use treesitter folds
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.bo.filetype = "baseterm"

Then run the following in the terminal

while true; do echo test; done

Now if you exit terminal mode and try to navigate to the first split with the [No name] buffer and start typing, go in normal mode and try to move the cursor back/forward ([b] and [w]). There is a significant lag in every motion.

Expected behavior

Terminal data streaming should not lock up nvim.

@asmodeus812 asmodeus812 added the enhancement feature request label May 10, 2024
@clason clason added the terminal built-in :terminal or :shell label May 10, 2024
@asmodeus812
Copy link
Author

asmodeus812 commented May 10, 2024

Small correction, seems like foldmethod is affecting this greatly, discovered that the global config that i had enabled - vim.o.foldmethod="expr" along with vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()" , was getting applied to the terminal buffer, and that is what seems to be destroying the perofrmance, even though the treesitter is not active in that buffer.

@asmodeus812 asmodeus812 changed the title Speeding up terminal buffer rendering during streaming with bigger scrollback values Setting foldmethod and foldexpr to treesitter affect terminal buffer May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request terminal built-in :terminal or :shell
Projects
None yet
Development

No branches or pull requests

2 participants