summary refs log tree commit diff
path: root/emacs/custom/my-navigation.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/custom/my-navigation.el')
-rw-r--r--emacs/custom/my-navigation.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/emacs/custom/my-navigation.el b/emacs/custom/my-navigation.el
index 28c1fa1..5d03f86 100644
--- a/emacs/custom/my-navigation.el
+++ b/emacs/custom/my-navigation.el
@@ -16,6 +16,14 @@
                           (?m "Magit status" magit-project-status)
                           (?r "Search" rg-project)))
 
+(defun my/project-find-rust-module (dir)
+  "Find the Cargo.toml file in a DIR."
+  (when-let ((root (locate-dominating-file dir "Cargo.toml")))
+    (cons 'rust-module root)))
+
+(cl-defmethod project-root ((project (head rust-module)))
+  "Set the project root for PROJECT."
+  (cdr project))
 
 (defun my/project-find-go-module (dir)
   "Find the go.mod file in a DIR."
@@ -27,6 +35,7 @@
   (cdr project))
 
 (add-to-list 'project-find-functions #'my/project-find-go-module)
+(add-to-list 'project-find-functions #'my/project-find-rust-module)
 
 (customize-set-variable 'bookmark-save-flag 1)