Option for JumpTrigger only during snippet expansion
This commit is contained in:
parent
1097b280a3
commit
a32473a5d4
@ -240,6 +240,20 @@ vimrc file. >
|
||||
let g:UltiSnipsJumpForwardTrigger="<tab>"
|
||||
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
|
||||
|
||||
The mapping of g:UltiSnipsJumpForwardTrigger and g:UltiSnipsJumpBackwardTrigger
|
||||
can be controlled with this option:
|
||||
|
||||
*g:UltiSnipsClearJumpTrigger*
|
||||
g:UltiSnipsClearJumpTrigger By default both triggers are global mappings
|
||||
that are always present. By setting this
|
||||
variable to 1 the plugin will define <buffer>
|
||||
mappings only during snippet expansions.
|
||||
|
||||
Note that the default value for g:UltiSnipsJumpBackwardTrigger interferes with
|
||||
the built-in complete function: |i_CTRL-X_CTRL-K|. A workaround is to add the
|
||||
following to your vimrc file. >
|
||||
inoremap <c-x><c-k> <c-x><c-k>
|
||||
|
||||
3.2.1 Using your own trigger functions *UltiSnips-trigger-functions*
|
||||
--------------------------------------
|
||||
|
||||
|
@ -84,6 +84,12 @@ endif
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||
endif
|
||||
|
||||
" Should UltiSnips map JumpForwardTrigger and JumpBackwardTrigger only during
|
||||
" snippet expansion?
|
||||
if !exists("g:UltiSnipsClearJumpTrigger")
|
||||
let g:UltiSnipsClearJumpTrigger = 0
|
||||
endif
|
||||
" }}}
|
||||
|
||||
" Global Commands {{{
|
||||
@ -130,12 +136,18 @@ function! CompensateForPUM()
|
||||
endif
|
||||
endfunction
|
||||
function! UltiSnips_ExpandSnippet()
|
||||
if g:UltiSnipsClearJumpTrigger == 1
|
||||
call UltiSnips_MapInnerKeys()
|
||||
endif
|
||||
exec g:_uspy "UltiSnips_Manager.expand()"
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! UltiSnips_ExpandSnippetOrJump()
|
||||
call CompensateForPUM()
|
||||
if g:UltiSnipsClearJumpTrigger == 1
|
||||
call UltiSnips_MapInnerKeys()
|
||||
endif
|
||||
exec g:_uspy "UltiSnips_Manager.expand_or_jump()"
|
||||
return ""
|
||||
endfunction
|
||||
@ -204,12 +216,16 @@ function! UltiSnips_MapKeys()
|
||||
else
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips_ExpandSnippet()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips_ExpandSnippet()<cr>"
|
||||
exec "inoremap <silent> " . g:UltiSnipsJumpForwardTrigger . " <C-R>=UltiSnips_JumpForwards()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsJumpForwardTrigger . " <Esc>:call UltiSnips_JumpForwards()<cr>"
|
||||
if g:UltiSnipsClearJumpTrigger == 0
|
||||
exec "inoremap <silent> " . g:UltiSnipsJumpForwardTrigger . " <C-R>=UltiSnips_JumpForwards()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsJumpForwardTrigger . " <Esc>:call UltiSnips_JumpForwards()<cr>"
|
||||
endif
|
||||
endif
|
||||
exec 'xnoremap ' . g:UltiSnipsExpandTrigger. ' :call UltiSnips_SaveLastVisualSelection()<cr>gvs'
|
||||
exec "inoremap <silent> " . g:UltiSnipsJumpBackwardTrigger . " <C-R>=UltiSnips_JumpBackwards()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsJumpBackwardTrigger . " <Esc>:call UltiSnips_JumpBackwards()<cr>"
|
||||
if g:UltiSnipsClearJumpTrigger == 0
|
||||
exec "inoremap <silent> " . g:UltiSnipsJumpBackwardTrigger . " <C-R>=UltiSnips_JumpBackwards()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsJumpBackwardTrigger . " <Esc>:call UltiSnips_JumpBackwards()<cr>"
|
||||
endif
|
||||
exec "inoremap <silent> " . g:UltiSnipsListSnippets . " <C-R>=UltiSnips_ListSnippets()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsListSnippets . " <Esc>:call UltiSnips_ListSnippets()<cr>"
|
||||
|
||||
@ -217,6 +233,23 @@ function! UltiSnips_MapKeys()
|
||||
snoremap <silent> <DEL> <c-g>c
|
||||
snoremap <silent> <c-h> <c-g>c
|
||||
endf
|
||||
function! UltiSnips_MapInnerKeys()
|
||||
if g:UltiSnipsExpandTrigger != g:UltiSnipsJumpForwardTrigger
|
||||
exec "inoremap <buffer> <silent> " . g:UltiSnipsJumpForwardTrigger . " <C-R>=UltiSnips_JumpForwards()<cr>"
|
||||
exec "snoremap <buffer> <silent> " . g:UltiSnipsJumpForwardTrigger . " <Esc>:call UltiSnips_JumpForwards()<cr>"
|
||||
endif
|
||||
exec "inoremap <buffer> <silent> " . g:UltiSnipsJumpBackwardTrigger . " <C-R>=UltiSnips_JumpBackwards()<cr>"
|
||||
exec "snoremap <buffer> <silent> " . g:UltiSnipsJumpBackwardTrigger . " <Esc>:call UltiSnips_JumpBackwards()<cr>"
|
||||
endf
|
||||
function! UltiSnips_RestoreInnerKeys()
|
||||
if g:UltiSnipsExpandTrigger != g:UltiSnipsJumpForwardTrigger
|
||||
exec "iunmap <buffer> " . g:UltiSnipsJumpForwardTrigger
|
||||
exec "sunmap <buffer> " . g:UltiSnipsJumpForwardTrigger
|
||||
endif
|
||||
exec "iunmap <buffer> " . g:UltiSnipsJumpBackwardTrigger
|
||||
exec "sunmap <buffer> " . g:UltiSnipsJumpBackwardTrigger
|
||||
endf
|
||||
|
||||
|
||||
function! UltiSnips_CursorMoved()
|
||||
exec g:_uspy "UltiSnips_Manager.cursor_moved()"
|
||||
|
@ -763,6 +763,8 @@ class SnippetManager(object):
|
||||
|
||||
def _current_snippet_is_done(self):
|
||||
self._csnippets.pop()
|
||||
if _vim.eval("g:UltiSnipsClearJumpTrigger") == "1":
|
||||
_vim.command("call UltiSnips_RestoreInnerKeys()")
|
||||
|
||||
def _jump(self, backwards = False):
|
||||
jumped = False
|
||||
|
Loading…
Reference in New Issue
Block a user