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

131 lines
4.0 KiB
EmacsLisp
Raw Normal View History

2022-11-19 04:33:22 +01:00
;;; init-ivy.el --- Ayuditas y autocompletado del minibufer -*- lexical-binding: t -*-
;; Author: kj <webmaster@outcontrol.net>
;; URL: https://git.kj2.me/kj/confi-emacs-actual
;;; Commentary:
;;; Code:
;; Autocompletado para el minibuffer (counsel e ivy)
(use-package counsel
:defer t
:straight t
:diminish ivy-mode counsel-mode
:bind (("C-s" . swiper-isearch)
("C-r" . counsel-rg)
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'"))
)
;; Autocompletado de proyectos en counsel (projectile)
(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)))
(use-package ivy
:defer t
:straight t
:hook (after-init . ivy-mode)
:config
(setq ivy-use-virtual-buffers nil))
(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))
;; Iconos en Ivy (allthe 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))
2022-11-19 04:33:22 +01:00
(provide 'init-ivy)
;;; init-ivy.el ends here