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

Major mode substitution (when the grammars are present) isn't consistent #89

Closed acid-bong closed 3 months ago

acid-bong commented 4 months ago

(Grammars are already packaged in nixpkgs, so i'm in luck with that, the issue is only about the mode substitution.)

When I'm opening a Rust file (rust-ts-mode is built-in, rust-mode is absent), the substitution works: it loads up the treesitter-based mode (and, if i'm using package.el instead of Nix, asks to install the grammar). Same with languages where the TS-less mode is available (like Python and C).

With Nix files, however, it doesn't work: I install nix-ts-mode ((use-package nix-ts-mode)), but it doesn't get loaded, neither when nix-mode is installed nor when it's not.

I wonder if the reason is that Nix isn't in the recipe list.

renzmann commented 3 months ago

I wonder if the reason is that Nix isn't in the recipe list.

A recipe is the only way for treesit-auto to know what to do for a language (in your case, nix). Since this issue is about Nix specifically, there are two options:

  1. Use the guide from the README on configuring a recipe for your own use
  2. Open a PR that adds nix support, following the CONTRIBUTING guide