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

152 lines
4.6 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)
2023-09-09 07:37:29 +02:00
;; Colocando isearch en otro keybind
("C-S-s" . isearch-forward)
("C-S-r" . isearch-backward)
:map isearch-mode-map
("C-S-s" . isearch-repeat-forward)
("C-S-r" . isearch-repeat-backward)
: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-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-06-23 11:34:43 +02:00
;; nerd-icons en ivy
(use-package nerd-icons-ivy-rich
:defer t
:straight t
:ensure t
2023-06-23 11:34:43 +02:00
: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))
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