tree-sitter / tree-sitter-javascript

Javascript grammar for tree-sitter
MIT License
314 stars 108 forks source link

Extremely bad performance on longer javascript files #274

Closed ahelwer closed 6 months ago

ahelwer commented 6 months ago

Ref https://github.com/nvim-treesitter/nvim-treesitter/issues/1313

If I open my tree-sitter-tlaplus grammar file in neovim, which uses this grammar, performance is extremely bad. It takes several seconds to input a single character. Here is the file https://github.com/tlaplus-community/tree-sitter-tlaplus/blob/main/grammar.js

Opening an issue here because I believe the issue is with the grammar itself and not neovim.

maxbrunsfeld commented 6 months ago

I'd love to look into this, but there's not quite enough information to go on. Can you provide an example that reproduces the problem from the Tree-sitter CLI, or using Tree-sitter in any way that's not tied to Neovim?

amaanq commented 6 months ago

I don't think it's a slow parsing issue or a tree-sitter issue - the file takes 5ms for an initial parse, and I believe it's a combination of using an older neovim version (nightly has great perf improvements) and some slow plugins that leverage nvim-treesitter, because I don't experience any lag in tlaplus's grammar.js