-
Notifications
You must be signed in to change notification settings - Fork 181
Description
Hi, I'm the author of nvim-completion-manager (NCM)
Currently NCM uses snipmate for function parameter expansion, and snippets expansions from language server
My current approach is quite hacky
In short, NCM injects the snippet into snipmate. And it remembers to cleanup the injected snippet afterwards.
As discussed in Shougo/neosnippet.vim#398 (comment)
This approach has some disavantages.
- NCM has no control over the priority where there's name collision of snippets
The point where ncm removes the injected snippet is not elegant, yet, I haven't seen the use case where this approach fails.
Here's my proposal:
Things would be a lot easier if a common convension is set up so that snippet engines recognize the v:completed_item.snippet and v:completed_item.snippet_trigger.
- Other auto-completion plugins may integrate with snippet engine more easily.
- And there's no need to cleanup the snippet after completion.
The snippet_trigger is useful, for example, in ncm, the popup menu looks like this when there's a file named datetime.noww. A more complicated situation would be non-parameter-expansion snippets.
from datetime import datetime
now = datetime.now
| now [+] now(cls, tz=None) |
|datetime.noww [ ] ~buf |
The completion items are
[{
'word': 'datetime.now',
'snippet':'now($1)$0',
'snippet_trigger': 'now',
'abbr': ' now'
}, {
'word': 'datetime.noww'
}]
Notice that the now method is left-padded with datetime. to be merged with the items from filepath completion. Without snippet_trigger, the engine may not be able to know it should replace now instead of datetime.now.
This is also related to neovim/neovim#7179, since vim doesn't forward custom field name like snippet and snippet_trigger. Currently ncm also uses some dirty hack to get this to work.