GNU bug report logs -
#61849
29.0.60; Unable to use treesit-install-language-grammar because repo doesn't have parser.c
Previous Next
Full log
Message #53 received at 61849 <at> debbugs.gnu.org (full text, mbox):
Just to add another example. It seems that LaTeX grammar [1] maintainers made
a decision to remove parser.c in
https://github.com/latex-lsp/tree-sitter-latex/pull/114.
And for posterity, here's a workaround I added to my configuration (sightly
more complicated than it could be for Emacs 30, but it has been written with
Emacs 29 in mind (the latter I still use)):
(defun pk/treesit-generate-parser (&rest args)
"Try to run \\='tree-sitter generate\\=' if there's no parser.c."
(when-let* (((equal "parser.c" (car (last args))))
((not (file-exists-p (expand-file-name "parser.c"))))
(tree-sitter (executable-find "tree-sitter"))
(default-directory (file-name-parent-directory default-directory)))
(message "Generating parser.c")
(treesit--call-process-signal
tree-sitter nil t nil "generate")))
(advice-add 'treesit--call-process-signal
:before #'pk/treesit-generate-parser)
Perhaps similar concept could be added to the treesit-install-language-grammar:
when user provides tree-sitter executable in LANG recipe and parser.c is not
found then generate it? Alternatively, always generate parser.c if the
tree-sitter executable is passed in the LANG recipe. Or make it the decision
whether to generate the parser yet another parameter in the LANG recipe.
Cheers,
PK
[1] https://github.com/latex-lsp/tree-sitter-latex
This bug report was last modified 83 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.