Big re-write :)
I reordered the code in a more clean an organized way. Also this improves a lot the emacs startup time again, bucause after some updates it becomes a bit slow with the old configuration, so i did it again in a new way.
This commit is contained in:
125
configs/init-completion.el
Normal file
125
configs/init-completion.el
Normal file
@ -0,0 +1,125 @@
|
||||
;;; init-completion.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:
|
||||
|
||||
;; childframe con los cantidatos de autocompletado
|
||||
(use-package corfu
|
||||
:ensure (:files (:defaults "extensions/*")
|
||||
:includes (corfu-info corfu-history))
|
||||
:hook ((elpaca-after-init . global-corfu-mode)
|
||||
(global-corfu-mode . corfu-popupinfo-mode))
|
||||
:bind (:map corfu-map
|
||||
("<escape>" . corfu-quit)
|
||||
("<SPC>" . corfu-insert-separator))
|
||||
:custom-face
|
||||
(corfu-border ((t (:inherit region :background unspecified))))
|
||||
:custom
|
||||
(corfu-auto t)
|
||||
:config
|
||||
(global-corfu-mode)
|
||||
(setq corfu-popupinfo-delay 0
|
||||
corfu-auto-delay 1
|
||||
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
|
||||
:after corfu
|
||||
: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
|
||||
:ensure (:host github :repo "minad/cape")
|
||||
:after corfu
|
||||
:bind (("C-c c f" . cape-file)
|
||||
("C-c c l" . cape-line))
|
||||
: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")
|
||||
:init
|
||||
(corfu-terminal-mode +1))
|
||||
)
|
||||
|
||||
;; A few more useful configurations...
|
||||
(use-package emacs
|
||||
:ensure nil
|
||||
:custom
|
||||
;; TAB cycle if there are only few candidates
|
||||
;; (completion-cycle-threshold 3)
|
||||
|
||||
;; Enable indentation+completion using the TAB key.
|
||||
;; `completion-at-point' is often bound to M-TAB.
|
||||
(tab-always-indent 'complete)
|
||||
|
||||
;; Emacs 30 and newer: Disable Ispell completion function. As an alternative,
|
||||
;; try `cape-dict'.
|
||||
(text-mode-ispell-word-completion nil)
|
||||
|
||||
;; Emacs 28 and newer: Hide commands in M-x which do not apply to the current
|
||||
;; mode. Corfu commands are hidden, since they are not used via M-x. This
|
||||
;; setting is useful beyond Corfu.
|
||||
(read-extended-command-predicate #'command-completion-default-include-p))
|
||||
|
||||
;; Iconos en corfu
|
||||
(use-package nerd-icons-corfu
|
||||
:after corfu
|
||||
:init (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
|
||||
|
||||
|
||||
(provide 'init-completion)
|
||||
;;; init-completion.el ends here
|
Reference in New Issue
Block a user