110 lines
4.0 KiB
EmacsLisp
110 lines
4.0 KiB
EmacsLisp
;;; init-corfu.el --- Autocompletado con corfu -*- lexical-binding: t -*-
|
|
|
|
;; Author: kj <webmaster@outcontrol.net>
|
|
;; URL: https://git.kj2.me/kj/confi-emacs-actual
|
|
|
|
;;; Commentary:
|
|
|
|
;; Archivo de configuración específico para el paquete corfu.
|
|
;; Corfu, de manera resumida, es el que nos muestra el autocompletado
|
|
;; en Emacs, tanto para código como para otro tipo de textos.
|
|
;;
|
|
;; Este paquete viene a ser una alternativa a Company, por lo
|
|
;; que no se deberían activar los 2 al mismo tiempo.
|
|
|
|
|
|
;;; Code:
|
|
|
|
(use-package corfu
|
|
:defer t
|
|
:ensure (:files (:defaults "extensions/*")
|
|
:includes (corfu-info corfu-history))
|
|
:hook ((elpaca-after-init . global-corfu-mode)
|
|
(corfu-mode . corfu-popupinfo-mode))
|
|
:bind (:map corfu-map
|
|
("<tab>" . corfu-quit)
|
|
("<escape>" . corfu-quit)
|
|
("<SPC>" . corfu-insert-separator))
|
|
:custom
|
|
(corfu-auto t)
|
|
:config
|
|
(setq corfu-popupinfo-delay 0
|
|
;; corfu-auto-delay 0.5
|
|
corfu-auto-prefix 1
|
|
corfu-cycle t
|
|
corfu-quit-at-boundary t
|
|
corfu-preview-current nil
|
|
corfu-quit-no-match t)
|
|
(when (< emacs-major-version 29)
|
|
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
|
|
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify))
|
|
(corfu-history-mode 1)
|
|
(savehist-mode 1)
|
|
(add-to-list 'savehist-additional-variables 'corfu-history)
|
|
)
|
|
|
|
;; Cambia la forma de mostrar y buscar sugerencias (afecta a corfu, pero también a otros como vertico).
|
|
(use-package orderless
|
|
:defer t
|
|
:custom
|
|
(completion-styles '(orderless)) ; Use orderless
|
|
(completion-category-defaults nil) ; I want to be in control!
|
|
(setq completion-ignore-case t)
|
|
(completion-category-overrides '((file (styles basic partial-completion orderless))))
|
|
(orderless-matching-styles
|
|
'(orderless-literal
|
|
orderless-prefixes
|
|
orderless-initialism
|
|
orderless-regexp
|
|
orderless-flex ; Basically fuzzy finding
|
|
;; orderless-strict-leading-initialism
|
|
;; orderless-strict-initialism
|
|
;; orderless-strict-full-initialism
|
|
;; orderless-without-literal ; Recommended for dispatches instead
|
|
))
|
|
)
|
|
|
|
|
|
;; Set de funciones de para las sugerencias de corfu.
|
|
(use-package cape
|
|
:defer t
|
|
:ensure (:host github :repo "minad/cape")
|
|
:after corfu
|
|
:bind (("C-c f" . cape-file)
|
|
("C-c l" . cape-line)
|
|
("C-c _" . cape-tex))
|
|
:init
|
|
(setq text-mode-ispell-word-completion nil)
|
|
;; (add-to-list 'completion-at-point-functions #'cape-line) ;; Completar línea actual en función de lo que dice otras líneas de buffer.
|
|
;; (add-to-list 'completion-at-point-functions #'cape-tex) ;; Completar Latex (caracteres unicode).
|
|
(add-to-list 'completion-at-point-functions #'cape-dict) ;; Completar desde un diccionario (por defecto toma el de linux que está en /usr/share/dict/words).
|
|
(add-to-list 'completion-at-point-functions #'cape-dabbrev) ;; Completar desde otras la palabras del buffer.
|
|
(add-to-list 'completion-at-point-functions #'cape-abbrev) ;; Completar desde una abreviaciónes configuradas con add-global-abbrev (añadir abreviación global) o add-mode-abbrev (abreviación para el modo actual).
|
|
(add-to-list 'completion-at-point-functions #'cape-file) ;; Completar rutas de archivos.
|
|
(add-to-list 'completion-at-point-functions #'cape-keyword) ;; Completar desde keyword del lenguaje.
|
|
|
|
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
|
|
)
|
|
|
|
;; Hacer que corfu funcione en la terminal
|
|
(unless (display-graphic-p)
|
|
(use-package corfu-terminal
|
|
:after corfu
|
|
:ensure (:repo "https://codeberg.org/akib/emacs-corfu-terminal.git")
|
|
:config
|
|
(corfu-terminal-mode +1))
|
|
)
|
|
|
|
;; Iconos en corfu
|
|
(use-package kind-icon
|
|
:ensure t
|
|
:after corfu
|
|
:custom
|
|
(kind-icon-default-face 'corfu-default) ; to compute blended backgrounds correctly
|
|
:config
|
|
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
|
|
|
|
|
|
(provide 'init-corfu)
|
|
;;; init-corfu.el ends here
|