How to map two actions to a single key in select mode (UltiSnips and neosnippet Integration)

396 Views Asked by At

I am trying to use UltiSnips and neosnippet plugins simultaneously because of some features that the one has and the other doesn'nt and vice versa. So Mapped Ultisnips and neosnippet like the following :

"UltiSnips
let g:UltiSnipsExpandTrigger="<Tab>"
let g:UltiSnipsJumpForwardTrigger="<Tab>"
let g:UltiSnipsJumpBackwardTrigger="<S-Tab>"`

and

"neosnippet
imap <C-b> <Plug>(neosnippet_expand_or_jump)
smap <C-b> <Plug>(neosnippet_expand_or_jump)
xmap <C-b> <Plug>(neosnippet_expand_target)

everything works fine, until i decide to make a superTab that do the jumping in both plugins select mode with hitting Tab key. jumping in UltiSnip is done with Tab key by means of the following map that sets by plugin itself:

exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>"

so i can jump with Tab key in select mode seamlessley. For the neosnippet to jump in select mode with tab key i change the smap like this :

smap <Tab> <Plug>(neosnippet_expand_or_jump)

but this does not work and its natural because UltiSnips maps its keys after neosnippet plugin; so i change the mapping to:

au InsertEnter * exec "smap " . g:UltiSnipsExpandTrigger . " <Plug>(neosnippet_expand_or_jump)"

But now i can jump in neosnippet expanded snippets with tab key in select mode and cant jump in UltiSnips snippets. so my question is how can accomplish this?

i tried :

au InsertEnter * exec "smap " . g:UltiSnipsExpandTrigger . " neosnippet#expandable_or_jumpable() ? '\<Plug>(neosnippet_expand_or_jump)' : '\<Esc>:call "UltiSnips#ExpandSnippetOrJump()<cr>'"

and

au InsertEnter * exec "smap " . g:UltiSnipsExpandTrigger . " exists(g:ulti_expand_or_jump_res) ? '\<Esc>:call "UltiSnips#ExpandSnippetOrJump()<cr>' : '\<Plug>(neosnippet_expand_or_jump)'"

but they does not work :(

0

There are 0 best solutions below