summary refs log tree commit diff
path: root/emacs/custom/my-navigation.el
blob: 28c1fa18755d2a03a34205d8c678abda04a2ada0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;;; my-navigation.el --- Configure parts related to navigation -*- lexical-binding: t -*-

;;; Commentary:

;;; Code:

(setq help-window-select t)

(require 'project)

(customize-set-variable 'project-switch-commands
                        '((?f "File" project-find-file)
                          (?d "Dired" project-dired)
                          (?b "Buffer" project-switch-to-buffer)
                          (?e "Eshell" project-eshell)
                          (?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)
(global-set-key (kbd "M-g i") 'imenu)

(customize-set-variable 'recentf-max-saved-items 500)
(customize-set-variable 'recentf-exclude '(".gz" ".xz" ".zip" "tmp/" "/ssh:"))
(add-hook 'after-init-hook 'recentf-mode)

(customize-set-variable 'rg-group-result t)
(customize-set-variable 'rg-show-columns t)
(customize-set-variable 'rg-align-position-numbers t)
(customize-set-variable 'rg-align-line-number-field-length 3)
(customize-set-variable 'rg-align-column-number-field-length 3)
(customize-set-variable 'rg-align-line-column-separator "#")
(customize-set-variable 'rg-align-position-content-separator "|")

(add-hook 'after-init-hook 'which-key-mode)

(provide 'my-navigation)

;;; my-navigation.el ends here