ncm2 / ncm2-ultisnips

44 stars 3 forks source link

vimrc example is wrong #11

Open xiamaz opened 5 years ago

xiamaz commented 5 years ago

Current vimrc example will not behave as expected.

Expected behavior

Expansions are triggered with enter key. Tab key will scroll through completion list if configured to do so.

Actual behavior

Expansions are triggered with tab key. Enter key will do nothing.

Fix

In the current example one line is commented out. This needs to be activated to work.

sinetoami commented 5 years ago

@xiamaz Solve part of my issue. But only this still printed a string instead of call the ncm2_ultisnips#expand_or() function. gif1

So, I put this <buffer> argument on <CR> mapping, like:

inoremap <silent> <buffer> <expr> <CR> ncm2_ultisnips#expand_or("\<CR>", 'n')

gif2 And works like a charm.

So, thanks for your tip!

Edit:

I noticed that when I'm inside a project folder, such as a Rails project, the "print string" behavior still persists. What I did was delegate the mapping to a autocmd rule.

autocmd BufNewFile,BufRead * inoremap <silent> <buffer> <expr> <cr> ncm2_ultisnips#expand_or("\<CR>", 'n')

Works great to me. :+1: