-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REQ: expand but try to jump forward also #1
Comments
I'm not sure what you what. After the snippet is expanded, ultisnips will automatically jumps to the first snippet tabstop/placeholder. If you're encountering wired behavior, better to post a gif to describe the issue. |
maybe i hope to jump next placeholder. currently, based on example, press Enter key, it will input new line, but i want to jump to next placeholder(if body). i will try to find a gif tool to record. thank you! |
If you want a different order of placeholder, you should modify the snippet instead of modify the plugin |
would you like to try ? key maplet g:ulti_expand_or_jump_res = 0
function! SmartTab()
if pumvisible() == 1
return "\<C-n>"
else
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<Tab>"
endif
endif
endfunction
inoremap <silent><expr><CR> pumvisible() ? "<C-R>=<SID>ExpandOrClosePopup()<CR>" : "\<Cr>"
snoremap <silent><Tab> <Esc>:call UltiSnips#JumpForwards()<CR>
inoremap <silent><S-Tab> <C-R>=SmartSTab()<CR> Steps:
But above keymap lose function parameter expand. Then change Entry map to your suggestion: inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or("\<CR>", 'n') Re-execute above steps, you will find explicit Enter key is accepted, as result, newline is inserted, { is moved to newline |
diff --git a/autoload/ncm2_ultisnips.vim b/autoload/ncm2_ultisnips.vim
index ac80a21..e165896 100644
--- a/autoload/ncm2_ultisnips.vim
+++ b/autoload/ncm2_ultisnips.vim
@@ -33,6 +33,11 @@ func! ncm2_ultisnips#_do_expand_or()
call feedkeys("\<Plug>(ncm2_ultisnips_expand)", "im")
return ''
endif
+ let g:ulti_jump_forwards_res = 0
+ call UltiSnips#JumpForwards()
+ if g:ulti_jump_forwards_res == 1
+ return ''
+ endif
call call('feedkeys', s:or_key)
return ''
endfunc That's what I want. |
You could wrap your own
|
I have exported two API, you should be able to program you own key mapping based on
and
|
thank you. Based on requirement, would you like to give an example ? Sorry, I don't know how to do because knowledge of vim script is very limited. Anyway, thank you! |
|
i understand now, but it will cause vimrc ugly/complex. UltiSnips provide API UltiSnips#ExpandSnippetOrJump(). How about change ncm2_ultisnips#expand_or to ncm2_ultisnips#expand_or_jump_or ? appreciated for this wonderful plugin. |
Sorry if I am overly confused. Using this extension for ncm2 with your recommended configs for both does not allow for auto-completion and rotation through options with and . How should we go about solving this? |
If you're having trouble, you need to post your minimal vimrc and elaborate the reproducing steps. Another issue should be open too. |
This isssue is a bit old, but yes this would be great to have. Currently I can expand a snippet from ncm2 by pressing enter with the following mapping: inoremap <silent> <expr> <cr> pumvisible()
\ ? ncm2_ultisnips#expand_or("\<c-y>", 'n')
\ : "\<cr>" But I'd like to additionally be able to press enter again to jump to the next placeholder. This is how Edit - it occurred to me that something like this might work but it doesn't: let g:UltiSnipsJumpForwardTrigger="<c-b>"
inoremap <silent> <expr> <cr> pumvisible()
\ ? ncm2_ultisnips#expand_or("\<c-y>", 'n')
\ : ncm2_ultisnips#completed_is_snippet()
\ ? "\<c-b>"
\ : "\<cr>" |
currently, ncm2_ultisnips#_do_expand_or only try to expand snippet, but not try to jump forward. is it possible to add ?
taking go/LC as example:
input key word "if" --> trigger expand -> input "tr" -> LC will popup menu and complete to true -> use tab to choose --> press Enter --> cursor will jump to if body.
currently, with ncm2/ultisnips, i have to use C-J to move explicitly.
The text was updated successfully, but these errors were encountered: