Skip to content

Commit

Permalink
[emacs] move away from treesit-auto and setup treesit manually
Browse files Browse the repository at this point in the history
This makes it more direct to setup a specific version of the
tree-sitter grammar.
  • Loading branch information
meain committed Jun 10, 2024
1 parent 6363aac commit 3325faf
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions emacs/.config/emacs/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -3515,11 +3515,26 @@ Instead of `default-directory' when calling `ORIG-FN' with `ARGS'."
remember-notes-initial-major-mode 'org-mode
remember-notes-auto-save-visited-file-name t))

;; Automatically install treesit grammars
(use-package treesit-auto
:ensure t
(use-package emacs
:config
(global-treesit-auto-mode))
(setq treesit-language-source-alist
'((typescript . ("https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src"))
(tsx . ("https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src"))
(go . ("https://github.com/meain/tree-sitter-go" "e395081"))
(python . ("https://github.com/tree-sitter/tree-sitter-python"))))

(defun meain/install-treesit-grammars ()
(interactive)
(mapc #'treesit-install-language-grammar (mapcar #'car treesit-language-source-alist)))

(setq treesit-load-name-override-list '((js "libtree-sitter-go" "tree_sitter_go")))

(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-ts-mode))

(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
(add-to-list 'major-mode-remap-alist '(go-mode . go-ts-mode)))

;; Tree sitter
(use-package tree-sitter
Expand Down

0 comments on commit 3325faf

Please sign in to comment.