after script maps Keys again. Needed some refactorings. This fixes supertab integration and closes #212.
This commit is contained in:
parent
7ef866e1f4
commit
ba772b0d14
@ -4,10 +4,10 @@
|
||||
" Supertab)
|
||||
" Last Modified: July 27, 2009
|
||||
|
||||
if exists('did_UltiSnips_after') || &cp || version < 700 || !exists("did_UltiSnips_vim") || !has("python")
|
||||
if exists('did_UltiSnips_after') || &cp || version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
call UltiSnips#MapKeys()
|
||||
call UltiSnips#map_keys#MapKeys()
|
||||
|
||||
let did_UltiSnips_after=1
|
||||
|
@ -15,7 +15,7 @@ endfunction
|
||||
|
||||
" Kludge to make sure that if the python module is loaded first, all of this
|
||||
" initialization in this file is indeed done.
|
||||
function! UltiSnips#EnsureAutoloadScriptWasRun()
|
||||
function! UltiSnips#WasRun()
|
||||
endfunction
|
||||
|
||||
if !exists("g:UltiSnipsUsePythonVersion")
|
||||
@ -38,54 +38,6 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
" Global Variables {{{
|
||||
|
||||
" The trigger used to expand a snippet.
|
||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||
if !exists("g:UltiSnipsExpandTrigger")
|
||||
let g:UltiSnipsExpandTrigger = "<tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to display all triggers that could possible
|
||||
" match in the current position.
|
||||
if !exists("g:UltiSnipsListSnippets")
|
||||
let g:UltiSnipsListSnippets = "<c-tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to jump forward to the next placeholder.
|
||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||
if !exists("g:UltiSnipsJumpForwardTrigger")
|
||||
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
|
||||
endif
|
||||
|
||||
" The trigger to jump backward inside a snippet
|
||||
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
||||
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
||||
endif
|
||||
|
||||
" Should UltiSnips unmap select mode mappings automagically?
|
||||
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
||||
let g:UltiSnipsRemoveSelectModeMappings = 1
|
||||
end
|
||||
|
||||
" If UltiSnips should remove Mappings, which should be ignored
|
||||
if !exists("g:UltiSnipsMappingsToIgnore")
|
||||
let g:UltiSnipsMappingsToIgnore = []
|
||||
endif
|
||||
|
||||
" UltiSnipsEdit will use this variable to decide if a new window
|
||||
" is opened when editing. default is "normal", allowed are also
|
||||
" "vertical", "horizontal"
|
||||
if !exists("g:UltiSnipsEditSplit")
|
||||
let g:UltiSnipsEditSplit = 'normal'
|
||||
endif
|
||||
|
||||
" A list of directory names that are searched for snippets.
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||
endif
|
||||
" }}}
|
||||
|
||||
|
||||
" FUNCTIONS {{{
|
||||
function! s:compensate_for_pum()
|
||||
@ -138,43 +90,6 @@ function! UltiSnips#FileTypeComplete(arglead, cmdline, cursorpos)
|
||||
return sort(keys(ret))
|
||||
endfunction
|
||||
|
||||
function! UltiSnips#MapKeys()
|
||||
" Map the keys correctly
|
||||
if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger
|
||||
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
else
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippet()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippet()<cr>"
|
||||
endif
|
||||
exec 'xnoremap ' . g:UltiSnipsExpandTrigger. ' :call UltiSnips#SaveLastVisualSelection()<cr>gvs'
|
||||
exec "inoremap <silent> " . g:UltiSnipsListSnippets . " <C-R>=UltiSnips#ListSnippets()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsListSnippets . " <Esc>:call UltiSnips#ListSnippets()<cr>"
|
||||
|
||||
snoremap <silent> <BS> <c-g>c
|
||||
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#ExpandSnippet()
|
||||
exec g:_uspy "UltiSnips_Manager.expand()"
|
||||
return ""
|
||||
|
38
autoload/ultisnips/map_keys.vim
Normal file
38
autoload/ultisnips/map_keys.vim
Normal file
@ -0,0 +1,38 @@
|
||||
call UltiSnips#variables#WasRun()
|
||||
|
||||
function! UltiSnips#map_keys#MapKeys()
|
||||
" Map the keys correctly
|
||||
if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger
|
||||
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
else
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippet()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippet()<cr>"
|
||||
endif
|
||||
exec 'xnoremap ' . g:UltiSnipsExpandTrigger. ' :call UltiSnips#SaveLastVisualSelection()<cr>gvs'
|
||||
exec "inoremap <silent> " . g:UltiSnipsListSnippets . " <C-R>=UltiSnips#ListSnippets()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsListSnippets . " <Esc>:call UltiSnips#ListSnippets()<cr>"
|
||||
|
||||
snoremap <silent> <BS> <c-g>c
|
||||
snoremap <silent> <DEL> <c-g>c
|
||||
snoremap <silent> <c-h> <c-g>c
|
||||
endf
|
||||
|
||||
function! UltiSnips#map_keys#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#map_keys#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
|
48
autoload/ultisnips/variables.vim
Normal file
48
autoload/ultisnips/variables.vim
Normal file
@ -0,0 +1,48 @@
|
||||
" Kludge to make sure that this file is really run.
|
||||
function! UltiSnips#variables#WasRun()
|
||||
endfunction
|
||||
|
||||
" The trigger used to expand a snippet.
|
||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||
if !exists("g:UltiSnipsExpandTrigger")
|
||||
let g:UltiSnipsExpandTrigger = "<tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to display all triggers that could possible
|
||||
" match in the current position.
|
||||
if !exists("g:UltiSnipsListSnippets")
|
||||
let g:UltiSnipsListSnippets = "<c-tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to jump forward to the next placeholder.
|
||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||
if !exists("g:UltiSnipsJumpForwardTrigger")
|
||||
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
|
||||
endif
|
||||
|
||||
" The trigger to jump backward inside a snippet
|
||||
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
||||
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
||||
endif
|
||||
|
||||
" Should UltiSnips unmap select mode mappings automagically?
|
||||
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
||||
let g:UltiSnipsRemoveSelectModeMappings = 1
|
||||
end
|
||||
|
||||
" If UltiSnips should remove Mappings, which should be ignored
|
||||
if !exists("g:UltiSnipsMappingsToIgnore")
|
||||
let g:UltiSnipsMappingsToIgnore = []
|
||||
endif
|
||||
|
||||
" UltiSnipsEdit will use this variable to decide if a new window
|
||||
" is opened when editing. default is "normal", allowed are also
|
||||
" "vertical", "horizontal"
|
||||
if !exists("g:UltiSnipsEditSplit")
|
||||
let g:UltiSnipsEditSplit = 'normal'
|
||||
endif
|
||||
|
||||
" A list of directory names that are searched for snippets.
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||
endif
|
@ -50,7 +50,7 @@ au CursorMoved * call UltiSnips#CursorMoved()
|
||||
au BufLeave * call UltiSnips#LeavingBuffer()
|
||||
au InsertLeave * call UltiSnips#LeavingInsertMode()
|
||||
|
||||
call UltiSnips#MapKeys()
|
||||
call UltiSnips#map_keys#MapKeys()
|
||||
|
||||
let did_UltiSnips_plugin=1
|
||||
|
||||
|
@ -7,7 +7,7 @@ import vim # pylint:disable=import-error
|
||||
|
||||
from UltiSnips.snippet_manager import SnippetManager
|
||||
|
||||
vim.command("call UltiSnips#EnsureAutoloadScriptWasRun()")
|
||||
vim.command("call UltiSnips#WasRun()")
|
||||
|
||||
UltiSnips_Manager = SnippetManager( # pylint:disable=invalid-name
|
||||
vim.eval('g:UltiSnipsExpandTrigger'),
|
||||
|
@ -328,7 +328,7 @@ class SnippetManager(object):
|
||||
"""The current snippet should be terminated."""
|
||||
self._csnippets.pop()
|
||||
if not self._csnippets:
|
||||
_vim.command("call UltiSnips#RestoreInnerKeys()")
|
||||
_vim.command("call UltiSnips#map_keys#RestoreInnerKeys()")
|
||||
|
||||
def _jump(self, backwards=False):
|
||||
"""Helper method that does the actual jump."""
|
||||
@ -408,7 +408,7 @@ class SnippetManager(object):
|
||||
def _do_snippet(self, snippet, before):
|
||||
"""Expands the given snippet, and handles everything
|
||||
that needs to be done with it."""
|
||||
_vim.command("call UltiSnips#MapInnerKeys()")
|
||||
_vim.command("call UltiSnips#map_keys#MapInnerKeys()")
|
||||
|
||||
# Adjust before, maybe the trigger is not the complete word
|
||||
text_before = before
|
||||
|
Loading…
Reference in New Issue
Block a user