Sorixelle/astro-ts-mode

Just passing on a tip

Closed this issue · 3 comments

Thanks for making this. I'd been using the same TS grammar as you, but had kind of hacked together my own astro-ts-mode. This is much nicer than the one I had. I wanted to pass along a tip for configuration, there's some great synergy that can be achieved with the use of treesit-auto.

Here's what my use-package statement looks like with treesit-auto and astro-ts-mode:

    (use-package astro-ts-mode
      :after (treesit-auto)
      :config
      (setq astro-ts-auto-recipe
            (make-treesit-auto-recipe
             :lang 'astro
             :ts-mode 'astro-ts-mode
             :url "https://github.com/virchau13/tree-sitter-astro"
             :revision "master"
             :source-dir "src"))
      (add-to-list 'treesit-auto-recipe-list astro-ts-auto-recipe))

Feel free to close this, just wanted to pass this along to you. Thanks again!

Nice! I've added the snippet to the readme (with a let instead of a setq to avoid creating a global variable), so hopefully that should help others using it as well. Thanks!

Thanks, that's really helpful, but I'm still struggling. I haven't used tree-sitter mode before 😅 Any idea what I'm missing here?

(use-package treesit-auto
  :custom
  (treesit-auto-install 'prompt)
  :config
  (treesit-auto-add-to-auto-mode-alist 'all)
  (global-treesit-auto-mode)
  )

(use-package astro-ts-mode
  :after (treesit-auto)
  :config
  (let ((astro-recipe (make-treesit-auto-recipe
                     :lang 'astro
                     :ts-mode 'astro-ts-mode
                     :url "https://github.com/virchau13/tree-sitter-astro"
                     :revision "master"
                     :source-dir "src")))
    (add-to-list 'treesit-auto-recipe-list astro-recipe))
  )

The error I get is:

⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for typescript is unavailable (not-found): (libtree-sitter-typescript.so libtree-sitter-typescript.so.0 libtree-sitter-typescript.so.0.0 libtree-sitter-typescript.dylib libtree-sitter-typescript.dylib.0 libtree-sitter-typescript.dylib.0.0) No such file or directory
⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for tsx is unavailable (not-found): (libtree-sitter-tsx.so libtree-sitter-tsx.so.0 libtree-sitter-tsx.so.0.0 libtree-sitter-tsx.dylib libtree-sitter-tsx.dylib.0 libtree-sitter-tsx.dylib.0.0) No such file or directory
⛔ Error (use-package): astro-ts-mode/:catch: Cannot load language definition: not-found, ("libtree-sitter-tsx.so" "libtree-sitter-tsx.so.0" "libtree-sitter-tsx.so.0.0" "libtree-sitter-tsx.dylib" "libtree-sitter-tsx.dylib.0" "libtree-sitter-tsx.dylib.0.0"), "No such file or directory"

@mrcnski I just did a reset of my emacs dir and tried installing from scratch. Something is indeed wrong now. I've opened an issue in the treesit-auto, I believe what is happening is that treesit is told to expect the grammer but the grammar is never getting installed by treesit-auto.

Stay tuned!