Skip to content

Latest commit

 

History

History
74 lines (58 loc) · 2.47 KB

freemacs-corfu.org

File metadata and controls

74 lines (58 loc) · 2.47 KB

Corfu Configuration


Install Corfu

Corfu provides completion in region functions. This will create pop ups with completion options in the buffer.

(use-package corfu
  :straight (:files (:defaults "extensions/*.el"))
  :init
  (global-corfu-mode)
  (corfu-popupinfo-mode)
  :bind
  (:map corfu-map
        ("TAB" . corfu-next)
        ([tab] . corfu-next)
        ("S-TAB" . corfu-previous)
        ([backtab] . corfu-previous))
  :custom
  (corfu-auto t)
  (corfu-cycle t)
  (corfu-preselect 'prompt)
  :config
  <<corfu_config>>
  (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
  (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify))

Unbind RET

Having the “RET” key bound for Corfu becomes very frustrating when trying to enter a newline when the completion window pops up. Unbinding “RET” and using the Tab-and-Go method is preferrable in order to not have to always add an extra space at the end of every line.

(keymap-set corfu-map "RET" `( menu-item "" nil :filter
                               ,(lambda (&optional _)
                                  (and (derived-mode-p 'eshell-mode 'comint-mode)
                                       #'corfu-send))))

Completion by Pressing Tab

Set tab-always-indent variable must be set to complete. This will cause pressing <TAB> once to indent, and twice will cause it to activate completion.

(tab-always-indent 'complete)

End

Tell Emacs what package this file provides.

(provide 'freemacs-corfu)