snippets using the same key don't get all listed
Closed this issue · 6 comments
Hi, thanks for this package, helpful to use instead of relying on a capf translation.
If you don't mind I've noticed a single issue: if I have multiple snippets with the same key, only the first one gets listed during completion. Do you know why?
Surely I could rename my snippets foo
, foo2
, foo3
... and stop bothering you, but I didn't have that small issue with company.
Also, off-topic but do you plan to release your package on Melpa? (very fine if you want to keep it for yourself)
Anyway have a good day/night.
Interesting, I'll have a look into this.
Also, off-topic but do you plan to release your package on Melpa? (very fine if you want to keep it for yourself)
When it's more done, yeah maybe even upstreamed into cape but for now it's just testing. Hence no readme or anything
Hi, I tested your latest commit version ba7ff80 but I still have the same problem.
Just to make it clear about what I'm speaking of, I'll give you an example:
In emacs-lisp-mode
, I have two add-hook
snippets, one with and without lambda, defined like this:
# name: add-hook simple form
# key: add-hook
# --
(add-hook '$1-hook '$2-mode)
# name: add-hook form with lambda
# key: add-hook
# --
(add-hook '$1-hook (lambda () ($2)))
As you can see, both share the same key, and this is how they are displayed with company-mode
:
Now with version 0.0.3
of cape-yasnippet
and corfu
:
If I expand it it's choosing the first add-hook
snippet definition and doesn't propose me the second one.
Did you read the commit message and set the relevant variable?
Apologizes. Working good. Thank you!
Apologizes. Working good. Thank you!
No need for apologies :) Glad it's working for you!
Just found out, if someone still desires to use 'key
instead of 'name
and he has multiple snippets with the same # key
(as in my initial problem), he can use YASnippet's # uuid
attribute. Quick example:
# uuid: 1d1c72ad-b1f2-48op-958a-6d87g2ccb477
# key: printf
# name: insert printf with newline
# --
printf "$1\n"
# uuid: 9h4d22ad-r1g6-48af-908a-6d33d2ccb407
# key: printf
# name: insert printf with redirect
# --
printf "$1\n" >> $2
Having different # uuid
fixes the problem. One can generate uuids from the command line with uuidgen
(installed by default on most distros, macOS, Ubuntu, etc.), but you can use whatever like # uuid: foo
and # uuid: bar
as long as it's different.