diff --git a/nix/modules/completion/default.nix b/nix/modules/completion/default.nix index 45c8d11..f041c8a 100644 --- a/nix/modules/completion/default.nix +++ b/nix/modules/completion/default.nix @@ -29,7 +29,10 @@ let optionals (cfg.backend == "corfu") [ corfu cape - ] ++ optionals (cfg.backend == "company") [ + ] ++ optionals (config.fg42.graphics.enable && cfg.backend == "corfu") [ + nerd-icons-corfu + ] + ++ optionals (cfg.backend == "company") [ company company-box ]); diff --git a/nix/modules/completion/lisp/fg42/completion.el b/nix/modules/completion/lisp/fg42/completion.el index ecda93a..f5a6975 100644 --- a/nix/modules/completion/lisp/fg42/completion.el +++ b/nix/modules/completion/lisp/fg42/completion.el @@ -63,16 +63,41 @@ The current candidates are shown in a popup below or above the point. The candid can be selected by moving up and down. Corfu is the minimalistic in-buffer completion counterpart of the Vertico minibuffer UI." :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-cycle t) ;; Enable cycling for `corfu-next/previous' + (corfu-auto t) ;; Enable auto completion + (corfu-separator ?*) ;; Orderless field separator + (corfu-quit-no-match 'separator) + (corfu-quit-at-boundary 'separator) + (corfu-quit-no-match t) + (corfu-preview-current 'insert) ;; Disable current candidate preview + (corfu-preselect 'first) ;; Preselect the prompt + (corfu-on-exact-match 'insert) ;; Configure handling of exact matches (corfu-scroll-margin 5) ;; Use scroll margin - :hook (emacs-startup . global-corfu-mode))) + (corfu-left-margin-width 2.0) + (corfu-right-margin-width 2.0) + + :bind + (:map corfu-map ("" . corfu-quit)) + (:map corfu-map ("M-SPC" . corfu-insert-separator)) + :hook + (emacs-startup . global-corfu-mode) + (corfu-mode . (lambda () + (require 'corfu-popupinfo) + (require 'corfu-indexed) + + (corfu-popupinfo-mode) + (corfu-indexed-mode) + (dotimes (i 10) + (define-key corfu-mode-map + (kbd (format "M-%s" i)) + (kbd (format "C-%s " i))))))) + + (with-config "graphics" + (use! nerd-icons-corfu + "Nerd icon integration with corfu." + :after corfu + :config + (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)))) ;;;###autoload