diff options
author | Alan Pearce | 2023-09-17 18:55:27 +0200 |
---|---|---|
committer | Alan Pearce | 2023-09-17 18:55:27 +0200 |
commit | 150411927c8e490303a6415e6d82086defaf48cc (patch) | |
tree | 5f104418bbdeffb914f721c683fac1d9250e7874 /user | |
parent | b650fde62cdef9adb55db636ce16aa2120277d55 (diff) | |
download | nixfiles-150411927c8e490303a6415e6d82086defaf48cc.tar.lz nixfiles-150411927c8e490303a6415e6d82086defaf48cc.tar.zst nixfiles-150411927c8e490303a6415e6d82086defaf48cc.zip |
Emacs: replace company with corfu
Diffstat (limited to 'user')
-rw-r--r-- | user/emacs/init.el | 82 | ||||
-rw-r--r-- | user/settings/emacs.nix | 8 |
2 files changed, 34 insertions, 56 deletions
diff --git a/user/emacs/init.el b/user/emacs/init.el index 9317968a..279fd4b0 100644 --- a/user/emacs/init.el +++ b/user/emacs/init.el @@ -404,7 +404,8 @@ _p_rev _u_pper _=_: upper/lower _r_esolve :demand t :config (progn (setq evil-collection-magit-use-y-for-yank nil - evil-collection-want-company-extended-keybindings t) + evil-collection-corfu-key-themes '(tab-n-go + magic-return)) (general-unbind 'normal magit-mode-map "<escape>") (evil-collection-init))) @@ -520,48 +521,38 @@ _p_rev _u_pper _=_: upper/lower _r_esolve ;;; Completion -(use-package company - :defer 2 - :commands (company-explicit-action-p) +(use-package corfu + :defer 1 :config (progn - (setq company-idle-delay 0.2 - company-tooltip-align-annotations t - company-show-quick-access t - company-dabbrev-downcase nil - company-dabbrev-ignore-case nil - company-begin-commands '(self-insert-command) - company-insertion-on-trigger #'company-explicit-action-p - company-insertion-triggers '(?\ ?\( ?\) ?.)) - (global-company-mode +1)) - :general - (:states 'insert - "TAB" #'company-indent-or-complete-common - "C-x C-f" #'company-files) - (:keymaps 'company-active-map - "TAB" #'company-complete-common-or-cycle - "<tab>" #'company-complete-common-or-cycle - "C-j" nil - "<M-tab>" #'company-other-backend - "<C-tab>" #'company-other-backend - "S-TAB" #'company-select-previous - "<backtab>" #'company-select-previous)) - -(use-package company-posframe - :after company + (global-corfu-mode +1) + (setq corfu-auto t + corfu-auto-delay 0.1 + corfu-auto-prefix 3) + (defun corfu-enable-in-minibuffer () + "Enable Corfu in the minibuffer if `completion-at-point' is bound." + (when (where-is-internal #'completion-at-point (list (current-local-map))) + (setq-local corfu-auto nil) ;; Enable/disable auto completion + (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup + corfu-popupinfo-delay nil) + (corfu-mode 1))) + (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer) + (add-hook 'eshell-mode-hook (lambda () + (setq-local corfu-auto nil) + (corfu-mode +1))))) + +(use-package cape + :after (corfu) + :general (:states 'insert + "c-x c-f" #'cape-file)) + +(use-package kind-icon + :after (corfu) :config (progn - (when (display-graphic-p) - (company-posframe-mode +1)))) - -(use-package company-shell - :after company - :config (progn - (setq company-shell-clean-manpage t) - (add-to-list 'company-backends '(company-shell company-shell-env)))) + (setq kind-icon-default-face 'corfu-default) + (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))) (use-package tabnine - :after (company) :config (progn - (delq 'company-preview-if-just-one-frontend company-frontends) (setq tabnine-binaries-folder "~/.local/tabnine") (global-tabnine-mode) @@ -680,14 +671,6 @@ _p_rev _u_pper _=_: upper/lower _r_esolve :commands (eshell-toggle) :general ("C-`" #'eshell-toggle)) -(use-package capf-autosuggest - :after eshell - :general (:keymaps 'capf-autosuggest-active-mode-map - "C-e" #'capf-autosuggest-end-of-line - "<right>" #'capf-autosuggest-end-of-line) - :ghook ('(eshell-mode-hook - comint-mode-hook))) - (declare-function eshell-push-command "esh-buf-stack" (CMD)) (defun my-bind-esh-push () (general-define-key @@ -1045,7 +1028,6 @@ _p_rev _u_pper _=_: upper/lower _r_esolve haskell-mode-hook) #'eglot-ensure) :config (progn - (add-to-list 'eglot-stay-out-of 'company) (defun my/setup-eglot-eldoc () (push 'flymake-eldoc-function eldoc-documentation-functions)) (add-hook 'eglot-managed-mode-hook 'my/setup-eglot-eldoc) @@ -1066,12 +1048,10 @@ _p_rev _u_pper _=_: upper/lower _r_esolve :ghook ('(feature-mode-hook js2-mode-hook json-mode-hook typescript-mode-hook) #'add-node-modules-path)) (use-package tide - :after (typescript-mode company flycheck) + :after (typescript-mode flycheck) :ghook ('typescript-mode-hook #'tide-setup) :init (progn - (setq tide-completion-setup-company-backend nil) - (flycheck-add-next-checker 'javascript-tide 'javascript-eslint) - (company-set-secondary-backend-for-mode typescript-mode 'company-tide))) + (flycheck-add-next-checker 'javascript-tide 'javascript-eslint))) ;;;; Reformat on save diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix index 7e1884ff..09cdc04a 100644 --- a/user/settings/emacs.nix +++ b/user/settings/emacs.nix @@ -81,13 +81,10 @@ in auto-sudoedit avy benchmark-init - capf-autosuggest + cape clojure-mode cask-mode - company - company-posframe - company-shell - company-tabnine + corfu consult consult-dir consult-ghq @@ -138,6 +135,7 @@ in just-mode justl json-mode + kind-icon lua-mode lispy lispyville |