minad / cape

🦸cape.el - Completion At Point Extensions
GNU General Public License v3.0
603 stars 22 forks source link

cape-super-capf backends with another "non-merged" backend at the same time question #69

Closed grolongo closed 1 year ago

grolongo commented 1 year ago

Hi, this is not really an issue but more a question about settings.

Basically my question is: what is the correct way to have a cape-super-capf backends list with another backend which is not merged with cape-super-capf? (I didn't find an example in the README)

Let me be more concrete for clarity. Below is what I used for emacs-lisp when using company-mode:

(defun my/emacs-lisp-mode-company ()
  (setq-local company-backends
              '(company-files
                (company-yasnippet company-dabbrev-code company-keywords company-capf))))

Notice how company-files is not merged with the others, I'm basically trying to have the same config with corfu/cape and this is what I've been using:

(defun my/cape-emacs-lisp ()
  (setq-local completion-at-point-functions
              (list (cape-super-capf #'cape-yasnippet #'cape-dabbrev #'elisp-completion-at-point #'cape-keyword #'cape-symbol)))
  (add-to-list 'completion-at-point-functions #'cape-file))

If I'm using a cape-super-capf without the add-to-list cape-file line like above, in emacs-lisp-mode I'm not getting any completion even in strings or comments (like it is by default without any config). But with add-to-list cape-file now I can have path completion even outside strings and comments too.

Is this the proper/intended way to configure it? Or am I going to find weird bugs in the future?

Out-of-topic suggestion but I didn't want to open a new thread just for this:
Company has a nice lighter in the mode line that tells you which backend the candidate is coming from when you're selecting one in the completion UI. Like company-<dabbrev>, company-<capf> etc. Is this something that could be implemented with corfu/cape?

Anyway thanks a lot for your package and the whole others from the minad's family that I'm using daily.

minad commented 1 year ago

I am sorry, I am not answering questions regarding cape-super-capf. Don't use it if you are not sure about how it works. See the README:

Cape supports merging multiple Capfs using the function cape-super-capf. This feature is experimental and should only be used in special scenarios. Don’t use cape-super-capf if you are not 100% sure that you need it!

This function is experimental. I mean it.

minad commented 1 year ago

I forgot to answer this question (a separate issue may have been better):

Company has a nice lighter in the mode line that tells you which backend the candidate is coming from when you're selecting one in the completion UI. Like company-, company- etc. Is this something that could be implemented with corfu/cape?

One could store the name of the Capf when Corfu completion is started. Maybe it is possible to implement this as a Corfu extension. I think it doesn't really fit into Corfu itself, which aims to be minimal. Tbh I find the feature a bit unnecessary. The mode line is too noisy anyway and I disable most lighters - of course only a preference of mine.

grolongo commented 1 year ago

Tbh I find the feature a bit unnecessary. The mode line is too noisy anyway and I disable most lighters - of course only a preference of mine.

I agree, I do also disable all the static lighters with :delight and only keep the ones that produce live information like company, flymake and erc-mode. Anyway the backend is sometimes mentioned at the right of the completion UI like for dabbrev but for other backends it's not, that's why I suggested this. But yea not a mandatory feature at all.