lifepillar / vim-mucomplete

Chained completion that works the way you want!
MIT License
913 stars 18 forks source link

Snipmate compatibility #26

Closed soyuka closed 7 years ago

soyuka commented 7 years ago

For bug reports only, please provide the following details:

First of all, thanks for trying to make vim completion simple and great again.

I want to avoid all those plugins that are not made with vimL, just because they're often a pain to install on a new computer. This is why I prefered SnipMate over UltiSnips (python). The thing is, I can't trigger the snippets, and though you may have a solution.

I don't use any snipmate configuration, I just have the following (using Vundle):

Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'

Should I do something in particular do add the snipmate support? Thanks!

lifepillar commented 7 years ago

Try this:

  let g:mucomplete#user_mappings = { 'snip' : "\<plug>snipMateShow" }
  let g:mucomplete#chains = { 'default': ['snip', 'keyn'] } " For instance
lifepillar commented 7 years ago

I think you also need:

  let g:snipMate['no_match_completion_feedkeys_chars'] = ''
lifepillar commented 7 years ago

Adding this may also be convenient:

imap <expr> <c-j> (pumvisible()?"\<c-y>":"")."\<plug>snipMateNextOrTrigger"

(assuming that the SnipMate's trigger of your choice is <c-j>), because it allows you to expand a snippet without first closing the pop-up menu.

soyuka commented 7 years ago

Nice one, thanks

Just to make sure I understand everything

This adds snippets to the menu:

  let g:mucomplete#user_mappings = { 'snip' : "\<plug>snipMateShow" }
  let g:mucomplete#chains = { 'default': ['snip', 'keyn'] } " For instance

And

imap <expr> <c-j> (pumvisible()?"\<c-y>":"")."\<plug>snipMateNextOrTrigger"

Does expand the snippet with <c-j>. Is there a way to make the tab key to trigger the snippet?

lifepillar commented 7 years ago

Is there a way to make the tab key to trigger the snippet?

Sure:

imap <expr> <tab> (pumvisible()?"\<c-y>":"")."\<plug>snipMateNextOrTrigger"

Note that µcomplete maps <tab> by default, so you should either disable µcomplete's mappings:

let g:mucomplete_no_mappings =1

or map the completion trigger (which by default is <tab>) to something else, e.g.,

imap <c-j> <plug>(MUcompleteFwd)

See also :h mucomplete-mappings.

lifepillar commented 7 years ago

let g:mucomplete_no_mappings =1

Sorry, that should be

let g:mucomplete#no_mappings = 1
soyuka commented 7 years ago

Okay thanks I think I've enough elements to make it work!