Closed casprwang closed 6 years ago
Don't use inoremap for <CR>
mapping
I can reproduce using inoremap <expr> <CR> ncm2_snipmate#expand_or("\<CR>")
You should use imap.
Humm, I didn't use inoremap
, you can check my vimrc here, am I missing something?
I have just pushed an update. The behavior should be more clear with inoremap.
" Press enter key to trigger snippet expansion
" The parameters are the some as `:help feedkeys()`
inoremap <silent> <expr> <CR> ncm2_snipmate#expand_or("\<CR>", 'n')
" 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"
Hi Rox,
Appreciate you quick response. I updated the plugin and vimrc, but the behavior of <cr>
changed to add a new line without expanding snippet.
For reproduction
" autosompletion
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2' "{{{
" supress the annoying 'match x of y', 'The only match' and 'Pattern not
" found' messages
set shortmess+=c
" CTRL-C doesn't trigger the InsertLeave autocmd . map to <ESC> instead.
inoremap <c-c> <ESC>
" When the <Enter> key is pressed while the popup menu is visible, it only
" hides the menu. Use this mapping to close the menu and also start a new
" line.
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" wrap existing omnifunc
" Note that omnifunc does not run in background and may probably block the
" editor. If you don't want to be blocked by omnifunc too often, you could add
" 180ms delay before the omni wrapper:
" 'on_complete': ['ncm2#on_complete#delay', 180,
" \ 'ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
au User Ncm2Plugin call ncm2#register_source({
\ 'name' : 'css',
\ 'priority': 9,
\ 'subscope_enable': 1,
\ 'scope': ['css','scss'],
\ 'mark': 'css',
\ 'word_pattern': '[\w\-]+',
\ 'complete_pattern': ':\s*',
\ 'on_complete': ['ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
\ })
" enable ncm2 for all buffer
autocmd BufEnter * call ncm2#enable_for_buffer()
" note that must keep noinsert in completeopt, the others is optional
set completeopt=noinsert,menuone,noselect
"}}}
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-tmux'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi'
Plug 'ncm2/ncm2-tern', {'do': 'npm install'}
Plug 'ncm2/ncm2-html-subscope'
" snippets
" based on snipmate
Plug 'ncm2/ncm2-snipmate'
" snipmate dependencies
Plug 'tomtom/tlib_vim'
Plug 'marcweber/vim-addon-mw-utils'
Plug 'garbas/vim-snipmate' "{{{
" Press enter key to trigger snippet expansion
" The parameters are the some as `:help feedkeys()`
inoremap <silent> <expr> <CR> ncm2_snipmate#expand_or("\<CR>", 'n')
" 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"
"}}}
That's the expected behavior for for
completion. There's no snippet associated with this completion.
If the completion is expandable, you will see a [+]
sign in the completion menu field.
Ahhhh, Got it. I was thinking too much. Thanks!!!
I hit
for<tab><cr>
, with the configuration from readme.