Skip to content

perf: improve general treesitter performance and markdown particular performance#423

Merged
andymass merged 2 commits intoandymass:masterfrom
TheLeoP:perf
Dec 31, 2025
Merged

perf: improve general treesitter performance and markdown particular performance#423
andymass merged 2 commits intoandymass:masterfrom
TheLeoP:perf

Conversation

@TheLeoP
Copy link
Contributor

@TheLeoP TheLeoP commented Nov 12, 2025

Partially fixes #416

I've been having some performance issues just after opening markdown buffers since support for it was added. This PR improves the performance for treesitter (specially for the markdown buffer opened by vim.lsp.buf.hover).

I'm still having performance issues from time to time, but I haven't been able to track it down further. Something in the get_memoized_matches functions is (sometimes) taking a second and a half (on my particular hardware) on a new, empty, markdown buffer when typing ` as the first character in the buffer. But, for now, I've disabled vim-matchup in insert mode as a workaround instead (vim.g.matchup_matchparen_nomode = "i").

I'll open another PR in the future if I found the source of my other performance issue.

@TheLeoP TheLeoP changed the title perf(treesitter): query only the necessary trees instead of all of them perf: improve general treesitter performance and markdown particular performance Nov 13, 2025
@TheLeoP
Copy link
Contributor Author

TheLeoP commented Nov 13, 2025

I added a second commit removing one of the queries added to markdown_inline. On my testing, it caused the freezing mentioned in the minimal repro on #416

@TheLeoP
Copy link
Contributor Author

TheLeoP commented Nov 13, 2025

#416 (comment) explains why that particular Latex pattern was freezing Neovim

@andymass
Copy link
Owner

Thanks very much for this, and sorry for the delay

@andymass andymass merged commit 2afb7fc into andymass:master Dec 31, 2025
7 checks passed
lervag added a commit to lervag/dotnvim that referenced this pull request Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markdown matchup introduces performance regression at startup

2 participants