UltiSnips/plugin/UltiSnips.vim

58 lines
1.6 KiB
VimL
Raw Permalink Normal View History

if exists('did_plugin_ultisnips') || &cp
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
let did_plugin_ultisnips=1
if version < 704
echohl WarningMsg
echom "UltiSnips requires Vim >= 7.4"
echohl None
finish
endif
if !exists("g:UltiSnipsUsePythonVersion")
let g:_uspy=":py3 "
if !has("python3")
if !has("python")
if !exists("g:UltiSnipsNoPythonWarning")
echohl WarningMsg
echom "UltiSnips requires py >= 2.7 or py3"
echohl None
endif
unlet g:_uspy
finish
endif
let g:_uspy=":py "
endif
else
" Use user-provided value, but check if it's available.
" This uses `has()`, because e.g. `exists(":python3")` is always 2.
if g:UltiSnipsUsePythonVersion == 2 && has('python')
let g:_uspy=":python "
elseif g:UltiSnipsUsePythonVersion == 3 && has('python3')
let g:_uspy=":python3 "
endif
if !exists('g:_uspy')
echohl WarningMsg
echom "UltiSnips: the Python version from g:UltiSnipsUsePythonVersion (".g:UltiSnipsUsePythonVersion.") is not available."
echohl None
finish
endif
endif
" The Commands we define.
command! -bang -nargs=? -complete=customlist,UltiSnips#FileTypeComplete UltiSnipsEdit
\ :call UltiSnips#Edit(<q-bang>, <q-args>)
command! -nargs=1 UltiSnipsAddFiletypes :call UltiSnips#AddFiletypes(<q-args>)
augroup UltiSnips_AutoTrigger
au!
au InsertCharPre * call UltiSnips#TrackChange()
au TextChangedI * call UltiSnips#TrackChange()
augroup END
call UltiSnips#map_keys#MapKeys()
2011-04-27 11:37:07 -04:00
" vim: ts=8 sts=4 sw=4