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
|
.idea
|
||||||
.python-version
|
.python-version
|
||||||
|
.dir-locals.el
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
(defun locate-rust-analyzer ()
|
(defun locate-rust-analyzer ()
|
||||||
"Find 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)))
|
(let ((first-non-nil-path (seq-find (lambda (elt) elt) rust-analyzer-paths)))
|
||||||
first-non-nil-path
|
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
|
(use-package rust-ts-mode
|
||||||
:pin manual
|
:pin manual
|
||||||
:mode (
|
:mode (
|
||||||
@ -35,7 +40,7 @@
|
|||||||
(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-ts-mode (list 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)
|
(add-hook 'before-save-hook 'eglot-format-buffer nil 'local)
|
||||||
@ -63,5 +68,17 @@
|
|||||||
(unless (treesit-ready-p 'toml) (treesit-install-language-grammar 'toml))
|
(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)
|
(provide 'lang-rust)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user