init-navigation.el 3.5 KB

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