2009-07-04 10:08:14 -04:00
|
|
|
|
|
|
|
"" FUNCTIONS
|
|
|
|
|
2009-07-10 06:47:54 -04:00
|
|
|
function! UltiSnips_ExpandSnippet()
|
2009-07-04 10:08:14 -04:00
|
|
|
if exists('g:SuperTabMappingForward')
|
|
|
|
if g:SuperTabMappingForward == "<s-tab>"
|
|
|
|
let SuperTabKey = "\<c-n>"
|
|
|
|
elseif g:SuperTabMappingBackward == "<s-tab>"
|
|
|
|
let SuperTabKey = "\<c-p>"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
|
|
|
if exists('SuperTabKey')
|
|
|
|
call feedkeys(SuperTabKey) | return ''
|
|
|
|
endif
|
|
|
|
call feedkeys("\<esc>a", 'n') " Close completion menu
|
|
|
|
call feedkeys("\<tab>") | return ''
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Now, really expand something
|
2009-07-04 06:15:12 -04:00
|
|
|
py << EOF
|
2009-07-10 06:47:54 -04:00
|
|
|
if not UltiSnips_Manager.try_expand():
|
2009-07-04 10:08:14 -04:00
|
|
|
vim.command("""if exists('SuperTabKey')
|
|
|
|
call feedkeys(SuperTabKey)
|
|
|
|
endif
|
|
|
|
""")
|
2009-07-04 06:15:12 -04:00
|
|
|
EOF
|
2009-07-04 10:08:14 -04:00
|
|
|
|
|
|
|
return ""
|
2009-07-04 06:15:12 -04:00
|
|
|
endfunction
|
|
|
|
|
2009-07-10 06:47:54 -04:00
|
|
|
function! UltiSnips_JumpBackwards()
|
2009-07-04 06:15:12 -04:00
|
|
|
py << EOF
|
2009-07-10 06:47:54 -04:00
|
|
|
UltiSnips_Manager.jump(True)
|
2009-07-09 09:30:23 -04:00
|
|
|
EOF
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
2009-07-10 06:47:54 -04:00
|
|
|
function! UltiSnips_JumpForwards()
|
2009-07-09 09:30:23 -04:00
|
|
|
py << EOF
|
2009-07-10 06:47:54 -04:00
|
|
|
UltiSnips_Manager.jump()
|
2009-07-04 06:15:12 -04:00
|
|
|
EOF
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2009-07-04 10:08:14 -04:00
|
|
|
"" STARTUP CODE
|
|
|
|
|
2009-07-04 06:15:12 -04:00
|
|
|
" Expand our path
|
2009-07-04 10:08:14 -04:00
|
|
|
python << EOF
|
|
|
|
import vim, os, sys
|
|
|
|
|
|
|
|
for p in vim.eval("&runtimepath").split(','):
|
|
|
|
dname = p + os.path.sep + "plugin"
|
2009-07-10 06:47:54 -04:00
|
|
|
if os.path.exists(dname + os.path.sep + "UltiSnips"):
|
2009-07-04 10:08:14 -04:00
|
|
|
if dname not in sys.path:
|
|
|
|
sys.path.append(dname)
|
|
|
|
break
|
|
|
|
|
2009-07-10 06:47:54 -04:00
|
|
|
from UltiSnips import UltiSnips_Manager
|
2009-07-04 10:08:14 -04:00
|
|
|
EOF
|
2009-07-04 06:15:12 -04:00
|
|
|
|
2009-07-06 17:09:53 -04:00
|
|
|
" You can remap these
|
2009-07-10 06:47:54 -04:00
|
|
|
inoremap <Tab> <C-R>=UltiSnips_ExpandSnippet()<cr>
|
|
|
|
snoremap <Tab> <Esc>:call UltiSnips_ExpandSnippet()<cr>
|
|
|
|
inoremap <C-k> <C-R>=UltiSnips_JumpBackwards()<cr>
|
|
|
|
snoremap <C-k> <Esc>:call UltiSnips_JumpBackwards()<cr>
|
|
|
|
inoremap <C-j> <C-R>=UltiSnips_JumpForwards()<cr>
|
|
|
|
snoremap <C-j> <Esc>:call UltiSnips_JumpForwards()<cr>
|
2009-07-06 17:09:53 -04:00
|
|
|
|
|
|
|
" Do not remap this.
|
2009-07-10 06:47:54 -04:00
|
|
|
snoremap <BS> <Esc>:py UltiSnips_Manager.backspace_while_selected()<cr>
|
2009-07-04 06:15:12 -04:00
|
|
|
|
2009-07-10 06:47:54 -04:00
|
|
|
au CursorMovedI * py UltiSnips_Manager.cursor_moved()
|
|
|
|
au InsertEnter * py UltiSnips_Manager.entered_insert_mode()
|
2009-07-04 06:15:12 -04:00
|
|
|
|