Migrate from ivy+counsel to vertico+consult.
This commit is contained in:
parent
e9eb786eaf
commit
29328974c2
@ -10,134 +10,138 @@
|
|||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
;; Autocompletado y sugerencias para el minibuffer
|
;; UI para completado
|
||||||
(use-package counsel
|
(use-package vertico
|
||||||
:defer t
|
:defer t
|
||||||
:diminish ivy-mode counsel-mode
|
:bind (:map vertico-map
|
||||||
:bind (("C-s" . swiper-isearch)
|
("RET" . vertico-directory-enter)
|
||||||
("C-r" . counsel-rg)
|
("DEL" . vertico-directory-delete-char)
|
||||||
("M-x" . counsel-M-x)
|
("M-DEL" . vertico-directory-delete-word))
|
||||||
("<menu>" . counsel-M-x)
|
:hook ((elpaca-after-init . vertico-mode)
|
||||||
|
(elpaca-after-init . savehist-mode) ;; savehist sirve para recordar el último comando de M-x
|
||||||
|
(rfn-eshadow-update-overlay . vertico-directory-tidy)))
|
||||||
|
|
||||||
;; ("C-c C-r" . ivy-resume)
|
;; Reemplazo para counsel
|
||||||
;; ("C-c v p" . ivy-push-view)
|
(use-package consult
|
||||||
;; ("C-c v o" . ivy-pop-view)
|
:defer t
|
||||||
;; ("C-c v ." . ivy-switch-view)
|
:bind (;; C-c bindings in `mode-specific-map'
|
||||||
|
("C-s" . consult-line)
|
||||||
|
("C-r" . consult-ripgrep)
|
||||||
|
("C-S-s" . isearch-forward)
|
||||||
|
("C-S-r" . isearch-backward)
|
||||||
|
("M-m" . consult-mode-command)
|
||||||
|
("C-c h" . consult-history)
|
||||||
|
("C-c k" . consult-kmacro)
|
||||||
|
|
||||||
;; Colocando isearch en otro keybind
|
([remap Info-search] . consult-info)
|
||||||
("C-S-s" . isearch-forward)
|
([remap imenu] . consult-imenu)
|
||||||
("C-S-r" . isearch-backward)
|
([remap recentf-open-files] . consult-recent-file)
|
||||||
|
|
||||||
|
|
||||||
|
;; C-x bindings in `ctl-x-map'
|
||||||
|
("C-x M-." . consult-complex-command) ;; orig. repeat-complex-command
|
||||||
|
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
|
||||||
|
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
|
||||||
|
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
|
||||||
|
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
|
||||||
|
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
|
||||||
|
;; Custom M-# bindings for fast register access
|
||||||
|
("M-#" . consult-register-load)
|
||||||
|
("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
|
||||||
|
("M-¡" . consult-register)
|
||||||
|
;; Other custom bindings
|
||||||
|
("M-y" . consult-yank-pop) ;; orig. yank-pop
|
||||||
|
;; M-g bindings in `goto-map'
|
||||||
|
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
|
||||||
|
("M-g g" . consult-goto-line) ;; orig. goto-line
|
||||||
|
("M-g M-g" . consult-goto-line) ;; orig. goto-line
|
||||||
|
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
|
||||||
|
("M-g m" . consult-mark)
|
||||||
|
("M-g k" . consult-global-mark)
|
||||||
|
("M-g i" . consult-imenu)
|
||||||
|
("M-g I" . consult-imenu-multi)
|
||||||
|
;; M-s bindings in `search-map'
|
||||||
|
("M-s d" . consult-find)
|
||||||
|
("M-s D" . consult-locate)
|
||||||
|
("M-s L" . consult-line-multi)
|
||||||
|
("M-s k" . consult-keep-lines)
|
||||||
|
("M-s u" . consult-focus-lines)
|
||||||
|
;; Isearch integration
|
||||||
:map isearch-mode-map
|
:map isearch-mode-map
|
||||||
("C-S-s" . isearch-repeat-forward)
|
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
|
||||||
("C-S-r" . isearch-repeat-backward)
|
|
||||||
|
|
||||||
:map counsel-mode-map
|
;; Minibuffer history
|
||||||
([remap swiper] . counsel-grep-or-swiper)
|
:map minibuffer-local-map
|
||||||
([remap swiper-backward] . counsel-grep-or-swiper-backward)
|
|
||||||
([remap dired] . counsel-dired)
|
|
||||||
([remap set-variable] . counsel-set-variable)
|
|
||||||
([remap insert-char] . counsel-unicode-char)
|
|
||||||
([remap recentf-open-files] . counsel-recentf)
|
|
||||||
([remap org-capture] . counsel-org-capture)
|
|
||||||
([remap jump-to-register] . counsel-register)
|
|
||||||
|
|
||||||
:map ivy-minibuffer-map
|
|
||||||
("C-w" . ivy-yank-word)
|
|
||||||
("<tab>" . ivy-partial)
|
|
||||||
("<escape>" . minibuffer-keyboard-quit)
|
("<escape>" . minibuffer-keyboard-quit)
|
||||||
|
("C-s" . (lambda ()
|
||||||
|
"Insert the currunt symbol."
|
||||||
|
(interactive)
|
||||||
|
(insert (save-excursion
|
||||||
|
(set-buffer (window-buffer (minibuffer-selected-window)))
|
||||||
|
(or (thing-at-point 'symbol t) "")))))
|
||||||
|
("M-s" . consult-history) ;; orig. next-matching-history-element
|
||||||
|
("M-r" . consult-history)) ;; orig. previous-matching-history-element
|
||||||
|
|
||||||
:map counsel-find-file-map
|
;; Enable automatic preview at point in the *Completions* buffer. This is
|
||||||
("C-h" . counsel-up-directory)
|
;; relevant when you use the default completion UI.
|
||||||
|
:hook (completion-list-mode . consult-preview-at-point-mode)
|
||||||
|
|
||||||
:map swiper-map
|
;; The :init configuration is always executed (Not lazy)
|
||||||
("M-%" . swiper-query-replace)
|
|
||||||
)
|
|
||||||
|
|
||||||
:hook ((ivy-mode . counsel-mode))
|
|
||||||
:init
|
:init
|
||||||
(setq enable-recursive-minibuffers t) ; Allow commands in minibuffers
|
;; Optionally configure the register formatting. This improves the register
|
||||||
|
;; preview for `consult-register', `consult-register-load',
|
||||||
|
;; `consult-register-store' and the Emacs built-ins.
|
||||||
|
(setq register-preview-delay 0.5
|
||||||
|
register-preview-function #'consult-register-format)
|
||||||
|
|
||||||
(setq ivy-height 12
|
;; Optionally tweak the register preview window.
|
||||||
ivy-use-selectable-prompt t
|
;; This adds thin lines, sorting and hides the mode line of the window.
|
||||||
ivy-use-virtual-buffers t ; Enable bookmarks and recentf
|
(advice-add #'register-preview :override #'consult-register-window)
|
||||||
ivy-fixed-height-minibuffer t
|
|
||||||
ivy-count-format "(%d/%d) "
|
|
||||||
ivy-on-del-error-function #'ignore
|
|
||||||
ivy-initial-inputs-alist nil)
|
|
||||||
|
|
||||||
;; Use orderless regex strategy
|
;; Use Consult to select xref locations with preview
|
||||||
(setq ivy-re-builders-alist '((t . ivy--regex-ignore-order)))
|
(with-eval-after-load 'xref
|
||||||
|
(setq xref-show-xrefs-function #'consult-xref
|
||||||
|
xref-show-definitions-function #'consult-xref))
|
||||||
|
|
||||||
;; Set minibuffer height for different commands
|
|
||||||
(setq ivy-height-alist '((counsel-evil-registers . 5)
|
|
||||||
(counsel-yank-pop . 8)
|
|
||||||
(counsel-git-log . 4)
|
|
||||||
(swiper . 15)
|
|
||||||
(counsel-projectile-ag . 15)
|
|
||||||
(counsel-projectile-rg . 15)))
|
|
||||||
|
|
||||||
|
|
||||||
(setq swiper-action-recenter t)
|
|
||||||
|
|
||||||
(setq counsel-find-file-at-point t
|
|
||||||
counsel-preselect-current-file t
|
|
||||||
counsel-yank-pop-separator "\n────────\n")
|
|
||||||
(add-hook 'counsel-grep-post-action-hook #'recenter)
|
|
||||||
|
|
||||||
;; Use the faster search tools
|
|
||||||
(when (executable-find "rg")
|
|
||||||
(setq counsel-grep-base-command "rg -S --no-heading --line-number --color never '%s' '%s'"))
|
|
||||||
(when (executable-find "fd")
|
|
||||||
(setq counsel-fzf-cmd
|
|
||||||
"fd --type f --hidden --follow --exclude .git --color never '%s'"))
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Integración entre projectile y counsel
|
|
||||||
(use-package counsel-projectile
|
|
||||||
:defer t
|
|
||||||
:bind*
|
|
||||||
("C-x p" . counsel-projectile)
|
|
||||||
:hook (counsel-mode . counsel-projectile-mode)
|
|
||||||
:init (setq counsel-projectile-grep-initial-input '(ivy-thing-at-point)))
|
|
||||||
|
|
||||||
;; Autocompletado, sugerencias y menú de búsqueda mejorados (este paquete incluye counsel y swiper)
|
|
||||||
(use-package ivy
|
|
||||||
:defer t
|
|
||||||
:hook (elpaca-after-init . ivy-mode)
|
|
||||||
:config
|
:config
|
||||||
(setq ivy-use-virtual-buffers nil))
|
;; Optionally configure preview. The default value
|
||||||
|
;; is 'any, such that any key triggers the preview.
|
||||||
|
;; (setq consult-preview-key 'any)
|
||||||
|
(setq consult-preview-key "M-.")
|
||||||
|
;; (setq consult-preview-key '("S-<down>" "S-<up>"))
|
||||||
|
;; For some commands and buffer sources it is useful to configure the
|
||||||
|
;; :preview-key on a per-command basis using the `consult-customize' macro.
|
||||||
|
(consult-customize
|
||||||
|
consult-goto-line
|
||||||
|
consult-theme :preview-key '(:debounce 0.4 any))
|
||||||
|
|
||||||
;; Ivy pero con más detalles en pantalla
|
;; Optionally configure the narrowing key.
|
||||||
(use-package ivy-rich
|
;; Both < and C-+ work reasonably well.
|
||||||
:defer t
|
(setq consult-narrow-key "<") ;; "C-+"
|
||||||
:ensure t
|
|
||||||
:hook ((counsel-projectile-mode . ivy-rich-mode) ; MUST after `counsel-projectile'
|
|
||||||
(ivy-rich-mode . ivy-rich-project-root-cache-mode)
|
|
||||||
(ivy-rich-mode . (lambda ()
|
|
||||||
"Use abbreviate in `ivy-rich-mode'."
|
|
||||||
(setq ivy-virtual-abbreviate
|
|
||||||
(or (and ivy-rich-mode 'abbreviate) 'name)))))
|
|
||||||
:init
|
|
||||||
;; For better performance
|
|
||||||
(setq ivy-rich-parse-remote-buffer nil))
|
|
||||||
|
|
||||||
;; nerd-icons en ivy
|
;; Optionally make narrowing help available in the minibuffer.
|
||||||
(use-package nerd-icons-ivy-rich
|
;; You may want to use `embark-prefix-help-command' or which-key instead.
|
||||||
:defer t
|
(define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help))
|
||||||
:ensure t
|
|
||||||
:hook (ivy-mode . nerd-icons-ivy-rich-mode))
|
|
||||||
|
|
||||||
;; nerd-icons en ibuffer
|
;; nerd-icons en ibuffer
|
||||||
(use-package nerd-icons-ibuffer
|
(use-package nerd-icons-ibuffer
|
||||||
:defer t
|
:defer t
|
||||||
:hook (ibuffer-mode . nerd-icons-ibuffer-mode))
|
:hook (ibuffer-mode . nerd-icons-ibuffer-mode))
|
||||||
|
|
||||||
;; Ordenar los comandos usados en M-x (por uso y luego alfabéticamente)
|
;; Integración entre consult y projectile
|
||||||
(use-package smex
|
(use-package consult-projectile
|
||||||
:defer t
|
:defer t
|
||||||
:after (counsel))
|
:bind ("C-x p" . consult-projectile))
|
||||||
|
|
||||||
|
;; Descripciones en el minibufer
|
||||||
|
(use-package marginalia
|
||||||
|
:defer t
|
||||||
|
:hook (elpaca-after-init . marginalia-mode))
|
||||||
|
|
||||||
|
;; Nerd icons para vertico
|
||||||
|
(use-package nerd-icons-completion
|
||||||
|
:after nerd-icons
|
||||||
|
:config (nerd-icons-completion-mode))
|
||||||
|
|
||||||
(provide 'init-minibuffer)
|
(provide 'init-minibuffer)
|
||||||
;;; init-minibuffer.el ends here
|
;;; init-minibuffer.el ends here
|
||||||
|
Loading…
Reference in New Issue
Block a user