summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-09-07 19:02:42 -0700
committerFranck Cuny <franck@fcuny.net>2022-09-07 19:02:42 -0700
commit581a64371cfc309a225bedee1d70f7df16b6073e (patch)
tree5c5e923b7e536ec78c4a514e88a64d38b73897da
parentfeat(rust): add initial configuration for rust (diff)
downloademacs.d-581a64371cfc309a225bedee1d70f7df16b6073e.tar.gz
feat(project): consider cargo's crate as project
Add a helper to define directories that contain a 'Cargo.toml' file as a
project.

Change-Id: If099172eb6f35ecbea06a06fb39b7f64a5a809b7
-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)