Files
.emacs.d/lisp/init-completion.el
andsy10 aa4dea523e style(config): Reformat Emacs Lisp code for consistency
Standardize formatting across multiple init files: expand
single-line use-package keywords onto separate lines, fix
indentation, remove outdated comments, and clean up whitespace. Also
adds mc/keymap <return> binding and improves fcitx5 startup logic in
EXWM.
2026-05-11 03:40:06 +08:00

98 lines
3.0 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;;; init-completion.el --- completion config -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; eglot
(use-package eglot
:hook
((python-mode . eglot-ensure)
;; (scheme-mode . eglot-ensure)
)
:config
(setq eglot-send-changes-idle-time 0.25)
(add-to-list 'eglot-server-programs
'(scheme-mode . ("guile-lsp-server")))
;; 在scheme模式禁用eglot补全保留其他功能
(add-hook 'eglot-managed-mode-hook
(lambda ()
(when (derived-mode-p 'scheme-mode)
(setq-local completion-at-point-functions
(remq 'eglot-completion-at-point
completion-at-point-functions))))))
;; corfu
(use-package corfu
:autoload
(corfu-quit consult-completion-in-region)
:functions
(persistent-scratch-save)
:custom
(corfu-auto t)
(corfu-auto-prefix 2)
(corfu-count 12)
(corfu-preview-current nil)
(corfu-on-exact-match nil)
(corfu-auto-delay 0.2)
(corfu-popupinfo-delay '(0.4 . 0.2))
(global-corfu-modes '((not erc-mode
circe-mode
help-mode
gud-mode
vterm-mode)
t))
:init
(global-corfu-mode)
(corfu-popupinfo-mode)
(corfu-history-mode)
:config
;;Quit completion before saving
(add-hook 'before-save-hook #'corfu-quit)
(advice-add #'persistent-scratch-save :before #'corfu-quit)
:bind
(:map corfu-map
("RET" . nil)))
;; 在eshell中使用tab打开补全
(add-hook 'eshell-mode-hook
(lambda ()
(setq-local corfu-auto nil)
(local-set-key (kbd "TAB") 'completion-at-point)))
(use-package emacs
:custom
(tab-always-indent 'complete)
;; Emacs 30 and newer: Disable Ispell completion function.
;; Try `cape-dict' as an alternative.
(text-mode-ispell-word-completion nil)
;; 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))
;; cape
(use-package cape
:commands (cape-file cape-elisp-block cape-keyword)
:autoload (cape-wrap-noninterruptible cape-wrap-nonexclusive cape-wrap-buster)
:autoload (cape-wrap-silent)
:init
;; (add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-elisp-block)
(add-to-list 'completion-at-point-functions #'cape-keyword)
;; (add-to-list 'completion-at-point-functions #'cape-abbrev)
;; Make these capfs composable.
(advice-add 'comint-completion-at-point :around #'cape-wrap-nonexclusive)
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
(advice-add 'eglot-completion-at-point :around #'cape-wrap-nonexclusive)
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-nonexclusive))
(provide 'init-completion)
;;; init-completion.el ends here