Files
.emacs.d/lisp/init-completion.el
2026-03-15 14:29:20 +08:00

57 lines
1.3 KiB
EmacsLisp

;;; init-completion.el
;;; -*- lexical-binding: t -*-
;; eglot
(use-package eglot
:hook ((python-mode . eglot-ensure))
:config
(setq eglot-send-changes-idle-time 0.5))
;; corfu
(use-package corfu
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
:init
(global-corfu-mode)
(corfu-history-mode)
(corfu-popupinfo-mode)
(corfu-echo-mode)
:custom
(corfu-popupinfo-delay 0.5)
(corfu-auto t)
: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
:init
(add-to-list 'completion-at-point-functions #'cape-file) ;; 文件补全
(setq-local completion-at-point-functions
(list (cape-capf-super #'cape-dabbrev)))) ;; 启用dabbrev
(provide 'init-completion)