From ed50afc6a8b01f3f766e11b76f06f6d0b8d33d71 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Sat, 19 Mar 2022 23:59:32 +0800 Subject: Use corfu to complete in emacs gui --- .emacs.d/lisp/init-company.el | 3 ++- .emacs.d/lisp/init-corfu.el | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .emacs.d/lisp/init-corfu.el (limited to '.emacs.d/lisp') diff --git a/.emacs.d/lisp/init-company.el b/.emacs.d/lisp/init-company.el index 58e4de4..12e409e 100644 --- a/.emacs.d/lisp/init-company.el +++ b/.emacs.d/lisp/init-company.el @@ -1,5 +1,6 @@ (when (gx/maybe-require-package 'company) - (add-hook 'after-init-hook 'global-company-mode)) + (when (not (display-graphic-p)) + (add-hook 'after-init-hook 'global-company-mode))) (with-eval-after-load 'company (company-tng-configure-default) diff --git a/.emacs.d/lisp/init-corfu.el b/.emacs.d/lisp/init-corfu.el new file mode 100644 index 0000000..fb92857 --- /dev/null +++ b/.emacs.d/lisp/init-corfu.el @@ -0,0 +1,25 @@ +;; -*- lexical-binding: t; -*- + +(when (gx/maybe-require-package 'corfu) + (autoload 'corfu-mode "corfu") + (when (display-graphic-p) + (add-hook 'prog-mode-hook #'corfu-mode))) + +(setq corfu-cycle t + corfu-auto t + corfu-quit-no-match t + corfu-preselect-first nil) + +(with-eval-after-load 'corfu + (define-key corfu-map (kbd "TAB") 'corfu-next) + (define-key corfu-map (kbd "") 'corfu-next) + (define-key corfu-map (kbd "S-TAB") 'corfu-previous) + (define-key corfu-map (kbd "") 'corfu-previous)) + +(when (gx/maybe-require-package 'orderless) + (setq completion-styles '(orderless) + completion-category-defaults nil + completion-category-overrides + '((file (styles . (partial-completion)))))) + +(provide 'init-corfu) -- cgit v1.2.3