From 36a4a9c122ca98d58c0d8abb890cf475dc86e90f Mon Sep 17 00:00:00 2001 From: Mark van der Putten Date: Wed, 17 Jul 2024 00:49:42 +0200 Subject: [PATCH] Add corfu autocompletion --- elisp/init-completion.el | 53 ++++++++++++++++++++++++++++++++++++++++ init.el | 2 ++ 2 files changed, 55 insertions(+) create mode 100644 elisp/init-completion.el diff --git a/elisp/init-completion.el b/elisp/init-completion.el new file mode 100644 index 0000000..878f672 --- /dev/null +++ b/elisp/init-completion.el @@ -0,0 +1,53 @@ +;;; init-completion.el --- -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + + +(use-package corfu + ;; Optional customizations + ;; :custom + ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + ;; (corfu-auto t) ;; Enable auto completion + ;; (corfu-separator ?\s) ;; Orderless field separator + ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary + ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match + ;; (corfu-preview-current nil) ;; Disable current candidate preview + ;; (corfu-preselect 'prompt) ;; Preselect the prompt + ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches + ;; (corfu-scroll-margin 5) ;; Use scroll margin + + ;; Enable Corfu only for certain modes. + ;; :hook ((prog-mode . corfu-mode) + ;; (shell-mode . corfu-mode) + ;; (eshell-mode . corfu-mode)) + + ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can + ;; be used globally (M-/). See also the customization variable + ;; `global-corfu-modes' to exclude certain modes. + :config + (global-corfu-mode 1)) + + +;; (use-package corfu +;; ;;:ensure (:files (:defaults "extensions/*")) +;; :demand t ; need this when using :bind or :hook +;; :config +;; (global-corfu-mode 1) +;; :custom +;; (corfu-auto t) +;; (corfu-auto-delay 0.5) +;; (corfu-quit-no-match t) ; quit when the popup appears and I type anything else +;; ;; Might want to customize corfu-sort-function +;; ;; :bind +;; ;; (("M-RET" . completion-at-point) +;; ;; ) +;; ) + + +;; Nice icons for corfu popups +(use-package kind-icon + :after corfu + :config + (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) + +(provide 'init-completion) diff --git a/init.el b/init.el index 064249f..82bf0f0 100644 --- a/init.el +++ b/init.el @@ -127,6 +127,8 @@ If you experience freezing, decrease this. If you experience stuttering, increa (require 'init-syntax) (require 'init-parens) +(require 'init-completion) + ;;; (require 'init-indent) ;;; (require 'init-quickrun)