ncm2 / ncm2-snipmate

3 stars 0 forks source link
ncm2-plugin ncm2-snippet

snipMate integration for ncm2.

rec

Features

Reaurements

Install

" based on snipmate
Plug 'ncm2/ncm2-snipmate'

" snipmate dependencies
Plug 'tomtom/tlib_vim'
Plug 'marcweber/vim-addon-mw-utils'
Plug 'garbas/vim-snipmate'

Vimrc Example

" Press enter key to trigger snippet expansion
" The parameters are the same as `:help feedkeys()`
inoremap <silent> <expr> <CR> ncm2_snipmate#expand_or("\<CR>", 'n')

" wrap <Plug>snipMateTrigger so that it works for both completin and normal
" snippet
" inoremap <expr> <c-u> ncm2_snipmate#expand_or("\<Plug>snipMateTrigger", "m")

" c-j c-k for moving in snippet
let g:snips_no_mappings = 1
vmap <c-j> <Plug>snipMateNextOrTrigger
vmap <c-k> <Plug>snipMateBack
imap <expr> <c-k> pumvisible() ? "\<c-y>\<Plug>snipMateBack" : "\<Plug>snipMateBack"
imap <expr> <c-j> pumvisible() ? "\<c-y>\<Plug>snipMateNextOrTrigger" : "\<Plug>snipMateNextOrTrigger"

:help snipMate for more information on using snipMate.

API

If you need more control over the completed item's snippet expansion, you might need these two APIs to help program your key mapping.

ncm2_snipmate#completed_is_snippet()

Checks whether the v:completed_item is also a snippet.

<Plug>(ncm2_snipmate_expand_completed)

Use this key to expand the completed snippet.