Migrate from ivy+counsel to vertico+consult.
This commit is contained in:
parent
e9eb786eaf
commit
29328974c2
@ -10,134 +10,138 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Autocompletado y sugerencias para el minibuffer
|
||||
(use-package counsel
|
||||
;; UI para completado
|
||||
(use-package vertico
|
||||
:defer t
|
||||
:diminish ivy-mode counsel-mode
|
||||
:bind (("C-s" . swiper-isearch)
|
||||
("C-r" . counsel-rg)
|
||||
("M-x" . counsel-M-x)
|
||||
("<menu>" . counsel-M-x)
|
||||
:bind (:map vertico-map
|
||||
("RET" . vertico-directory-enter)
|
||||
("DEL" . vertico-directory-delete-char)
|
||||
("M-DEL" . vertico-directory-delete-word))
|
||||
: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)
|
||||
;; ("C-c v p" . ivy-push-view)
|
||||
;; ("C-c v o" . ivy-pop-view)
|
||||
;; ("C-c v ." . ivy-switch-view)
|
||||
;; Reemplazo para counsel
|
||||
(use-package consult
|
||||
:defer t
|
||||
: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
|
||||
("C-S-s" . isearch-forward)
|
||||
("C-S-r" . isearch-backward)
|
||||
([remap Info-search] . consult-info)
|
||||
([remap imenu] . consult-imenu)
|
||||
([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
|
||||
("C-S-s" . isearch-repeat-forward)
|
||||
("C-S-r" . isearch-repeat-backward)
|
||||
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
|
||||
|
||||
:map counsel-mode-map
|
||||
([remap swiper] . counsel-grep-or-swiper)
|
||||
([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)
|
||||
;; Minibuffer history
|
||||
:map minibuffer-local-map
|
||||
("<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
|
||||
("C-h" . counsel-up-directory)
|
||||
;; Enable automatic preview at point in the *Completions* buffer. This is
|
||||
;; relevant when you use the default completion UI.
|
||||
:hook (completion-list-mode . consult-preview-at-point-mode)
|
||||
|
||||
:map swiper-map
|
||||
("M-%" . swiper-query-replace)
|
||||
)
|
||||
|
||||
:hook ((ivy-mode . counsel-mode))
|
||||
;; The :init configuration is always executed (Not lazy)
|
||||
: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
|
||||
ivy-use-selectable-prompt t
|
||||
ivy-use-virtual-buffers t ; Enable bookmarks and recentf
|
||||
ivy-fixed-height-minibuffer t
|
||||
ivy-count-format "(%d/%d) "
|
||||
ivy-on-del-error-function #'ignore
|
||||
ivy-initial-inputs-alist nil)
|
||||
;; Optionally tweak the register preview window.
|
||||
;; This adds thin lines, sorting and hides the mode line of the window.
|
||||
(advice-add #'register-preview :override #'consult-register-window)
|
||||
|
||||
;; Use orderless regex strategy
|
||||
(setq ivy-re-builders-alist '((t . ivy--regex-ignore-order)))
|
||||
;; Use Consult to select xref locations with preview
|
||||
(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
|
||||
(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
|
||||
(use-package ivy-rich
|
||||
:defer t
|
||||
: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))
|
||||
;; Optionally configure the narrowing key.
|
||||
;; Both < and C-+ work reasonably well.
|
||||
(setq consult-narrow-key "<") ;; "C-+"
|
||||
|
||||
;; nerd-icons en ivy
|
||||
(use-package nerd-icons-ivy-rich
|
||||
:defer t
|
||||
:ensure t
|
||||
:hook (ivy-mode . nerd-icons-ivy-rich-mode))
|
||||
;; Optionally make narrowing help available in the minibuffer.
|
||||
;; You may want to use `embark-prefix-help-command' or which-key instead.
|
||||
(define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help))
|
||||
|
||||
;; nerd-icons en ibuffer
|
||||
(use-package nerd-icons-ibuffer
|
||||
:defer t
|
||||
:hook (ibuffer-mode . nerd-icons-ibuffer-mode))
|
||||
|
||||
;; Ordenar los comandos usados en M-x (por uso y luego alfabéticamente)
|
||||
(use-package smex
|
||||
;; Integración entre consult y projectile
|
||||
(use-package consult-projectile
|
||||
: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)
|
||||
;;; init-minibuffer.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user