Use treesitter for rust.

This commit is contained in:
Tom Alexander 2023-05-27 00:22:26 -04:00
parent ba21ec24b8
commit cb63ab4b1f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 30 additions and 8 deletions

View File

@ -1,3 +1,4 @@
(package-initialize)
(use-package use-package) (use-package use-package)
(add-to-list 'package-archives (add-to-list 'package-archives

View File

@ -24,14 +24,17 @@
) )
) )
(add-to-list 'major-mode-remap-alist '(rust-mode . rust-ts-mode))
(use-package rust-mode (use-package rust-mode
:pin nongnu
:mode "\\.rs\\'" :mode "\\.rs\\'"
:hook ( :hook (
(rust-mode . (lambda () (rust-ts-mode . (lambda ()
(eglot-ensure) (eglot-ensure)
(let ((rust-analyzer-command (locate-rust-analyzer))) (let ((rust-analyzer-command (locate-rust-analyzer)))
(when rust-analyzer-command (when rust-analyzer-command
(add-to-list 'eglot-server-programs (cons 'rust-mode (list rust-analyzer-command))) (add-to-list 'eglot-server-programs (cons 'rust-ts-mode (list rust-analyzer-command)))
) )
) )
(when-linux (when-linux
@ -41,9 +44,10 @@
)) ))
) )
:config :config
(treesit-install-language-grammar 'rust)
;; Add keybindings for interacting with Cargo ;; Add keybindings for interacting with Cargo
(use-package cargo (use-package cargo
:hook (rust-mode . cargo-minor-mode)) :hook (rust-ts-mode . cargo-minor-mode))
) )
(provide 'lang-rust) (provide 'lang-rust)

View File

@ -1,7 +1,24 @@
;; (use-package tree-sitter (setq treesit-language-source-alist
;; :commands (tree-sitter-hl-mode) '(
;; :config (bash "https://github.com/tree-sitter/tree-sitter-bash")
;; (use-package tree-sitter-langs) (c "https://github.com/tree-sitter/tree-sitter-c")
;; ) (common-lisp "https://github.com/theHamsta/tree-sitter-commonlisp")
(css "https://github.com/tree-sitter/tree-sitter-css")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(go "https://github.com/tree-sitter/tree-sitter-go")
(go-mod "https://github.com/camdencheek/tree-sitter-go-mod")
(html "https://github.com/tree-sitter/tree-sitter-html")
(js . ("https://github.com/tree-sitter/tree-sitter-javascript" "master" "src"))
(json "https://github.com/tree-sitter/tree-sitter-json")
(lua "https://github.com/Azganoth/tree-sitter-lua")
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(python "https://github.com/tree-sitter/tree-sitter-python")
(rust "https://github.com/tree-sitter/tree-sitter-rust")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(tsx . ("https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src"))
(typescript . ("https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src"))
(yaml "https://github.com/ikatyang/tree-sitter-yaml"))
)
(provide 'util-tree-sitter) (provide 'util-tree-sitter)