From b04d4bd2a62f5f015b9f19f178a2afd3bfc91b42 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 1 Apr 2021 16:39:46 -0500 Subject: Update `consult' bindings and config --- init.el | 96 ++++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 28 deletions(-) diff --git a/init.el b/init.el index 400dfca..5d0bc1b 100644 --- a/init.el +++ b/init.el @@ -489,37 +489,77 @@ call `zzz-to-char'." ;;;;; Consult (setup (:straight consult) + + ;; "Sensible" functions + (defun consult-sensible-grep () + "Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep' +if ripgrep is installed, otherwise `consult-grep'." + (interactive "P") + (cond ((= (vc-backend buffer-file-name) "Git") + (call-interactively #'consult-git-grep)) + ((exectuable-find "rg") + (call-interactively #'consult-ripgrep)) + (t (call-interactively #'consult-grep)))) + (defun consult-sensible-find () + "Peform `consult-locate' if locate is installed, otehrwise `consult-find'." + (interactive "P") + (cond ((executable-find "locate") (call-interactively #'consult-locate)) + (t (call-interactively #'consult-find)))) + + ;; Bindings (:global - ;; C-c bindings (`mode-specific-map') - "C-c h" consult-history - "C-c m" consult-mode-command - ;; C-x bindings (`ctl-x-map') - "C-x M-:" consult-complex-command - "C-x b" consult-buffer - "C-x 4 b" consult-buffer-other-window - "C-x 5 b" consult-buffer-other-frame - "C-x r x" consult-register - "C-x r b" consult-bookmark - ;; M-g bindings (`goto-map') - "M-g o" consult-outline - "M-g m" consult-mark - "M-g k" consult-global-mark - "M-g i" consult-imenu - "M-g e" consult-error - ;; M-s bindings (`search-map') - "M-s g" consult-grep ; alts: consult-git-grep, consult-ripgrep - "M-s f" consult-find ; alts: consult-locate - "M-s l" consult-line - "M-s m" consult-multi-occur - "M-s k" consult-keep-lines - "M-s u" consult-focus-lines - ;; Other bindings - "M-y" consult-yank-pop - " a" consult-apropos - "C-h a" consult-apropos) + ;; C-c bindings (`mode-specific-map') + "C-c h" consult-history + "C-c m" consult-mode-command + "C-c b" consult-bookmark + "C-c k" consult-kmacro + ;; C-x bindings (`ctl-x-map') + "C-x M-:" consult-complex-command + "C-x b" consult-buffer + "C-x 4 b" consult-buffer-other-window + "C-x 5 b" consult-buffer-other-frame + ;; Custom M-# bindings for fast register access + "M-#" consult-register-load + "M-'" consult-register-store + "C-M-#" consult-register + ;; M-g bindings (`goto-map') + "M-g e" consult-compile-error + "M-g g" consult-goto-line + "M-g M-g" consult-goto-line + "M-g o" consult-outline + "M-g m" consult-mark + "M-g k" consult-global-mark + "M-g i" consult-imenu + "M-g I" consult-project-imenu + ;; M-s bindings (`search-map') + "M-s g" consult-sensible-grep + "M-s f" consult-sensible-find + "M-s l" consult-line + "M-s m" consult-multi-occur + "M-s k" consult-keep-lines + "M-s u" consult-focus-lines + ;; Other bindings + "M-y" consult-yank-pop + " a" consult-apropos + ;; Isearch integration + "M-s e" consult-isearch) + (:with-map isearch-mode-map + (:bind "M-e" consult-isearch + "M-s e" consult-isearch + "M-s l" consult-line)) + + ;; Registers (autoload 'consult-register-preview "consult") (:option register-preview-delay 0 - register-preview-function #'consult-register-preview)) + register-preview-function #'consult-register-format) + (:advise register-preview :override #'consult-register-window) + + ;; Xref + (:option xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + + ;; Projects + (:option consult-project-root-function #'vc-root-dir)) ;;;;; Marginalia (setup (:straight marginalia) -- cgit 1.4.1-21-gabe81