" File: UltiSnips.vim " Author: Holger Rapp " Description: The Ultimate Snippets solution for Vim " Last Modified: July 21, 2009 " " Testing Info: {{{ " Running vim + ultisnips with the absolute bar minimum settings inside a screen session: " $ screen -S vim " $ vim -u NONE -U NONE -c ':set nocompatible' -c ':set runtimepath+=.' " $ ./test.py # launch the testsuite " }}} if exists('did_UltiSnips_vim') || &cp || version < 700 || !has("python") finish 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 = "" endif " The trigger used to display all triggers that could possible " match in the current position. if !exists("g:UltiSnipsListSnippets") let g:UltiSnipsListSnippets = "" 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 = "" endif " The trigger to jump backward inside a snippet if !exists("g:UltiSnipsJumpBackwardTrigger") let g:UltiSnipsJumpBackwardTrigger = "" endif " }}} "" FUNCTIONS {{{ function! UltiSnips_ExpandSnippet() py UltiSnips_Manager.expand() return "" endfunction function! UltiSnips_ExpandSnippetOrJump() py UltiSnips_Manager.expand_or_jump() return "" endfunction function! UltiSnips_ListSnippets() py UltiSnips_Manager.list_snippets() return "" endfunction function! UltiSnips_JumpBackwards() py UltiSnips_Manager.jump_backwards() return "" endfunction function! UltiSnips_JumpForwards() py UltiSnips_Manager.jump_forwards() return "" endfunction function! UltiSnips_MapKeys() " Map the keys correctly if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger exec "inoremap " . g:UltiSnipsExpandTrigger . " =UltiSnips_ExpandSnippetOrJump()" exec "snoremap " . g:UltiSnipsExpandTrigger . " :call UltiSnips_ExpandSnippetOrJump()" else exec "inoremap " . g:UltiSnipsExpandTrigger . " =UltiSnips_ExpandSnippet()" exec "snoremap " . g:UltiSnipsExpandTrigger . " :call UltiSnips_ExpandSnippet()" exec "inoremap " . g:UltiSnipsJumpForwardTrigger . " =UltiSnips_JumpForwards()" exec "snoremap " . g:UltiSnipsJumpForwardTrigger . " :call UltiSnips_JumpForwards()" endif exec "inoremap " . g:UltiSnipsJumpBackwardTrigger . " =UltiSnips_JumpBackwards()" exec "snoremap " . g:UltiSnipsJumpBackwardTrigger . " :call UltiSnips_JumpBackwards()" exec "inoremap " . g:UltiSnipsListSnippets . " =UltiSnips_ListSnippets()" exec "snoremap " . g:UltiSnipsListSnippets . " :call UltiSnips_ListSnippets()" " Do not remap this. snoremap :py UltiSnips_Manager.backspace_while_selected() endf " }}} "" STARTUP CODE {{{ " Expand our path python << EOF import vim, os, sys for p in vim.eval("&runtimepath").split(','): dname = p + os.path.sep + "plugin" if os.path.exists(dname + os.path.sep + "UltiSnips"): if dname not in sys.path: sys.path.append(dname) break from UltiSnips import UltiSnips_Manager UltiSnips_Manager.expand_trigger = vim.eval("g:UltiSnipsExpandTrigger") UltiSnips_Manager.forward_trigger = vim.eval("g:UltiSnipsJumpForwardTrigger") UltiSnips_Manager.backward_trigger = vim.eval("g:UltiSnipsJumpBackwardTrigger") EOF au CursorMovedI * py UltiSnips_Manager.cursor_moved() au InsertEnter * py UltiSnips_Manager.entered_insert_mode() call UltiSnips_MapKeys() let did_UltiSnips_vim=1 " }}}