aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-03-19 23:59:32 +0800
committerGuangxiong Lin <[email protected]>2022-03-19 23:59:32 +0800
commited50afc6a8b01f3f766e11b76f06f6d0b8d33d71 (patch)
tree8cbe042c2eef6c1f6d7b5ac80cbbf5c5f96b1a56 /.emacs.d/lisp
parent1f5be956ef77ebaaf425bc7a4de5a49f5a8e63ca (diff)
downloaddotfiles-ed50afc6a8b01f3f766e11b76f06f6d0b8d33d71.tar.gz
dotfiles-ed50afc6a8b01f3f766e11b76f06f6d0b8d33d71.tar.bz2
dotfiles-ed50afc6a8b01f3f766e11b76f06f6d0b8d33d71.zip
Use corfu to complete in emacs gui
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-company.el3
-rw-r--r--.emacs.d/lisp/init-corfu.el25
2 files changed, 27 insertions, 1 deletions
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 "<tab>") 'corfu-next)
+ (define-key corfu-map (kbd "S-TAB") 'corfu-previous)
+ (define-key corfu-map (kbd "<backtab>") '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)