Tidy `treesit' setup

This commit is contained in:
Gerard Vermeulen 2023-01-20 20:13:31 +01:00
parent d828941025
commit ddcce0abff
2 changed files with 24 additions and 9 deletions

1
.gitignore vendored
View File

@ -30,4 +30,5 @@ worg-backend-dependent-execution-update.org
/eln-cache
/elpa
/quelpa
/tree-sitter
/var

View File

@ -369,15 +369,29 @@ the contents of packages and allows to update packages to the latest version.
#+name: lst:setup-emacs-tree-sitter
#+begin_src emacs-lisp
(when (require 'treesit nil 'noerror)
;; https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg01372.html
(let ((tselp (expand-file-name "~/VCS/tree-sitter-module/dist/")))
(when (file-exists-p tselp)
(add-to-list 'treesit-extra-load-path tselp)
;; Does not play nicely with eglot:
;; (setq major-mode-remap-alist '((python-mode . python-ts-mode)))
;; Plays nicely with eglot:
(add-to-list 'auto-mode-alist
`(,(rx ".py" (opt (any "iw")) eos) . python-ts-mode)))))
(setopt
treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash" "master" "src")
(c "https://github.com/tree-sitter/tree-sitter-c" "master" "src")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp" "master" "src")
(css "https://github.com/tree-sitter/tree-sitter-css" "master" "src")
(go "https://github.com/tree-sitter/tree-sitter-go" "master" "src")
(java "https://github.com/tree-sitter/tree-sitter-java" "master" "src")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
(json "https://github.com/tree-sitter/tree-sitter-json" "master" "src")
(julia "https://github.com/tree-sitter/tree-sitter-julia" "master" "src")
(python "https://github.com/tree-sitter/tree-sitter-python" "master" "src")
(ruby "https://github.com/tree-sitter/tree-sitter-ruby" "master" "src")
(rust "https://github.com/tree-sitter/tree-sitter-rust" "master" "src")
(scala "https://github.com/tree-sitter/tree-sitter-scala" "master" "src")
(toml "https://github.com/tree-sitter/tree-sitter-toml" "master" "src")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master"
"tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master"
"typescript/src")))
(add-to-list 'auto-mode-alist
`(,(rx ".py" (opt (any "iw")) eos) . python-ts-mode)))
#+end_src
* [[info:emacs#Faces][Text faces or styles (info)]]