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/init.el | 1 + .emacs.d/lisp/init-company.el | 3 ++- .emacs.d/lisp/init-corfu.el | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .emacs.d/lisp/init-corfu.el diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 22c9e7f..8fad1fc 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -22,6 +22,7 @@ (require 'init-evil) (require 'init-minibuffer) (require 'init-company) +(require 'init-corfu) (require 'init-flycheck) (require 'init-org) (require 'init-lang) 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