Locate rust-analyzer on the /home/talexander/.pyenv/shims:/opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin.
This commit is contained in:
parent
d229447149
commit
db5b400408
@ -1,2 +1,3 @@
|
||||
.idea
|
||||
.python-version
|
||||
.dir-locals.el
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
(defun locate-rust-analyzer ()
|
||||
"Find rust-analyzer."
|
||||
(let ((rust-analyzer-paths (list (locate-rust-analyzer-rustup) (locate-rust-analyzer-ansible-built))))
|
||||
(let ((rust-analyzer-paths (list (locate-rust-analyzer-rustup) (locate-rust-analyzer-ansible-built) (locate-rust-analyzer-in-path))))
|
||||
(let ((first-non-nil-path (seq-find (lambda (elt) elt) rust-analyzer-paths)))
|
||||
first-non-nil-path
|
||||
)
|
||||
@ -24,6 +24,11 @@
|
||||
)
|
||||
)
|
||||
|
||||
(defun locate-rust-analyzer-in-path ()
|
||||
"Find rust-analyzer in $PATH."
|
||||
(executable-find "rust-analyzer")
|
||||
)
|
||||
|
||||
(use-package rust-ts-mode
|
||||
:pin manual
|
||||
:mode (
|
||||
@ -32,14 +37,14 @@
|
||||
:commands (rust-ts-mode)
|
||||
:hook (
|
||||
(rust-ts-mode . (lambda ()
|
||||
(eglot-ensure)
|
||||
(let ((rust-analyzer-command (locate-rust-analyzer)))
|
||||
(when rust-analyzer-command
|
||||
(add-to-list 'eglot-server-programs (cons 'rust-ts-mode (list rust-analyzer-command)))
|
||||
)
|
||||
)
|
||||
(add-hook 'before-save-hook 'eglot-format-buffer nil 'local)
|
||||
))
|
||||
(eglot-ensure)
|
||||
(let ((rust-analyzer-command (locate-rust-analyzer)))
|
||||
(when rust-analyzer-command
|
||||
(add-to-list 'eglot-server-programs `(rust-ts-mode . (,rust-analyzer-command)))
|
||||
)
|
||||
)
|
||||
(add-hook 'before-save-hook 'eglot-format-buffer nil 'local)
|
||||
))
|
||||
)
|
||||
:init
|
||||
(add-to-list 'major-mode-remap-alist '(rust-mode . rust-ts-mode))
|
||||
@ -63,5 +68,17 @@
|
||||
(unless (treesit-ready-p 'toml) (treesit-install-language-grammar 'toml))
|
||||
)
|
||||
|
||||
;; Set additional rust-analyzer settings:
|
||||
;;
|
||||
;; (add-to-list 'eglot-server-programs `(rust-ts-mode . (,rust-analyzer-command :initializationOptions (:cargo (:features "all")))))
|
||||
;;
|
||||
;; In addition to the above, directory-specific settings can be written to a .dir-locals.el with the contents:
|
||||
;;
|
||||
;; (
|
||||
;; (rust-ts-mode . ((eglot-workspace-configuration
|
||||
;; . (:rust-analyzer (:cargo (:features "compare"))))
|
||||
;; ))
|
||||
;; )
|
||||
|
||||
|
||||
(provide 'lang-rust)
|
||||
|
Loading…
x
Reference in New Issue
Block a user