I'm unable to have tree-sitter on gdscript-mode (Emacs)

Hi!

I’m using the latest Emacs (pkgs.unstable.emacs29-pgtk) and I’m unable to use tree-sitter for GDScript on it. I have these packages installed by home-manager:

  80   │     pkgs.tree-sitter-grammars.tree-sitter-gdscript
  81   │     pkgs.tree-sitter

And this is what I get when opening a GDScript file:

⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for gdscript is unavailable (not-found): (libtree-sitter-gdscript libtree-sitter-gdscript.0 libtree-sitter-gdscript.0.0 libtree-sitter-gdscript.so libtree-sitter-gdscript.so.0 libtree-sitter-gdscript.so.0.0) No such file or directory

You need to add it to the emacs package proper, so try:

defaultPkg = pkgs.unstable.emacs29-pgtk.withPackages (epkgs: with epkgs; [
  (treesit-grammars.with-grammars (grammars: with grammars; [
    tree-sitter-gdscript
  ])
]);

YMMV, I’m not sure that all emacs derivation alternatives have a withPackages, but I’m too lazy to read that code again right now.

Stable has emacs 29 too, by the way, grabbing it from unstable seems unnecessary.

1 Like

Thank you for the code snippet! I’ll paste it here with the small correction because you were missing a parenthesis :slight_smile:

  defaultPkg = (
    (pkgs.emacsPackagesFor pkgs.emacs).emacsWithPackages (
      epkgs: with epkgs; [
        (treesit-grammars.with-grammars (grammars: with grammars; [ tree-sitter-gdscript ]))
      ]
    )
  );

update your answer so I can accept it as the correct answer, please!

1 Like

Eh, too lazy to play syntax parser, and there’s a solution already ;p

1 Like