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

146 lines
4.5 KiB
EmacsLisp

;;; 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:
;; Aquí se encuentran todos los paquetes que tienen como
;; objetivo mejorar el minibuffer de Emacs.
;;; Code:
;; Autocompletado y sugerencias para el minibuffer
(use-package counsel
:defer t
:straight t
:diminish ivy-mode counsel-mode
:bind (("C-s" . swiper-isearch)
("C-r" . counsel-rg)
("M-x" . counsel-M-x)
("<menu>" . counsel-M-x)
;; ("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'"))
)
;; 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)))
;; 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))
;; 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))
;; nerd-icons en ivy
(use-package nerd-icons-ivy-rich
:defer t
:straight t
:ensure t
:hook (after-init . nerd-icons-ivy-rich-mode))
;; nerd-icons en ibuffer
(use-package nerd-icons-ibuffer
:straight t
: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
:straight t
:defer t
:after (counsel))
(provide 'init-minibuffer)
;;; init-minibuffer.el ends here