roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

TODO: integrate with ultisnips for completions with snippet #36

Closed roxma closed 7 years ago

roxma commented 7 years ago

For example:

def foobar(param1,param2)
  pass

foobar|

| is the cursor position after foobar is completed by NCM, then press ultisnips expand trigger should expand the completion into

def foobar(param1,param2)
  pass

foobar(|<param1>,<param2>)

I'm not sure whether this is possible but it's worth a try

roxma commented 7 years ago

Ultisnips is kind of heavy and complicated for me.

So I started looking into neosnippet by @Shougo. It's more lightweight and easier to integrate, since it has been integrated in neocomplete already. Although I don't enjoy the display of '<2:foo:>' placeholder. It's simple, and it works well.

Requirement: installation of neosnippet and let g:neosnippet#enable_completed_snippet=1 Here's a screencast for python completion and expansion:

A + sign means the completion item is expandable.

soutput

This feature is still experimental.

Besides, the syntax of neosnippet by @Shougo and snipmate maintained by @garbas seems to be compatible at some level.

I'll look into snipmate as another alternative when I have some free time available.

roxma commented 7 years ago

Just take a deeper look into ultisnips, now it works with ultisnips, :smile:

output

roxma commented 7 years ago

Closing this, snipmate support may be implemented in the future. But this is not high priority.

roxma commented 7 years ago

snipmate is supported now

output

config:

    let g:snips_no_mappings = 1 
    " imap <expr> <c-u> pumvisible() ? "\<c-y>\<Plug>snipMateTrigger" : "\<Plug>snipMateTrigger"
    " wrap the mapping
    imap <expr> <Plug>(snipmate_force_trigger) pumvisible() ? "\<c-y>\<Plug>snipMateTrigger" : "\<Plug>snipMateTrigger"
    " show a list of snippets when no the user has typed nothing
    inoremap <silent> <c-u> <c-r>=cm#sources#snipmate#trigger_or_popup("\<Plug>(snipmate_force_trigger)")<cr>
    vmap <c-u> <Plug>snipMateTrigger
    imap <expr> <c-j> pumvisible() ? "\<c-y>\<Plug>snipMateNextOrTrigger" : "\<Plug>snipMateNextOrTrigger"
    vmap <c-j> <Plug>snipMateNextOrTrigger
    imap <expr> <c-k> pumvisible() ? "\<c-y>\<Plug>snipMateBack" : "\<Plug>snipMateBack"
    vmap <c-k> <Plug>snipMateBack

// cc @ajzafar @garbas

Battleroid commented 7 years ago

Does anything special need to be done in order to get snippets provided by Ultisnips to expand?

roxma commented 7 years ago

@Battleroid

No. This issue is about parameter expansion.

roxma commented 7 years ago

@battleroid I’m not sure what you need. But this might be useful. https://github.com/roxma/nvim-completion-manager/issues/89

Battleroid commented 7 years ago

Thank you, I'll poke at it.