Remove bootstrap.vim. Simplify startup.
The python module is now pulled in autoload/UltiSnips.vim. This means that parsing of the .vimrc will only map the keys and set some options - very cheap. Unfortunately, the autocommands set up in plugin/UltiSnips.vim pulls in the python code basically immediately still.
This commit is contained in:
parent
b13015d47a
commit
becab789a8
@ -1,13 +1,8 @@
|
||||
" File: UltiSnips_after.vim
|
||||
" Author: Holger Rapp <SirVer@gmx.de>
|
||||
" Description: Called after everything else to reclaim keys (Needed for
|
||||
" Supertab)
|
||||
" Last Modified: July 27, 2009
|
||||
" Called after everything else to reclaim keys (Needed for Supertab)
|
||||
|
||||
if exists('did_UltiSnips_after') || &cp || version < 704
|
||||
finish
|
||||
if exists("b:did_after_plugin_ultisnips_after") || !exists("g:_uspy")
|
||||
finish
|
||||
endif
|
||||
let b:did_after_plugin_ultisnips_after = 1
|
||||
|
||||
call UltiSnips#map_keys#MapKeys()
|
||||
|
||||
let did_UltiSnips_after=1
|
||||
|
@ -1,28 +1,12 @@
|
||||
" File: UltiSnips.vim
|
||||
" Author: Holger Rapp <SirVer@gmx.de>
|
||||
" Description: The Ultimate Snippets solution for Vim
|
||||
|
||||
if exists('did_UltiSnips_autoload') || &cp || version < 704
|
||||
finish
|
||||
if exists("b:did_autoload_ultisnips") || !exists("g:_uspy")
|
||||
finish
|
||||
endif
|
||||
let did_UltiSnips_autoload=1
|
||||
let b:did_autoload_ultisnips = 1
|
||||
|
||||
" Define dummy version of function called by autocommand setup in
|
||||
" 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
|
||||
" Also import vim as we expect it to be imported in many places.
|
||||
exec g:_uspy "import vim"
|
||||
exec g:_uspy "from UltiSnips import UltiSnips_Manager"
|
||||
|
||||
call UltiSnips#bootstrap#Bootstrap()
|
||||
if !exists("g:_uspy")
|
||||
" Delete the autocommands defined in plugin/UltiSnips.vim and
|
||||
" ftdetect/UltiSnips.vim.
|
||||
|
@ -1,93 +0,0 @@
|
||||
let s:SourcedFile=expand("<sfile>")
|
||||
|
||||
function! UltiSnips#bootstrap#Bootstrap()
|
||||
if exists('s:did_UltiSnips_bootstrap')
|
||||
return
|
||||
endif
|
||||
let s:did_UltiSnips_bootstrap=1
|
||||
|
||||
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 any py3"
|
||||
echohl None
|
||||
endif
|
||||
unlet g:_uspy
|
||||
return
|
||||
endif
|
||||
let g:_uspy=":py "
|
||||
endif
|
||||
let g:UltiSnipsUsePythonVersion = "<tab>"
|
||||
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
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
" Import vim as we expect it to be imported in many places.
|
||||
exec g:_uspy "import vim"
|
||||
exec g:_uspy "from UltiSnips import UltiSnips_Manager"
|
||||
endfunction
|
||||
|
||||
" 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 = "<tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to display all triggers that could possible
|
||||
" match in the current position.
|
||||
if !exists("g:UltiSnipsListSnippets")
|
||||
let g:UltiSnipsListSnippets = "<c-tab>"
|
||||
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 = "<c-j>"
|
||||
endif
|
||||
|
||||
" The trigger to jump backward inside a snippet
|
||||
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
||||
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
||||
endif
|
||||
|
||||
" Should UltiSnips unmap select mode mappings automagically?
|
||||
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
||||
let g:UltiSnipsRemoveSelectModeMappings = 1
|
||||
end
|
||||
|
||||
" If UltiSnips should remove Mappings, which should be ignored
|
||||
if !exists("g:UltiSnipsMappingsToIgnore")
|
||||
let g:UltiSnipsMappingsToIgnore = []
|
||||
endif
|
||||
|
||||
" UltiSnipsEdit will use this variable to decide if a new window
|
||||
" is opened when editing. default is "normal", allowed are also
|
||||
" "vertical", "horizontal"
|
||||
if !exists("g:UltiSnipsEditSplit")
|
||||
let g:UltiSnipsEditSplit = 'normal'
|
||||
endif
|
||||
|
||||
" A list of directory names that are searched for snippets.
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||
endif
|
||||
|
||||
" Enable or Disable snipmate snippet expansion.
|
||||
if !exists("g:UltiSnipsEnableSnipMate")
|
||||
let g:UltiSnipsEnableSnipMate = 1
|
||||
endif
|
@ -1,14 +1,60 @@
|
||||
call UltiSnips#bootstrap#Bootstrap()
|
||||
if exists("b:did_autoload_ultisnips_map_keys") || !exists("g:_uspy")
|
||||
finish
|
||||
endif
|
||||
let b:did_autoload_ultisnips_map_keys = 1
|
||||
|
||||
" 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 = "<tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to display all triggers that could possible
|
||||
" match in the current position.
|
||||
if !exists("g:UltiSnipsListSnippets")
|
||||
let g:UltiSnipsListSnippets = "<c-tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to jump forward to the next placeholder.
|
||||
" NOTE: expansion and forward jumping can be the same trigger.
|
||||
if !exists("g:UltiSnipsJumpForwardTrigger")
|
||||
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
|
||||
endif
|
||||
|
||||
" The trigger to jump backward inside a snippet
|
||||
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
||||
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
||||
endif
|
||||
|
||||
" Should UltiSnips unmap select mode mappings automagically?
|
||||
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
||||
let g:UltiSnipsRemoveSelectModeMappings = 1
|
||||
end
|
||||
|
||||
" If UltiSnips should remove Mappings, which should be ignored
|
||||
if !exists("g:UltiSnipsMappingsToIgnore")
|
||||
let g:UltiSnipsMappingsToIgnore = []
|
||||
endif
|
||||
|
||||
" UltiSnipsEdit will use this variable to decide if a new window
|
||||
" is opened when editing. default is "normal", allowed are also
|
||||
" "vertical", "horizontal"
|
||||
if !exists("g:UltiSnipsEditSplit")
|
||||
let g:UltiSnipsEditSplit = 'normal'
|
||||
endif
|
||||
|
||||
" A list of directory names that are searched for snippets.
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||
endif
|
||||
|
||||
" Enable or Disable snipmate snippet expansion.
|
||||
if !exists("g:UltiSnipsEnableSnipMate")
|
||||
let g:UltiSnipsEnableSnipMate = 1
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
else
|
||||
|
@ -1,15 +1,7 @@
|
||||
" 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
|
||||
" directory above this file.
|
||||
|
||||
if exists('did_UltiSnips_plugin') || &cp
|
||||
if exists('did_plugin_ultisnips') || &cp
|
||||
finish
|
||||
endif
|
||||
let did_UltiSnips_plugin=1
|
||||
let did_plugin_ultisnips=1
|
||||
|
||||
if version < 704
|
||||
echohl WarningMsg
|
||||
@ -18,6 +10,36 @@ if version < 704
|
||||
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>)
|
||||
|
@ -98,7 +98,7 @@ class SnippetManager(object):
|
||||
self.register_snippet_source('ultisnips_files', UltiSnipsFileSource())
|
||||
self.register_snippet_source('added', self._added_snippets_source)
|
||||
|
||||
enable_snipmate = True
|
||||
enable_snipmate = '1'
|
||||
if _vim.eval("exists('g:UltiSnipsEnableSnipMate')") == '1':
|
||||
enable_snipmate = _vim.eval('g:UltiSnipsEnableSnipMate')
|
||||
if enable_snipmate == '1':
|
||||
|
@ -7,7 +7,7 @@ from test.constant import *
|
||||
class _AnonBase(_VimTest):
|
||||
args = ''
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('inoremap <silent> %s <C-R>=UltiSnips#Anon(%s)<cr>'
|
||||
% (EA, self.args))
|
||||
|
||||
|
@ -22,7 +22,7 @@ class SimpleExpandNewLineAndBackspae_ExpectCorrectResult(_SimpleExpands):
|
||||
keys = 'hallo' + EX + '\nHallo Welt!\n\n\b\b\b\b\b'
|
||||
wanted = 'Hallo Welt!\nHallo We'
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set backspace=eol,start')
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ class VirtualEdit(_VimTest):
|
||||
keys = '\t\t\tpd' + EX + '2'
|
||||
wanted = '\t\t\tpadding: 2px'
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set virtualedit=all')
|
||||
vim_config.append('set noexpandtab')
|
||||
# End: 1251994 #}}}
|
||||
@ -46,7 +46,7 @@ class RetainsTheUnnamedRegister_ButOnlyOnce(_VimTest):
|
||||
|
||||
class ShiftWidthZero(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config += [
|
||||
"if exists('*shiftwidth')",
|
||||
' set shiftwidth=0',
|
||||
|
@ -6,7 +6,7 @@ from test.constant import *
|
||||
|
||||
class FoldingEnabled_SnippetWithFold_ExpectNoFolding(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set foldlevel=0')
|
||||
vim_config.append('set foldmethod=marker')
|
||||
snippets = ('test', r"""Hello {{{
|
||||
@ -37,7 +37,7 @@ class Fold_DeleteMiddleLine_ECR(_VimTest):
|
||||
|
||||
class PerlSyntaxFold(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set foldlevel=0')
|
||||
vim_config.append('syntax enable')
|
||||
vim_config.append('set foldmethod=syntax')
|
||||
|
@ -7,7 +7,7 @@ from test.util import running_on_windows
|
||||
|
||||
class _ExpandTabs(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set expandtab')
|
||||
|
||||
@ -33,8 +33,8 @@ class RecTabStopsWithExpandtab_SpecialIndentProblem_ECR(_ExpandTabs):
|
||||
keys = 'm' + EX + 'm1' + EX + '\nHallo'
|
||||
wanted = ' Something\n Hallo'
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
_ExpandTabs._extra_options_pre_init(self, vim_config)
|
||||
def _extra_vim_config(self, vim_config):
|
||||
_ExpandTabs._extra_vim_config(self, vim_config)
|
||||
vim_config.append('set indentkeys=o,O,*<Return>,<>>,{,}')
|
||||
vim_config.append('set indentexpr=8')
|
||||
# End: ExpandTab #}}}
|
||||
@ -59,7 +59,7 @@ class ProperIndenting_AutoIndentAndNewline_ECR(_VimTest):
|
||||
keys = ' test' + EX + '\n' + 'blah'
|
||||
wanted = ' hui\n blah'
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set autoindent')
|
||||
# Test for bug 1073816
|
||||
|
||||
@ -99,7 +99,7 @@ class ProperIndenting_FirstLineInFileComplete_ECR(
|
||||
|
||||
class _FormatoptionsBase(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set tw=20')
|
||||
vim_config.append('set fo=lrqntc')
|
||||
|
||||
|
@ -283,7 +283,7 @@ i0
|
||||
|
||||
class PythonCode_IndentEtSw(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set expandtab')
|
||||
snippets = ('test', r"""hi
|
||||
@ -307,7 +307,7 @@ i0
|
||||
|
||||
class PythonCode_IndentEtSwOffset(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set expandtab')
|
||||
snippets = ('test', r"""hi
|
||||
@ -331,7 +331,7 @@ End""")
|
||||
|
||||
class PythonCode_IndentNoetSwTs(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set ts=4')
|
||||
snippets = ('test', r"""hi
|
||||
@ -357,7 +357,7 @@ i0
|
||||
|
||||
class PythonCode_OptExists(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('let g:UStest="yes"')
|
||||
snippets = (
|
||||
'test',
|
||||
|
@ -13,7 +13,7 @@ class CursorMovement_Multiline_ECR(_VimTest):
|
||||
|
||||
class CursorMovement_BS_InEditMode(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set backspace=eol,indent,start')
|
||||
snippets = ('<trh', '<tr>\n\t<th>$1</th>\n\t$2\n</tr>\n$3')
|
||||
keys = '<trh' + EX + 'blah' + JF + BS + BS + JF + 'end'
|
||||
|
@ -24,7 +24,7 @@ def python3():
|
||||
# keys = "superlo\ty"
|
||||
# wanted = "Hello"
|
||||
|
||||
# def _extra_options_pre_init(self, vim_config):
|
||||
# def _extra_vim_config(self, vim_config):
|
||||
# # Not sure why, but I need to make a new tab for this to work.
|
||||
# vim_config.append('let g:UltiSnipsExpandTrigger="y"')
|
||||
# vim_config.append('tabnew')
|
||||
@ -47,7 +47,7 @@ def python3():
|
||||
# keys = 'iab\\ t' + EX
|
||||
# wanted = 'iab\\ Hello'
|
||||
|
||||
# def _extra_options_pre_init(self, vim_config):
|
||||
# def _extra_vim_config(self, vim_config):
|
||||
# vim_config.append(r'set iskeyword+=\\ ')
|
||||
# vim_config.append('let g:neocomplete#enable_at_startup = 1')
|
||||
# vim_config.append('let g:neocomplete#enable_smart_case = 1')
|
||||
@ -64,7 +64,7 @@ def python3():
|
||||
# keys = 'iab\\ t=UltiSnipsCallUnite()\n'
|
||||
# wanted = 'iab\\ Hello '
|
||||
|
||||
# def _extra_options_pre_init(self, vim_config):
|
||||
# def _extra_vim_config(self, vim_config):
|
||||
# vim_config.append(r'set iskeyword+=\\ ')
|
||||
# vim_config.append('function! UltiSnipsCallUnite()')
|
||||
# vim_config.append(
|
||||
@ -87,7 +87,7 @@ class Plugin_SuperTab_SimpleTest(_VimTest):
|
||||
# Make sure that UltiSnips has the keymap
|
||||
self.vim.send(':call UltiSnips#map_keys#MapKeys()\n')
|
||||
|
||||
def _extra_options_post_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
assert EX == '\t' # Otherwise this test needs changing.
|
||||
vim_config.append('let g:SuperTabDefaultCompletionType = "<c-p>"')
|
||||
vim_config.append('let g:SuperTabRetainCompletionDuration = "insert"')
|
||||
|
@ -14,7 +14,7 @@ class _SelectModeMappings(_VimTest):
|
||||
do_unmapping = True
|
||||
ignores = []
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append(
|
||||
':let g:UltiSnipsRemoveSelectModeMappings=%i' % int(
|
||||
self.do_unmapping))
|
||||
@ -77,7 +77,7 @@ class SelectModeMappings_BufferLocalMappings_ECR(_SelectModeMappings):
|
||||
|
||||
class _ES_Base(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set selection=exclusive')
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ class ExclusiveSelection_RealWorldCase_Test(_ES_Base):
|
||||
|
||||
class _OS_Base(_VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set selection=old')
|
||||
|
||||
|
||||
|
@ -13,6 +13,17 @@ snippet hello
|
||||
keys = 'hello' + EX
|
||||
wanted = 'This is a test snippet\n# With a comment'
|
||||
|
||||
class snipMate_Disabled(_VimTest):
|
||||
files = { 'snippets/_.snippets': """
|
||||
snippet hello
|
||||
\tThis is a test snippet
|
||||
\t# With a comment"""}
|
||||
keys = 'hello' + EX
|
||||
wanted = 'hello' + EX
|
||||
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append("let g:UltiSnipsEnableSnipMate=0");
|
||||
|
||||
|
||||
class snipMate_OtherFiletype(_VimTest):
|
||||
files = { 'snippets/blubi.snippets': """
|
||||
|
@ -128,7 +128,7 @@ class No_Tab_Expand_Leading_Tabs(_No_Tab_Expand):
|
||||
|
||||
class No_Tab_Expand_No_TS(_No_Tab_Expand):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set sts=3')
|
||||
keys = 'test' + EX
|
||||
@ -137,7 +137,7 @@ class No_Tab_Expand_No_TS(_No_Tab_Expand):
|
||||
|
||||
class No_Tab_Expand_ET(_No_Tab_Expand):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set expandtab')
|
||||
keys = 'test' + EX
|
||||
@ -146,7 +146,7 @@ class No_Tab_Expand_ET(_No_Tab_Expand):
|
||||
|
||||
class No_Tab_Expand_ET_Leading_Spaces(_No_Tab_Expand):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set expandtab')
|
||||
keys = ' test' + EX
|
||||
@ -155,7 +155,7 @@ class No_Tab_Expand_ET_Leading_Spaces(_No_Tab_Expand):
|
||||
|
||||
class No_Tab_Expand_ET_SW(_No_Tab_Expand):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=8')
|
||||
vim_config.append('set expandtab')
|
||||
keys = 'test' + EX
|
||||
@ -164,7 +164,7 @@ class No_Tab_Expand_ET_SW(_No_Tab_Expand):
|
||||
|
||||
class No_Tab_Expand_ET_SW_TS(_No_Tab_Expand):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set sw=3')
|
||||
vim_config.append('set sts=3')
|
||||
vim_config.append('set ts=3')
|
||||
@ -190,7 +190,7 @@ End""")
|
||||
|
||||
class No_Tab_Expand_RealWorld(_TabExpand_RealWorld, _VimTest):
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set noexpandtab')
|
||||
keys = '\t\thi' + EX
|
||||
wanted = """\t\thi
|
||||
|
@ -9,9 +9,8 @@ from test.util import running_on_windows
|
||||
class _AddFuncBase(_VimTest):
|
||||
args = ''
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
vim_config.append(':call UltiSnips#AddSnippetWithPriority(%s)' %
|
||||
self.args)
|
||||
def _before_test(self):
|
||||
self.vim.send(':call UltiSnips#AddSnippetWithPriority(%s)\n' % self.args)
|
||||
|
||||
|
||||
class AddFunc_Simple(_AddFuncBase):
|
||||
@ -42,7 +41,7 @@ and a mirror: hi1
|
||||
hi2...hi3
|
||||
hi4"""
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
vim_config.append('set langmap=dj,rk,nl,ln,jd,kr,DJ,RK,NL,LN,JD,KR')
|
||||
|
||||
# Test for https://bugs.launchpad.net/bugs/501727 #
|
||||
@ -149,7 +148,7 @@ class AddNewSnippetSource(_VimTest):
|
||||
'blumba' + EX
|
||||
)
|
||||
|
||||
def _extra_options_post_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
self._create_file('snippet_source.py', """
|
||||
from UltiSnips.snippet.source import SnippetSource
|
||||
from UltiSnips.snippet.definition import UltiSnipsSnippetDefinition
|
||||
|
@ -52,10 +52,7 @@ class VimTestCase(unittest.TestCase, TempFileManager):
|
||||
self.setUp()
|
||||
self.assertEqual(self.output, wanted)
|
||||
|
||||
def _extra_options_pre_init(self, vim_config):
|
||||
"""Adds extra lines to the vim_config list."""
|
||||
|
||||
def _extra_options_post_init(self, vim_config):
|
||||
def _extra_vim_config(self, vim_config):
|
||||
"""Adds extra lines to the vim_config list."""
|
||||
|
||||
def _before_test(self):
|
||||
@ -131,15 +128,11 @@ class VimTestCase(unittest.TestCase, TempFileManager):
|
||||
(3 if PYTHON3 else 2))
|
||||
vim_config.append('let g:UltiSnipsSnippetDirectories=["us"]')
|
||||
|
||||
self._extra_options_pre_init(vim_config)
|
||||
|
||||
# Now activate UltiSnips.
|
||||
vim_config.append('call UltiSnips#bootstrap#Bootstrap()')
|
||||
|
||||
self._extra_options_post_init(vim_config)
|
||||
self._extra_vim_config(vim_config)
|
||||
|
||||
# Finally, add the snippets and some configuration for the test.
|
||||
vim_config.append('%s << EOF' % ('py3' if PYTHON3 else 'py'))
|
||||
vim_config.append('from UltiSnips import UltiSnips_Manager\n')
|
||||
|
||||
if len(self.snippets) and not isinstance(self.snippets[0], tuple):
|
||||
self.snippets = (self.snippets, )
|
||||
@ -159,6 +152,7 @@ class VimTestCase(unittest.TestCase, TempFileManager):
|
||||
|
||||
# fill buffer with default text and place cursor in between.
|
||||
prefilled_text = (self.text_before + self.text_after).splitlines()
|
||||
vim_config.append('import vim\n')
|
||||
vim_config.append('vim.current.buffer[:] = %r\n' % prefilled_text)
|
||||
vim_config.append(
|
||||
'vim.current.window.cursor = (max(len(vim.current.buffer)//2, 1), 0)')
|
||||
|
Loading…
Reference in New Issue
Block a user