about summary refs log tree commit diff stats
path: root/.emacs.d/lisp/init-navigation.el
blob: cb2a39eab2ff6b78dc49852c32bc1240c3f4a6cc (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
;;; init-navigation.el --- Navigation Configuration File -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(use-package avy
  :config
  ;; https://karthinks.com/software/avy-can-do-anything/#avy-plus-embark-any-action-anywhere
  (defun avy-action-embark (pt)
    (unwind-protect
        (save-excursion
          (goto-char pt)
          (embark-act))
      (select-window
       (cdr (ring-ref avy-ring 0))))
    t)
  (add-to-list 'avy-dispatch-alist '(111 . avy-action-embark))
  :bind
  ("C-'" . avy-goto-char-timer)
  ("C-;" . avy-goto-char-in-line))

(use-package smartscan
  :config
  (global-smartscan-mode t)
  :hook
  (cider-repl-mode . (lambda () (smartscan-mode -1)))
  (ielm-mode . (lambda () (smartscan-mode -1)))
  (vterm-mode . (lambda () (smartscan-mode -1)))
  (term-mode . (lambda () (smartscan-mode -1)))
  (ansi-term-mode . (lambda () (smartscan-mode -1)))
  (eshell-mode . (lambda () (smartscan-mode -1)))
  (shell-mode . (lambda () (smartscan-mode -1)))
  (sql-interactive-mode . (lambda () (smartscan-mode -1)))
  (compilation-mode . (lambda () (smartscan-mode -1)))
  (deadgrep-mode . (lambda () (smartscan-mode -1))))

(use-package symbol-overlay
  :bind
  ("C-c o" . symbol-overlay-put)
  ("M-N" . symbol-overlay-switch-forward)
  ("M-P" . symbol-overlay-switch-backward)
  ("<f8>" . symbol-overlay-remove-all))

(use-package affe
  :after (consult orderless)
  :config
  (setq affe-grep-command (replace-regexp-in-string "\\." "-Suu ." affe-grep-command))
  ;; Configure Orderless
  (defun affe-orderless-regexp-compiler (input _type _ignorecase)
    (setq input (orderless-pattern-compiler input))
    (cons input (lambda (str) (orderless--highlight input str))))
  (setq affe-regexp-compiler #'affe-orderless-regexp-compiler)
  ;; Manual preview key for `affe-grep'
  (consult-customize affe-grep :preview-key (kbd "M-."))
  (defun my/affe-grep-symbol-at-point (&optional dir initial)
    (interactive
     (list prefix-arg (when-let ((s (symbol-at-point)))
                        (symbol-name s))))
    (affe-grep dir initial))
  (defun my/affe-find-symbol-at-point (&optional dir initial)
    (interactive
     (list prefix-arg (when-let ((s (symbol-at-point)))
                        (symbol-name s))))
    (affe-find dir initial))
  :bind
  ("C-#" . affe-grep)
  ("C-c z" . affe-find)
  ("C-c Z" . my/affe-find-symbol-at-point)
  ("C-~" . my/affe-grep-symbol-at-point))

(use-package gumshoe
  :defer 5
  :after perspective
  :diminish global-gumshoe-persp-mode
  :custom (gumshoe-show-footprints-p nil)
  :config
  (global-gumshoe-persp-mode +1)
  (defvar gumshoe-repeat-map
    (let ((map (make-sparse-keymap)))
      (define-key map (kbd "]") #'gumshoe-buf-backtrack-forward)
      (define-key map (kbd "[") #'gumshoe-buf-backtrack-back)
      (define-key map (kbd "}") #'gumshoe-persp-backtrack-forward)
      (define-key map (kbd "{") #'gumshoe-persp-backtrack-back)
      map))
  (dolist (cmd '(gumshoe-buf-backtrack-forward gumshoe-buf-backtrack-back gumshoe-persp-backtrack-forward gumshoe-persp-backtrack-back))
    (put cmd 'repeat-map 'gumshoe-repeat-map))
  :bind
  ("C-c ]" . gumshoe-buf-backtrack-forward)
  ("C-c [" . gumshoe-buf-backtrack-back)
  ("C-c }" . gumshoe-persp-backtrack-forward)
  ("C-c {" . gumshoe-persp-backtrack-back)
  ("C-c '" . gumshoe-peruse-in-persp))

(provide 'init-navigation)
;;; init-navigation.el ends here