renzmann / treesit-auto

Automatic installation, usage, and fallback for tree-sitter major modes in Emacs 29
GNU General Public License v3.0
353 stars 27 forks source link

Can the version of the grammar be fixed according to the version of emacs? #99

Open yuzhou721 opened 2 months ago

yuzhou721 commented 2 months ago

Can the version of the grammar be fixed according to the version of emacs? Because each installation is the latest version, but emacs treesit does not support that version, causing an error:

(treesit-query-error "Node type error at" 150 "(function_declaration name: (identifier) @font-lock-function-name-face)

Or is it possible to set the version simply?

renzmann commented 2 months ago

I imagine this might vary for each grammar. Would the :revision keyword for a recipe, assuming that your grammar's repo has version number tags, do the trick?

yuzhou721 commented 2 months ago

https://genehack.blog/2024/02/fixing-an-emacs-typescript-ts-mode-problem/ Actually, that's exactly what I'm doing now.

  (add-to-list 'treesit-auto-recipe-list (make-treesit-auto-recipe
      :lang 'go
      :ts-mode 'go-ts-mode
      :remap 'go-mode
      :requires 'gomod
      :url "https://github.com/tree-sitter/tree-sitter-go"
      :revision "v0.20.0"
      :ext "\\.go\\'"))

I'm not sure if there's another way to do it.

Maintaining an association list (alist) for Emacs versions could be a solution to manage different versions of grammar supported by tree-sit. This alist would map Emacs versions to the compatible tree-sit grammar versions, allowing for more precise control over which version is installed and used.