summary refs log tree commit diff
path: root/emacs/custom
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/custom')
-rw-r--r--emacs/custom/my-navigation.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/emacs/custom/my-navigation.el b/emacs/custom/my-navigation.el
index c0726ac..28c1fa1 100644
--- a/emacs/custom/my-navigation.el
+++ b/emacs/custom/my-navigation.el
@@ -6,6 +6,8 @@
 
 (setq help-window-select t)
 
+(require 'project)
+
 (customize-set-variable 'project-switch-commands
                         '((?f "File" project-find-file)
                           (?d "Dired" project-dired)
@@ -14,6 +16,18 @@
                           (?m "Magit status" magit-project-status)
                           (?r "Search" rg-project)))
 
+
+(defun my/project-find-go-module (dir)
+  "Find the go.mod file in a DIR."
+  (when-let ((root (locate-dominating-file dir "go.mod")))
+    (cons 'go-module root)))
+
+(cl-defmethod project-root ((project (head go-module)))
+  "Set the project root for PROJECT."
+  (cdr project))
+
+(add-to-list 'project-find-functions #'my/project-find-go-module)
+
 (customize-set-variable 'bookmark-save-flag 1)
 
 (global-set-key (kbd "C-x C-b") 'ibuffer)