#+TITLE: Contributing new recipes

Each language's behavior for upgrade, fallback, and installation are defined by
a recipe in `treesit-auto-recipe-list`.  Here is an example entry for
JavaScript:


#+begin_src emacs-lisp
  ,(make-treesit-auto-recipe
    :lang 'typescript
    :ts-mode 'typescript-ts-mode
    :remap 'typescript-mode
    :requires 'tsx
    :url "https://github.com/tree-sitter/tree-sitter-typescript"
    :revision "master"
    :source-dir "typescript/src"
    :ext "\\.ts\\'")
#+end_src


1. =:lang= should *exactly* match the grammar name in the source repository's
   =grammar.js=.  Look for a line [[https://github.com/tree-sitter/tree-sitter-python/blob/9e53981ec31b789ee26162ea335de71f02186003/grammar.js#L28][like this]]
2. =:ts-mode= must be a single quoted symbol that is the tree-sitter mode Emacs
   should use for this grammar
3. =:remap= is either a quoted symbol or quoted list of symbols that are modes
   that should attempt to "switch up" to the tree-sitter major mode.  When the
   tree-sitter grammar isn't available, these modes are tried *in order* as
   fallback modes
4. =:requires= optionally specifies a quoted language symbol or quoted list of
   symbols of any grammars that must be installed alongside this one.
4. =:url= must specify the grammar's source repository.  Many are already listed
   on the [[https://github.com/tree-sitter][tree-sitter GitHub]]
5. =:revision= and =:source-dir= are optional, but may be required if the
   =scanner.c= file is not found under the default directory or on the default
   branch
6. =:cc= and =:c++= should be left unspecified, as they are reserved for user
   customization
7. =:ext= should be a regexp compatible with =auto-mode-alist=, specifying file
   extensions that would use this tree-sitter mode.

When submitting a pull request for a new recipe, use the title =New recipe: <grammar name>=,
and ensure that the patch consists only of the net-new recipe
lines, in the correct alphabetical position within =treesit-auto-recipe-list=.
