renzmann / treesit-auto

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

Can't get work for nix #66

Closed anuvyklack closed 10 months ago

anuvyklack commented 10 months ago

I am trying to add a recipe for nix language, but can't get it work. I use this configuration

(use-package treesit-auto
  :ensure t
  :custom (treesit-auto-install t)
  :config
  (global-treesit-auto-mode)
  (add-to-list 'treesit-auto-langs 'nix)
  (add-to-list 'treesit-auto-recipe-list
               (make-treesit-auto-recipe
                :lang 'nix
                :ts-mode 'nix-ts-mode
                :remap 'nix-mode
                :url "https://github.com/nix-community/tree-sitter-nix"
                :revision "master"
                :source-dir "src"
                :ext "\\.nix\\'"))
  (treesit-auto-add-to-auto-mode-alist))

And when I manually call treesit-auto-install-all command, it builds libtree-sitter-nix.so, but when I delete it, restart Emacs and visit Nix file, nothing happens.

renzmann commented 10 months ago

when I delete it, restart Emacs and visit Nix file, nothing happens

This would be because the default behavior of treesit-auto-add-to-auto-mode-alist is to only add tree-sitter modes that are ready to auto-mode-alist. If you use (treesit-auto-add-to-auto-mode-alist 'all) or (treesit-auto-add-to-auto-mode-alist '(nix)), do you get the intended behavior?

renzmann commented 10 months ago

Additionally, feel free to contribute this recipe in a PR so we can just include nix with treesit-auto!