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

Compute indentexpr for the whole buffer and cache it #6486

Open
xzbdmw opened this issue Apr 21, 2024 · 1 comment
Open

Compute indentexpr for the whole buffer and cache it #6486

xzbdmw opened this issue Apr 21, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request indent Issues or PRs about indentation queries or module

Comments

@xzbdmw
Copy link

xzbdmw commented Apr 21, 2024

Is your feature request related to a problem? Please describe.
In a lua file, ts's indent method takes 0.02s which is a noticeable delay when I type o. After trying zed, which also use treessitter to indent, I found their speed is super fast(new line).
With some curiosity to scan their code, I found zed computes an indent map that is (line->indent) for the whole buffer and that's where the speed comes from. I think nvim-treessitter can adapt that pattern too.

relevant code

@xzbdmw xzbdmw added the enhancement New feature or request label Apr 21, 2024
@lucario387 lucario387 self-assigned this Apr 21, 2024
@clason clason added the indent Issues or PRs about indentation queries or module label Apr 21, 2024
@xzbdmw
Copy link
Author

xzbdmw commented Apr 21, 2024

For simplicity I want to cache get_indent() call's result at CursorMove and apply result when I type o so eliminating latency, but it turns out that when I type o, neovim adds a new line below and change cursor position at first(not showed in ui) and then calls indentexpr, for that reason, calling get_indent() mannally don't works, do you have any suggestions to get real indent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request indent Issues or PRs about indentation queries or module
Projects
None yet
Development

No branches or pull requests

3 participants