UltiSnips/plugin/UltiSnips.vim

70 lines
2.4 KiB
VimL
Raw Normal View History

" File: UltiSnips.vim
" Author: Holger Rapp <SirVer@gmx.de>
" Description: The Ultimate Snippets solution for Vim
"
" Testing Info:
" See directions at the top of the test.py script located one
A "clearsnippets" feature ========================= It's difficult for the user to control which of the default bundled snippets are active in his environment. The 'runtimepath' variable must be set to the root of the ultisnips installation, which brings in all of the bundled snippets. Though the user may individually override the definition of the bundled snippets using the "!" flag, the method has a couple of problems: - There's no way to remove a snippet, only to override it (and each snippet must be overridden individually). - The "!" flag currently doesn't remove the overridden snippets from the "list snippets" command. It might be considered a feature that "!" doesn't actually remove the snippets from the "list snippets" command, though perhaps that's an unintended effect. In any case, it would be more convenient to allow the user to selectively remove the bundled snippets from his environment. A patch is provided in the following branch to address these problems: http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets The branch's primary purpose is the addition of a "clearsnippets" command that may be placed in a user's ~/.vim/UltiSnips/ft.snippets file. The user may clear all lower-priority snippet for that file type with the line: clearsnippets Alternatively, he may clear individual snippets by listing their triggers: clearsnippets trigger1 trigger2 A few changes were made to the testing system as part of the incorporation of this new feature. These changes include: - The "extends" directive is now supported on multiple lines throughout file. - A completely empty .snippets file is now possible. - The test.py scripts now handles most of the vim setup, simplifying the running of the tests. The invocation of Vim now reduces to: vim -u NONE Instructions for running the tests are included at top of test.py, where they should be more visible to interested users; UltiSnips.vim now just points to test.py's instructions. - A new function vim_quote() encodes an arbitrary string into a singly-quoted Vim string, with embedded quotes escaped. - SnippetsFileParser() now allows file_data to be passed directly for unit testing, avoiding the need to create files in the filesystem for test purposes. - A new _error() function reports errors to the user. At runtime, this function uses :echo_err in general, but also can append error text to current buffer to check for expected errors during unit tests. - Added error checks to snippets file parsing, along with unit tests for the parsing. - Increased retries from 2 to 4 (on my system, occasionally the timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
" directory above this file.
if exists('did_UltiSnips_plugin') || &cp || version < 700
A "clearsnippets" feature ========================= It's difficult for the user to control which of the default bundled snippets are active in his environment. The 'runtimepath' variable must be set to the root of the ultisnips installation, which brings in all of the bundled snippets. Though the user may individually override the definition of the bundled snippets using the "!" flag, the method has a couple of problems: - There's no way to remove a snippet, only to override it (and each snippet must be overridden individually). - The "!" flag currently doesn't remove the overridden snippets from the "list snippets" command. It might be considered a feature that "!" doesn't actually remove the snippets from the "list snippets" command, though perhaps that's an unintended effect. In any case, it would be more convenient to allow the user to selectively remove the bundled snippets from his environment. A patch is provided in the following branch to address these problems: http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets The branch's primary purpose is the addition of a "clearsnippets" command that may be placed in a user's ~/.vim/UltiSnips/ft.snippets file. The user may clear all lower-priority snippet for that file type with the line: clearsnippets Alternatively, he may clear individual snippets by listing their triggers: clearsnippets trigger1 trigger2 A few changes were made to the testing system as part of the incorporation of this new feature. These changes include: - The "extends" directive is now supported on multiple lines throughout file. - A completely empty .snippets file is now possible. - The test.py scripts now handles most of the vim setup, simplifying the running of the tests. The invocation of Vim now reduces to: vim -u NONE Instructions for running the tests are included at top of test.py, where they should be more visible to interested users; UltiSnips.vim now just points to test.py's instructions. - A new function vim_quote() encodes an arbitrary string into a singly-quoted Vim string, with embedded quotes escaped. - SnippetsFileParser() now allows file_data to be passed directly for unit testing, avoiding the need to create files in the filesystem for test purposes. - A new _error() function reports errors to the user. At runtime, this function uses :echo_err in general, but also can append error text to current buffer to check for expected errors during unit tests. - Added error checks to snippets file parsing, along with unit tests for the parsing. - Increased retries from 2 to 4 (on my system, occasionally the timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
finish
endif
" The Commands we define.
command! -nargs=? -complete=customlist,UltiSnips#FileTypeComplete UltiSnipsEdit
\ :call UltiSnips#Edit(<q-args>)
command! -nargs=1 UltiSnipsAddFiletypes :call UltiSnips#AddFiletypes(<q-args>)
" Backwards compatible functions. Prefer the ones in autoload/.
function! UltiSnips_FileTypeChanged()
echoerr "Deprecated UltiSnips_FileTypeChanged called. Please use UltiSnips#FileTypeChanged." | sleep 1
return UltiSnips#FileTypeChanged()
endfunction
function! UltiSnips_ExpandSnippet()
echoerr "Deprecated UltiSnips_ExpandSnippet called. Please use UltiSnips#ExpandSnippet." | sleep 1
return UltiSnips#ExpandSnippet()
endfunction
function! UltiSnips_ExpandSnippetOrJump()
echoerr "Deprecated UltiSnips_ExpandSnippetOrJump called. Please use UltiSnips#ExpandSnippetOrJump." | sleep 1
return UltiSnips#ExpandSnippetOrJump()
endfunction
function! UltiSnips_SnippetsInCurrentScope()
echoerr "Deprecated UltiSnips_SnippetsInCurrentScope called. Please use UltiSnips#SnippetsInCurrentScope." | sleep 1
return UltiSnips#SnippetsInCurrentScope()
endfunction
2009-07-10 06:47:54 -04:00
function! UltiSnips_JumpBackwards()
echoerr "Deprecated UltiSnips_JumpBackwards called. Please use UltiSnips#JumpBackwards." | sleep 1
return UltiSnips#JumpBackwards()
endfunction
2009-07-10 06:47:54 -04:00
function! UltiSnips_JumpForwards()
echoerr "Deprecated UltiSnips_JumpForwards called. Please use UltiSnips#JumpForwards." | sleep 1
return UltiSnips#JumpForwards()
endfunction
function! UltiSnips_AddSnippet(...)
echoerr "Deprecated UltiSnips_AddSnippet called. Please use UltiSnips#AddSnippetWithPriority." | sleep 1
return call(function('UltiSnips#AddSnippet'), a:000)
endfunction
function! UltiSnips_Anon(...)
echoerr "Deprecated UltiSnips_Anon called. Please use UltiSnips#Anon." | sleep 1
return call(function('UltiSnips#Anon'), a:000)
endfunction
2009-07-04 06:15:12 -04:00
au CursorMovedI * call UltiSnips#CursorMoved()
au CursorMoved * call UltiSnips#CursorMoved()
au BufLeave * call UltiSnips#LeavingBuffer()
au InsertLeave * call UltiSnips#LeavingInsertMode()
call UltiSnips#map_keys#MapKeys()
2011-04-27 11:37:07 -04:00
let did_UltiSnips_plugin=1
2011-04-27 11:37:07 -04:00
" vim: ts=8 sts=4 sw=4