Skip to content

Commit

Permalink
refactor(treesit-auto): better way of adding extra grammar recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed May 19, 2024
1 parent 15f0716 commit 63f953d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions modules/me-prog.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,21 @@
(global-treesit-auto-mode 1)
(+treesit-enable-available-grammars-on-normal-modes))
:config
(setq treesit-auto-langs (append treesit-auto-langs '(xml elisp))
treesit-auto-recipe-list
(append
treesit-auto-recipe-list
(list (make-treesit-auto-recipe
:lang 'xml
:ts-mode 'xml-ts-mode
:remap '(nxml-mode xml-mode)
:url "https://github.com/ObserverOfTime/tree-sitter-xml"
:source-dir "tree-sitter-xml/src"
:ext "\\.xml\\'")
(make-treesit-auto-recipe
:lang 'elisp
:ts-mode 'emacs-lisp-ts-mode
:remap 'emacs-lisp-mode
:url "https://github.com/Wilfred/tree-sitter-elisp"
:ext "\\.el\\'"))))
(let ((extra-recipes (list (make-treesit-auto-recipe
:lang 'xml
:ts-mode 'xml-ts-mode
:remap '(nxml-mode xml-mode)
:url "https://github.com/ObserverOfTime/tree-sitter-xml"
:source-dir "tree-sitter-xml/src"
:ext "\\.xml\\'")
(make-treesit-auto-recipe
:lang 'elisp
:ts-mode 'emacs-lisp-ts-mode
:remap 'emacs-lisp-mode
:url "https://github.com/Wilfred/tree-sitter-elisp"
:ext "\\.el\\'"))))
(setq treesit-auto-langs (append treesit-auto-langs (mapcar #'treesit-auto-recipe-lang extra-recipes))
treesit-auto-recipe-list (append treesit-auto-recipe-list extra-recipes)))

;; Ensure that installed tree-sitter languages have their corresponding `x-ts-mode' added to `auto-mode-alist'
(treesit-auto-add-to-auto-mode-alist 'all)
Expand Down

0 comments on commit 63f953d

Please sign in to comment.