feat(tazjin/emacs): add find-cargo-project function

This is useful for eglot launching rust-analyzer when I'm outside of a
depot project.

Change-Id: I1fa1dc11e3eabe4bdedbd6389b55411641391c7e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6176
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-08-26 20:20:05 +03:00 committed by clbot
parent 598c197422
commit e70ef017ff

View file

@ -293,6 +293,16 @@ the GPG agent correctly."
(add-to-list 'project-find-functions #'find-depot-project)
(defun find-cargo-project (dir)
"Attempt to find the current project in `project-find-functions'
by looking for a `Cargo.toml' file."
(unless (equal "/" dir)
(if (f-exists-p (f-join dir "Cargo.toml"))
(cons 'transient dir)
(find-cargo-project (f-parent dir)))))
(add-to-list 'project-find-functions #'find-cargo-project)
(defun magit-find-file-worktree ()
(interactive)
"Find a file in the current (ma)git worktree."