confi-emacs-actual/configs/init-minibuffer.el

142 lines
4.5 KiB
EmacsLisp
Raw Normal View History

2023-04-14 18:39:19 +02:00
;;; init-minibuffer.el --- Ayuditas y autocompletado del minibufer -*- lexical-binding: t -*-
;; Author: kj <webmaster@outcontrol.net>
;; URL: https://git.kj2.me/kj/confi-emacs-actual
;;; Commentary:
2023-04-14 18:39:19 +02:00
;; Aquí se encuentran todos los paquetes que tienen como
;; objetivo mejorar el minibuffer de Emacs.
2023-04-14 18:39:19 +02:00
;;; Code:
2023-04-14 18:39:19 +02:00
;; Autocompletado y sugerencias para el minibuffer
(use-package counsel
:defer t
:straight t
:diminish ivy-mode counsel-mode
2023-04-14 18:39:19 +02:00
:bind (("C-s" . swiper-isearch)
("C-r" . counsel-rg)
("M-x" . counsel-M-x)
("<menu>" . counsel-M-x)
2023-04-14 00:30:48 +02:00
;; ("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)
: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)
("<escape>" . minibuffer-keyboard-quit)
:map counsel-find-file-map
("C-h" . counsel-up-directory)
:map swiper-map
("M-%" . swiper-query-replace)
)
:hook ((after-init . ivy-mode)
(ivy-mode . counsel-mode))
:init
(setq enable-recursive-minibuffers t) ; Allow commands in minibuffers
(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-ignore-buffers '("\\` " "\\`\\*tramp/" "\\`\\*xref" "\\`\\*helpful "
"\\`\\*.+-posframe-buffer\\*" "\\` ?\\*company-.+\\*")
ivy-on-del-error-function #'ignore
ivy-initial-inputs-alist nil)
;; Use orderless regex strategy
(setq ivy-re-builders-alist '((t . ivy--regex-ignore-order)))
;; 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'"))
)
2023-04-14 18:39:19 +02:00
;; Integración entre projectile y counsel
(use-package counsel-projectile
:defer t
:straight t
:bind*
("C-x p" . counsel-projectile)
:hook (counsel-mode . counsel-projectile-mode)
:init (setq counsel-projectile-grep-initial-input '(ivy-thing-at-point)))
2023-04-14 18:39:19 +02:00
;; Autocompletado, sugerencias y menú de búsqueda mejorados (este paquete incluye counsel y swiper)
(use-package ivy
:defer t
:straight t
:hook (after-init . ivy-mode)
:config
(setq ivy-use-virtual-buffers nil))
2023-04-14 18:39:19 +02:00
;; Ivy pero con más detalles en pantalla
(use-package ivy-rich
:defer t
:straight 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))
2023-04-14 18:39:19 +02:00
;; Iconos en Ivy usando all-the-icons
(use-package all-the-icons-ivy-rich
:defer t
:straight t
:ensure t
:hook (ivy-mode . all-the-icons-ivy-rich-mode)
:config
(setq all-the-icons-ivy-rich-color-icon t))
2023-04-14 21:43:55 +02:00
;; Ordenar los comandos usados en M-x (por uso y luego alfabéticamente)
(use-package smex
:straight t
:defer t
:after (counsel))
2023-04-14 18:39:19 +02:00
(provide 'init-minibuffer)
;;; init-minibuffer.el ends here