init-navigation.el 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ;;; init-navigation.el --- Navigation Configuration File -*- lexical-binding: t -*-
  2. ;;; Commentary:
  3. ;;; Code:
  4. (use-package avy
  5. :custom
  6. (avy-all-windows nil)
  7. (avy-all-windows-alt t)
  8. (avy-timeout-seconds 0.3)
  9. :init
  10. ;; Allow C-[ to be bound (instead of being equivalent to ESC), but only in GUI Emacs
  11. ;; https://emacs.stackexchange.com/a/52334
  12. (let ((frame (framep (selected-frame))))
  13. (or (eq t frame)
  14. (eq 'pc frame)
  15. (define-key input-decode-map (kbd "C-[") [control-bracketleft])))
  16. :config
  17. ;; https://karthinks.com/software/avy-can-do-anything/#avy-plus-embark-any-action-anywhere
  18. (defun avy-action-embark (pt)
  19. (unwind-protect
  20. (save-excursion
  21. (goto-char pt)
  22. (embark-act))
  23. (select-window
  24. (cdr (ring-ref avy-ring 0))))
  25. t)
  26. (add-to-list 'avy-dispatch-alist '(?o . avy-action-embark))
  27. (defun avy-copy-as-kill ()
  28. (interactive)
  29. (avy-goto-char-timer)
  30. (let ((beg (point)))
  31. (avy-goto-char-timer)
  32. (copy-region-as-kill beg (point))))
  33. (defun avy-copy-as-kill-in-line ()
  34. (interactive)
  35. (avy-goto-char-timer)
  36. (let ((beg (point)))
  37. (call-interactively 'avy-goto-char-in-line)
  38. (copy-region-as-kill beg (point))))
  39. :bind
  40. ("C-'" . avy-goto-char-timer)
  41. ("C-;" . avy-goto-char-in-line)
  42. ("C-#" . avy-goto-word-1)
  43. ("C-c C-'" . avy-copy-as-kill)
  44. ("C-c C-;" . avy-copy-as-kill-in-line))
  45. (use-package casual-avy
  46. :bind ([control-bracketleft] . casual-avy-tmenu))
  47. (use-package smartscan
  48. :custom (smartscan-symbol-selector "symbol")
  49. :config
  50. (unbind-key "M-'" smartscan-map)
  51. :hook
  52. ((cider-repl-mode
  53. ielm-mode
  54. vterm-mode
  55. term-mode
  56. ansi-term-mode
  57. eshell-mode
  58. shell-mode
  59. sql-interactive-mode
  60. magit-status-mode
  61. compilation-mode
  62. deadgrep-mode) . (lambda () (smartscan-mode -1)))
  63. (elpaca-after-init . global-smartscan-mode)
  64. :bind (:map smartscan-map
  65. ("C-M-'" . smartscan-symbol-replace)))
  66. (use-package symbol-overlay
  67. :config
  68. (defun symbol-overlay-put-or-clear (arg)
  69. "Toggle all overlays of symbol at point.
  70. Or remove all highlighted symbols in the current buffer (with`ARG')."
  71. (interactive "P")
  72. (if arg
  73. (symbol-overlay-remove-all)
  74. (symbol-overlay-put)))
  75. :bind
  76. ("C-c o" . symbol-overlay-put-or-clear)
  77. ("M-N" . symbol-overlay-switch-forward)
  78. ("M-P" . symbol-overlay-switch-backward)
  79. (:map symbol-overlay-map ("o" . symbol-overlay-put-or-clear)))
  80. (use-package gumshoe
  81. :after perspective
  82. :demand t
  83. :diminish global-gumshoe-mode
  84. :custom
  85. (gumshoe-show-footprints-p nil)
  86. (gumshoe-idle-time 5)
  87. (gumshoe-follow-distance 5)
  88. (gumshoe-slot-schema '(perspective time buffer position line))
  89. :config
  90. (global-gumshoe-mode +1)
  91. :bind
  92. ("C-c '" . gumshoe-peruse-in-persp))
  93. (use-package goto-chg
  94. :config
  95. (defvar goto-chg-repeat-map
  96. (let ((map (make-sparse-keymap)))
  97. (define-key map (kbd "C-(") #'goto-last-change)
  98. (define-key map (kbd "C-)") #'goto-last-change-reverse)
  99. map))
  100. (dolist (cmd '(goto-last-change goto-last-change-reverse))
  101. (put cmd 'repeat-map 'goto-chg-repeat-map))
  102. :bind
  103. ("C-c C-(" . goto-last-change)
  104. ("C-c C-)" . goto-last-change-reverse))
  105. (use-package goto-last-point
  106. :diminish
  107. :custom (goto-last-point-max-length 100)
  108. :hook (elpaca-after-init . goto-last-point-mode)
  109. :config
  110. (defvar goto-last-point-repeat-map
  111. (let ((map (make-sparse-keymap)))
  112. (define-key map (kbd "<") #'goto-last-point)
  113. map))
  114. (put 'goto-last-point 'repeat-map 'goto-last-point-repeat-map)
  115. :bind ("C-c <" . goto-last-point))
  116. (use-package link-hint
  117. :bind
  118. ("C-c C-l" . link-hint-open-link)
  119. ("C-c C-S-l" . link-hint-copy-link))
  120. (use-package dumb-jump
  121. :defer 5
  122. :custom (dumb-jump-force-searcher 'rg)
  123. :config (add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
  124. (provide 'init-navigation)
  125. ;;; init-navigation.el ends here