Files
.emacs.d/lisp/init-completion.el

71 lines
1.6 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.25))
;; 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
;; lua
(use-package lua-ts-mode
:mode ("\\.lua\\'" . lua-ts-mode)
:config
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-ts-mode)))
;; tree-sitter
(use-package treesit-auto
:demand t
:config
(setq treesit-auto-install 'prompt)
(global-treesit-auto-mode)
(setq treesit-font-lock-level 4))
(provide 'init-completion)