latex-lsp / tree-sitter-latex

LaTeX grammar for tree-sitter
MIT License
87 stars 21 forks source link

Initial load of grammar is extremely slow #97

Open lgrosz opened 10 months ago

lgrosz commented 10 months ago

For the following file...

\documentclass{article}

\begin{document}

Hello world

\end{document}

When ensure_installed = { ..., 'latex' }, loading of this file takes multiple seconds. This only occurs once per instance of neovim. This is in stark contrast to any other treesitter grammar plugin I use.

clason commented 10 months ago

LaTeX is just a very complicated language to parse, with a lot of hard-coded commands that need to be supported. That just makes for a large (and expensive to load) grammar.

(You're lucky with your other grammars then; LaTeX is by far not the worst offender -- take a look at verilog...)

That being said, I'm sure there's things that can be done to improve size and load speed (see, e.g., https://github.com/tree-sitter/tree-sitter/wiki/Tips-and-Tricks-for-a-grammar-author); help is surely welcome.

lgrosz commented 10 months ago

I will definitely take a look and see if I can contribute! I just noticed it was slow compared to other languages I have treesitter active for (I haven't use verilog for years!) and wanted to put an issue out.