elken / yasnippet-capf

Completion-At-Point Extension for YASnippet
GNU General Public License v3.0
40 stars 9 forks source link

Fix for not expanding snippets #22

Closed thorstengrothe closed 4 months ago

thorstengrothe commented 4 months ago

This fix refers to my issue Completions are nil.

In the meantime I found the problem. It is not enough to register yasnippet-capf with

:init
(add-to-list 'completion-at-point-functions #'yasnippet-capf)

One must write it in a hook, like so

 (defun my-cape-capf-setup-latex ()
    (let ((result))
      (dolist (element '(yasnippet-capf) result)
        (add-to-list 'completion-at-point-functions element))))

and register it undercape for the equivalent modes:

(use-package cape
  :ensure t
  :after corfu
  :hook
  (emacs-lisp-mode . my-cape-capf-setup-latex)
  ....)

I guess this should be mentioned in the docs. Now it works perfectly for me :-)

elken commented 4 months ago

Your hook is very unnecessary code-wise, you just need the add-to-list call. Sounds like you might have something else that updates the list of functions, but sure I'll add a doc note about maybe needing a hook.

It looks like you're registering it under :init, you should be using :config as per the README :smile: