Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: recognize the v:completed_item.snippet and v:completed_item.snippet_trigger for completion snippet expansion #258

Open
roxma opened this issue Sep 1, 2017 · 2 comments
Assignees

Comments

@roxma
Copy link

roxma commented Sep 1, 2017

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.

@ajzafar
Copy link
Collaborator

ajzafar commented Sep 2, 2017

This is something I've wanted to do for a long time actually. I think using a pop up completion menu would be a lot simpler than the current multisnip method, and it'd remove the tlib dependency. I've just been struggling finding time for SnipMate as I started a new job not too long ago. Hopefully I can find some time this Labor Day at the latest.

@prabirshrestha
Copy link

I'm the author of asyncomplete.vim and vim-lsp. I would also be very much interested in this.

@ajzafar ajzafar self-assigned this Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants