diff --git a/autoload/UltiSnips.vim b/autoload/UltiSnips.vim index f1b2f15..5f18569 100644 --- a/autoload/UltiSnips.vim +++ b/autoload/UltiSnips.vim @@ -8,14 +8,30 @@ endif let did_UltiSnips_autoload=1 " Define dummy version of function called by autocommand setup in -" ftdetect/UltiSnips.vim. If the function isn't defined (probably due to -" using a copy of vim without python support) it will cause an error anytime a -" new file is opened. +" ftdetect/UltiSnips.vim and plugin/UltiSnips.vim. +" If the function isn't defined (probably due to using a copy of vim +" without python support) it would cause an error. function! UltiSnips#FileTypeChanged() endfunction +function! UltiSnips#CursorMoved() +endfunction +function! UltiSnips#CursorMoved() +endfunction +function! UltiSnips#LeavingBuffer() +endfunction +function! UltiSnips#LeavingInsertMode() +endfunction call UltiSnips#bootstrap#Bootstrap() if !exists("g:_uspy") + " Delete the autocommands defined in plugin/UltiSnips.vim and + " ftdetect/UltiSnips.vim. + augroup UltiSnips + au! + augroup END + augroup UltiSnipsFileType + au! + augroup END finish end diff --git a/autoload/UltiSnips/bootstrap.vim b/autoload/UltiSnips/bootstrap.vim index 50375b1..d5c865c 100644 --- a/autoload/UltiSnips/bootstrap.vim +++ b/autoload/UltiSnips/bootstrap.vim @@ -14,7 +14,7 @@ function! UltiSnips#bootstrap#Bootstrap() echo "UltiSnips requires py >= 2.6 or any py3" endif unlet g:_uspy - finish + return endif let g:_uspy=":py " endif diff --git a/autoload/UltiSnips/map_keys.vim b/autoload/UltiSnips/map_keys.vim index 44e4082..eb570ba 100644 --- a/autoload/UltiSnips/map_keys.vim +++ b/autoload/UltiSnips/map_keys.vim @@ -1,6 +1,11 @@ call UltiSnips#bootstrap#Bootstrap() function! UltiSnips#map_keys#MapKeys() + if !exists('g:_uspy') + " Do not map keys if bootstrapping failed (e.g. no Python). + return + endif + " Map the keys correctly if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger diff --git a/ftdetect/UltiSnips.vim b/ftdetect/UltiSnips.vim index 9ec5b7b..e5df595 100644 --- a/ftdetect/UltiSnips.vim +++ b/ftdetect/UltiSnips.vim @@ -1,5 +1,8 @@ " This has to be called before ftplugins are loaded. Therefore " it is here in ftdetect though it maybe shouldn't if has("autocmd") - autocmd FileType * call UltiSnips#FileTypeChanged() + augroup UltiSnipsFileType + au! + autocmd FileType * call UltiSnips#FileTypeChanged() + augroup END endif diff --git a/plugin/UltiSnips.vim b/plugin/UltiSnips.vim index bad9016..26ac44b 100644 --- a/plugin/UltiSnips.vim +++ b/plugin/UltiSnips.vim @@ -57,10 +57,13 @@ function! UltiSnips_Anon(...) return call(function('UltiSnips#Anon'), a:000) endfunction -au CursorMovedI * call UltiSnips#CursorMoved() -au CursorMoved * call UltiSnips#CursorMoved() -au BufLeave * call UltiSnips#LeavingBuffer() -au InsertLeave * call UltiSnips#LeavingInsertMode() +augroup UltiSnips + au! + au CursorMovedI * call UltiSnips#CursorMoved() + au CursorMoved * call UltiSnips#CursorMoved() + au BufLeave * call UltiSnips#LeavingBuffer() + au InsertLeave * call UltiSnips#LeavingInsertMode() +augroup END call UltiSnips#map_keys#MapKeys()