2014-07-19 11:45:44 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
from test.vim_test_case import VimTestCase as _VimTest
|
|
|
|
from test.constant import *
|
|
|
|
|
|
|
|
# snipMate support {{{#
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_SimpleSnippet(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet hello
|
|
|
|
\tThis is a test snippet
|
|
|
|
\t# With a comment"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'hello' + EX
|
|
|
|
wanted = 'This is a test snippet\n# With a comment'
|
|
|
|
|
2015-07-11 10:17:50 -04:00
|
|
|
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");
|
|
|
|
|
2015-01-20 15:26:03 -05:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_OtherFiletype(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/blubi.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet hello
|
|
|
|
\tworked"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'hello' + EX + ESC + ':set ft=blubi\nohello' + EX
|
|
|
|
wanted = 'hello' + EX + '\nworked'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_MultiMatches(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet hello The first snippet."
|
|
|
|
\tone
|
|
|
|
snippet hello The second snippet.
|
|
|
|
\ttwo"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'hello' + EX + '2\n'
|
|
|
|
wanted = 'two'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_SimpleSnippetSubDirectory(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_/blub.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet hello
|
|
|
|
\tThis is a test snippet"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'hello' + EX
|
|
|
|
wanted = 'This is a test snippet'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_SimpleSnippetInSnippetFile(_VimTest):
|
|
|
|
files = {
|
2015-01-20 15:26:03 -05:00
|
|
|
'snippets/_/hello.snippet': """This is a stand alone snippet""",
|
|
|
|
'snippets/_/hello1.snippet': """This is two stand alone snippet""",
|
|
|
|
'snippets/_/hello2/this_is_my_cool_snippet.snippet': """Three""",
|
2014-07-19 11:45:44 -04:00
|
|
|
}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'hello' + EX + '\nhello1' + EX + '\nhello2' + EX
|
|
|
|
wanted = 'This is a stand alone snippet\nThis is two stand alone snippet\nThree'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_Interpolation(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet test
|
|
|
|
\tla`printf('c%02d', 3)`lu"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'lac03lu'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_InterpolationWithSystem(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet test
|
|
|
|
\tla`system('echo -ne öäü')`lu"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'laöäülu'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_TestMirrors(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet for
|
|
|
|
\tfor (${2:i}; $2 < ${1:count}; $1++) {
|
|
|
|
\t\t${4}
|
|
|
|
\t}"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'for' + EX + 'blub' + JF + 'j' + JF + 'hi'
|
|
|
|
wanted = 'for (j; j < blub; blub++) {\n\thi\n}'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_TestMirrorsInPlaceholders(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet opt
|
|
|
|
\t<option value="${1:option}">${2:$1}</option>"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'opt' + EX + 'some' + JF + JF + 'ende'
|
2014-07-19 11:45:44 -04:00
|
|
|
wanted = """<option value="some">some</option>ende"""
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_TestMirrorsInPlaceholders_Overwrite(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet opt
|
|
|
|
\t<option value="${1:option}">${2:$1}</option>"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'opt' + EX + 'some' + JF + 'not' + JF + 'ende'
|
2014-07-19 11:45:44 -04:00
|
|
|
wanted = """<option value="some">not</option>ende"""
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_Visual_Simple(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet v
|
|
|
|
\th${VISUAL}b"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'blablub' + ESC + '0v6l' + EX + 'v' + EX
|
|
|
|
wanted = 'hblablubb'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_NoNestedTabstops(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet test
|
|
|
|
\th$${1:${2:blub}}$$"""}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX + JF + 'hi'
|
|
|
|
wanted = 'h$${2:blub}$$hi'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_Extends(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/a.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
extends b
|
|
|
|
snippet test
|
2015-01-20 15:26:03 -05:00
|
|
|
\tblub""", 'snippets/b.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet test1
|
|
|
|
\tblah"""
|
2015-01-20 15:26:03 -05:00
|
|
|
}
|
|
|
|
keys = ESC + ':set ft=a\n' + 'itest1' + EX
|
|
|
|
wanted = 'blah'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_EmptyLinesContinueSnippets(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet test
|
|
|
|
\tblub
|
|
|
|
|
|
|
|
\tblah
|
|
|
|
|
|
|
|
snippet test1
|
|
|
|
\ta"""
|
2015-01-20 15:26:03 -05:00
|
|
|
}
|
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'blub\n\nblah\n'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class snipMate_OverwrittenByRegExpTrigger(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'snippets/_.snippets': """
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet def
|
|
|
|
\tsnipmate
|
|
|
|
""",
|
2015-01-20 15:26:03 -05:00
|
|
|
'us/all.snippets': r"""
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet "(de)?f" "blub" r
|
|
|
|
ultisnips
|
|
|
|
endsnippet
|
|
|
|
""" }
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'def' + EX
|
|
|
|
wanted = 'ultisnips'
|
2014-07-19 11:45:44 -04:00
|
|
|
# End: snipMate support #}}}
|