diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-26T17·20+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-08-26T17·26+0000 |
commit | e70ef017ff3ff1c3aab6023b950b9206773d44dd (patch) | |
tree | 4b799f231f4b43fc328d5349c1c2071ef964f1d1 /users/tazjin/emacs/config/functions.el | |
parent | 598c197422481ed31c605d4dc3b7a7e3f043aa85 (diff) |
feat(tazjin/emacs): add `find-cargo-project` function r/4509
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
Diffstat (limited to 'users/tazjin/emacs/config/functions.el')
-rw-r--r-- | users/tazjin/emacs/config/functions.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/users/tazjin/emacs/config/functions.el b/users/tazjin/emacs/config/functions.el index e725c23ccf41..f64907a591b6 100644 --- a/users/tazjin/emacs/config/functions.el +++ b/users/tazjin/emacs/config/functions.el @@ -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." |