minad / corfu

:desert_island: corfu.el - COmpletion in Region FUnction
GNU General Public License v3.0
1.15k stars 43 forks source link

[Question][Help] Configuration #297

Closed deb75 closed 1 year ago

deb75 commented 1 year ago

Hello,

First of all, thanks for your nice packages (corfu and cape).

I currently experience some difficulties to configure them, even after having gone through the wiki/readme.

Here is my configuration :


(use-package corfu
  :custom
  (corfu-cycle t)
  (corfu-auto t)
  (corfu-auto-prefix 2)
  ;; (corfu-auto-delay 0)
  (corfu-separator ?\s)
  (corfu-quit-at-boundary 'separator)
  (corfu-quit-no-match 'separator)
  (corfu-preview-current 'insert)
  (corfu-preselect 'prompt)
  (corfu-on-exact-match nil)
  (corfu-scroll-margin 2)
  (corfu-preselect-first nil)
  :init
  (global-corfu-mode)
  (corfu-echo-mode)
  (corfu-history-mode))

(add-hook 'eshell-mode-hook
          (lambda ()
            (setq-local corfu-quit-at-boundary t
                        corfu-quit-no-match t
                        corfu-auto nil)
            (corfu-mode)))

;; Add extensions
(use-package cape
  :bind (("C-c q" . completion-at-point))
  :init
  (add-to-list 'completion-at-point-functions #'cape-dabbrev)
  (add-to-list 'completion-at-point-functions #'cape-file)
  (add-to-list 'completion-at-point-functions #'cape-keyword)
  (add-to-list 'completion-at-point-functions #'cape-tex)
  ;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
  ;;(add-to-list 'completion-at-point-functions #'cape-ispell)
  ;;(add-to-list 'completion-at-point-functions #'cape-dict)
  (add-to-list 'completion-at-point-functions #'cape-symbol)
  (add-to-list 'completion-at-point-functions #'cape-line)
)

(use-package company)

(require 'company-math)
(add-to-list 'company-backends 'company-math-symbols-unicode)
(add-to-list 'company-backends 'company-math-symbols-latex)

(setq-local completion-at-point-functions
  (mapcar #'cape-company-to-capf
    (list #'company-math-symbols-unicode #'company-math-symbols-latex)))

It does work, almost too well.

In an org file, when I enter just two letters, I am immediately proposed several matches which appear to be lines from the current buffer and even other org buffers !

In an elisp file, when I try to enter (setq comp sty...), I am not proposed anything with documentation popups (it says no match).

As advocated, I also configure cape, but it is not clear for me how it interacts with corfu. There are many completion providers. Which one is is used when I trigger completion ? How can I switch from one to another ?

WIth company I used to set locally the backends depending on the file major mode, is it possible with cape or corfu ?

I also tried to incorporate some company backends, it does not appear to work, I cannot see the usual matches when I hit "\" in a latex math environment.

There are also some small conflicts. In an org/tex file, I used to enter "equ[space]" and it writes a equation latex math template for me. With corfu enabled, once I entered "equ" I am proposed all sort of candidates and it is difficult to exit from corfu.

Could you help me to adjust my configuration to make corfu more usable ?

Regards

minad commented 1 year ago

Note that this is primarily an issue tracker. Unfortunately it exceeds my bandwidth to support configuration issues. Please try to figure out a solution based on the information in the corfu/cape READMEs and the wikis. My recommendation is to start small. Do not adjust all the configuration right away. It is mostly unnecessary, since the Corfu defaults are reasonable.