I broke up with neovim....vim is my best friend now
This commit is contained in:
149
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip.vimspec
Normal file
149
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip.vimspec
Normal file
@@ -0,0 +1,149 @@
|
||||
let s:expect = themis#helper('expect')
|
||||
|
||||
Describe vsnip
|
||||
|
||||
Describe #get_context
|
||||
|
||||
It should return context information in insert-mode
|
||||
enew!
|
||||
set filetype=basic_spec
|
||||
call setline(1, 'if')
|
||||
call cursor([1, 2])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(mode(1)).to_equal('i')
|
||||
call s:expect(vsnip#get_context()).to_equal({
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 0,
|
||||
\ 'character': 0,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 0,
|
||||
\ 'character': 2,
|
||||
\ },
|
||||
\ },
|
||||
\ 'snippet': {
|
||||
\ 'label': 'if',
|
||||
\ 'description': '',
|
||||
\ 'prefix': ['if'],
|
||||
\ 'prefix_alias': [],
|
||||
\ 'body': [
|
||||
\ "if ${1:condition}",
|
||||
\ "\t$0",
|
||||
\ "endif",
|
||||
\ ],
|
||||
\ }
|
||||
\ })
|
||||
endfunction
|
||||
call feedkeys("a\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should return context information in normal-mode
|
||||
enew!
|
||||
set filetype=basic_spec
|
||||
call setline(1, 'if')
|
||||
call cursor([1, 2])
|
||||
|
||||
call s:expect(mode(1)).to_equal('n')
|
||||
call s:expect(vsnip#get_context()).to_equal({
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 0,
|
||||
\ 'character': 0,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 0,
|
||||
\ 'character': 2,
|
||||
\ },
|
||||
\ },
|
||||
\ 'snippet': {
|
||||
\ 'label': 'if',
|
||||
\ 'description': '',
|
||||
\ 'prefix': ['if'],
|
||||
\ 'prefix_alias': [],
|
||||
\ 'body': [
|
||||
\ "if ${1:condition}",
|
||||
\ "\t$0",
|
||||
\ "endif",
|
||||
\ ],
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
It should return context information in select-mode
|
||||
enew!
|
||||
set filetype=basic_spec
|
||||
call setline(1, 'if')
|
||||
call feedkeys("v\<C-g>", 'x')
|
||||
call cursor([1, 2])
|
||||
|
||||
call s:expect(mode(1)).to_equal('s')
|
||||
call s:expect(vsnip#get_context()).to_equal({
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 0,
|
||||
\ 'character': 0,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 0,
|
||||
\ 'character': 2,
|
||||
\ },
|
||||
\ },
|
||||
\ 'snippet': {
|
||||
\ 'label': 'if',
|
||||
\ 'description': '',
|
||||
\ 'prefix': ['if'],
|
||||
\ 'prefix_alias': [],
|
||||
\ 'body': [
|
||||
\ "if ${1:condition}",
|
||||
\ "\t$0",
|
||||
\ "endif",
|
||||
\ ],
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #get_complete_items
|
||||
|
||||
It should return complete items
|
||||
enew!
|
||||
set filetype=basic_spec
|
||||
call s:expect(vsnip#get_complete_items(bufnr('%'))[-1]).to_equal({
|
||||
\ 'word': 'if',
|
||||
\ 'abbr': 'if',
|
||||
\ 'kind': 'Snippet',
|
||||
\ 'menu': '[v] if',
|
||||
\ 'dup': 1,
|
||||
\ 'user_data': json_encode({
|
||||
\ 'vsnip': {
|
||||
\ 'snippet': [
|
||||
\ "if ${1:condition}",
|
||||
\ "\t$0",
|
||||
\ "endif",
|
||||
\ ]
|
||||
\ }
|
||||
\ })
|
||||
\ }, {
|
||||
\ 'word': 'inline-fn',
|
||||
\ 'abbr': 'inline-fn',
|
||||
\ 'kind': 'Snippet',
|
||||
\ 'menu': '[v] inline-fn',
|
||||
\ 'dup': 1,
|
||||
\ 'user_data': json_encode({
|
||||
\ 'vsnip': {
|
||||
\ 'snippet': [
|
||||
\ "{ -> $1 }$0"
|
||||
\ ]
|
||||
\ }
|
||||
\ })
|
||||
\ })
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
129
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip/indent.vimspec
Normal file
129
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip/indent.vimspec
Normal file
@@ -0,0 +1,129 @@
|
||||
let s:expect = themis#helper('expect')
|
||||
|
||||
Describe vsnip#indent
|
||||
|
||||
After each
|
||||
set expandtab shiftwidth=2
|
||||
End
|
||||
|
||||
Describe #get_one_indent
|
||||
|
||||
It should return one indent
|
||||
enew!
|
||||
for l:execute in [
|
||||
\ 'set expandtab shiftwidth=4 tabstop=2',
|
||||
\ 'set expandtab shiftwidth=2 tabstop=4',
|
||||
\ 'set expandtab shiftwidth=0 tabstop=2',
|
||||
\ 'set noexpandtab shiftwidth=4 tabstop=4',
|
||||
\ ]
|
||||
execute l:execute
|
||||
%delete _
|
||||
call setline(1, '<')
|
||||
normal! >>
|
||||
call s:expect(vsnip#indent#get_one_indent()).to_equal(getline(1)[0 : -2])
|
||||
endfor
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #get_base_indent
|
||||
|
||||
It should return base indent
|
||||
enew!
|
||||
|
||||
call setline(1, ['foo'])
|
||||
call s:expect(vsnip#indent#get_base_indent(getline(1))).to_equal('')
|
||||
|
||||
call setline(1, [' foo'])
|
||||
call s:expect(vsnip#indent#get_base_indent(getline(1))).to_equal(' ')
|
||||
|
||||
call setline(1, ["\tfoo"])
|
||||
call s:expect(vsnip#indent#get_base_indent(getline(1))).to_equal("\t")
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #adjust_snippet_body
|
||||
|
||||
It should return adjusted snippet body for expandtab
|
||||
set expandtab shiftwidth=2
|
||||
call s:expect(vsnip#indent#adjust_snippet_body(' foo', join([
|
||||
\ "class $1 {",
|
||||
\ "\tpublic constructor() {",
|
||||
\ "\t\t$0",
|
||||
\ "\t}",
|
||||
\ "}"
|
||||
\ ], "\n"))).to_equal(join([
|
||||
\ "class $1 {",
|
||||
\ " public constructor() {",
|
||||
\ " $0",
|
||||
\ " }",
|
||||
\ " }"
|
||||
\ ], "\n"))
|
||||
End
|
||||
|
||||
It should return adjusted snippet body for noexpandtab
|
||||
set noexpandtab shiftwidth=2
|
||||
call s:expect(vsnip#indent#adjust_snippet_body("\tfoo", join([
|
||||
\ "class $1 {",
|
||||
\ "\tpublic constructor() {",
|
||||
\ "\t\t$0",
|
||||
\ "\t}",
|
||||
\ "}"
|
||||
\ ], "\n"))).to_equal(join([
|
||||
\ "class $1 {",
|
||||
\ "\t\tpublic constructor() {",
|
||||
\ "\t\t\t$0",
|
||||
\ "\t\t}",
|
||||
\ "\t}"
|
||||
\ ], "\n"))
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #trim_base_indent
|
||||
|
||||
It should trim base indent when target is line-wise multiline text
|
||||
call s:expect(vsnip#indent#trim_base_indent(join([
|
||||
\ " function! s:foo()",
|
||||
\ " return 'foo'",
|
||||
\ " endfunction"
|
||||
\ ], "\n") . "\n")).to_equal(join([
|
||||
\ "function! s:foo()",
|
||||
\ " return 'foo'",
|
||||
\ "endfunction"
|
||||
\ ], "\n"))
|
||||
End
|
||||
|
||||
It should trim base indent when target is char-wise multiline text
|
||||
call s:expect(vsnip#indent#trim_base_indent(join([
|
||||
\ "function! s:foo()",
|
||||
\ " return 'foo'",
|
||||
\ " endfunction"
|
||||
\ ], "\n"))).to_equal(join([
|
||||
\ "function! s:foo()",
|
||||
\ " return 'foo'",
|
||||
\ "endfunction"
|
||||
\ ], "\n"))
|
||||
End
|
||||
|
||||
It should trim base indent when target is line-wise singleline selection
|
||||
call s:expect(vsnip#indent#trim_base_indent(join([
|
||||
\ " function! s:foo()",
|
||||
\ ], "\n") . "\n")).to_equal(join([
|
||||
\ "function! s:foo()",
|
||||
\ ], "\n"))
|
||||
End
|
||||
|
||||
It should trim base indent when target is char-wise singleline selection
|
||||
call s:expect(vsnip#indent#trim_base_indent(join([
|
||||
\ " function! s:foo()",
|
||||
\ ], "\n"))).to_equal(join([
|
||||
\ " function! s:foo()",
|
||||
\ ], "\n"))
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
573
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip/snippet.vimspec
Normal file
573
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip/snippet.vimspec
Normal file
@@ -0,0 +1,573 @@
|
||||
let s:expect = themis#helper('expect')
|
||||
let s:Snippet = vsnip#snippet#import()
|
||||
|
||||
let s:start_position = {
|
||||
\ 'line': 1,
|
||||
\ 'character': 1
|
||||
\ }
|
||||
|
||||
Describe vsnip#snippet
|
||||
|
||||
Describe #init
|
||||
|
||||
It should mark follower placeholders
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1:default}, $1, $1)')
|
||||
call s:expect(l:snippet.children[3].follower).to_equal(v:true)
|
||||
call s:expect(l:snippet.children[5].follower).to_equal(v:true)
|
||||
End
|
||||
|
||||
It should add final tabstop
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log($1)')
|
||||
call s:expect(l:snippet.children[3].is_final).to_equal(v:true)
|
||||
End
|
||||
|
||||
It should convert variable to placeholder
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${variable:default}, $variable)')
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(default, default)')
|
||||
call s:expect(l:snippet.children[3].follower).to_equal(v:true)
|
||||
End
|
||||
|
||||
It should resolve known variables
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${CURRENT_YEAR})')
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(' . strftime('%Y') . ')')
|
||||
End
|
||||
|
||||
It should support whole word transform
|
||||
let l:snippet = s:Snippet.new(s:start_position, '${1:state}, set${1/(.*)/${1:/capitalize}/}')
|
||||
call s:expect(l:snippet.text()).to_equal('state, setState')
|
||||
End
|
||||
End
|
||||
|
||||
Describe #sync
|
||||
|
||||
It should sync placeholder text in same tabstop groups
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1:default}, $1)')
|
||||
call l:snippet.follow(0, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 13
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 17
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': '___'
|
||||
\ })
|
||||
call l:snippet.sync()
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(___ult, ___ult)')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #follow
|
||||
|
||||
It should not affect following empty diff
|
||||
let l:snippet = s:Snippet.new(s:start_position, "class $1 {\n\tpublic ${2:default}() {\n\t\t$0\n\t}\n}")
|
||||
let l:followed = l:snippet.follow(0, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 1
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 1
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': ''
|
||||
\ })
|
||||
call s:expect(l:followed).to_equal(v:true)
|
||||
call s:expect(l:snippet.text()).to_equal("class {\n\tpublic default() {\n\t\t\n\t}\n}")
|
||||
End
|
||||
|
||||
It should follow when diff range covers whole of snippet
|
||||
let l:snippet = s:Snippet.new(s:start_position, "class $1 {\n\tpublic ${2:default}() {\n\t\t$0\n\t}\n}")
|
||||
let l:followed = l:snippet.follow(0, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 1
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 5,
|
||||
\ 'character': 1
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': ''
|
||||
\ })
|
||||
call s:expect(l:followed).to_equal(v:true)
|
||||
call s:expect(l:snippet.text()).to_equal("")
|
||||
End
|
||||
|
||||
It should squash placeholder when diff range covers multiple placeholders
|
||||
let l:snippet = s:Snippet.new(s:start_position, "console.log(${1:first}, ${2:second})")
|
||||
call s:expect(l:snippet.get_placeholder_nodes()).to_have_length(3)
|
||||
let l:followed = l:snippet.follow(0, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 13
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 26
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': ''
|
||||
\ })
|
||||
call s:expect(l:followed).to_equal(v:true)
|
||||
call s:expect(l:snippet.get_placeholder_nodes()).to_have_length(2)
|
||||
call s:expect(l:snippet.text()).to_equal('console.log()')
|
||||
End
|
||||
|
||||
It should not squash placeholder when diff range includes multiple placeholders but last one does not covered
|
||||
let l:snippet = s:Snippet.new(s:start_position, "console.log(${1:first}, ${2:second})")
|
||||
call s:expect(l:snippet.get_placeholder_nodes()).to_have_length(3)
|
||||
let l:followed = l:snippet.follow(0, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 13
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 25
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': ''
|
||||
\ })
|
||||
call s:expect(l:followed).to_equal(v:true)
|
||||
call s:expect(l:snippet.get_placeholder_nodes()).to_have_length(3)
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(d)')
|
||||
End
|
||||
|
||||
It should prefer current placeholder
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1}, ${2:, ${3:default}})')
|
||||
let l:followed = l:snippet.follow(3, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 17
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 17
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': '___'
|
||||
\ })
|
||||
call s:expect(l:followed).to_equal(v:true)
|
||||
call s:expect(l:snippet.get_placeholder_nodes()[2].text()).to_equal('___default')
|
||||
End
|
||||
|
||||
It should follow when diff range is within one node range
|
||||
let l:snippet = s:Snippet.new(s:start_position, "class $1 {\n\tpublic ${2:default}() {\n\t\t$0\n\t}\n}")
|
||||
call l:snippet.follow(0, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 2,
|
||||
\ 'character': 9
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 2,
|
||||
\ 'character': 12
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': '___'
|
||||
\ })
|
||||
call s:expect(l:snippet.text()).to_equal("class {\n\tpublic d___ult() {\n\t\t\n\t}\n}")
|
||||
call s:expect(l:snippet.get_next_jump_point(1).placeholder.text()).to_equal('d___ult')
|
||||
End
|
||||
|
||||
It should follow when diff range included only text node
|
||||
let l:snippet = s:Snippet.new(s:start_position, "class $1 {\n\tpublic ${2:default}() {\n\t\t$0\n\t}\n}")
|
||||
call l:snippet.follow(1, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 1
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 6
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': 'modified'
|
||||
\ })
|
||||
call s:expect(l:snippet.text()).to_equal("modified {\n\tpublic default() {\n\t\t\n\t}\n}")
|
||||
End
|
||||
|
||||
It should prefer placeholder node than text node when both followable (left)
|
||||
let l:snippet = s:Snippet.new(s:start_position, '[${1:text1}][${2:text2}][${3:text3}]')
|
||||
call l:snippet.follow(1, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 9
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 9
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': '___'
|
||||
\ })
|
||||
call s:expect(l:snippet.text()).to_equal('[text1][___text2][text3]')
|
||||
call s:expect(l:snippet.children[3].text()).to_equal('___text2')
|
||||
End
|
||||
|
||||
It should prefer placeholder node than text node when both followable (right)
|
||||
let l:snippet = s:Snippet.new(s:start_position, '[${1:text1}][${2:text2}][${3:text3}]')
|
||||
call l:snippet.follow(1, {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 14
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 14
|
||||
\ }
|
||||
\ },
|
||||
\ 'text': '___'
|
||||
\ })
|
||||
call s:expect(l:snippet.text()).to_equal('[text1][text2___][text3]')
|
||||
call s:expect(l:snippet.children[3].text()).to_equal('text2___')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #text
|
||||
|
||||
It should return text1
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log($0${1:default})')
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(default)')
|
||||
End
|
||||
|
||||
It should return text2
|
||||
call vsnip#selected_text('THIS_IS_SELECTED_TEXT')
|
||||
let l:snippet = s:Snippet.new(s:start_position, '$TM_SELECTED_TEXT')
|
||||
call s:expect(l:snippet.text()).to_equal('THIS_IS_SELECTED_TEXT')
|
||||
End
|
||||
|
||||
It should return text2
|
||||
call vsnip#selected_text('THIS_IS_SELECTED_TEXT')
|
||||
let l:snippet = s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT}')
|
||||
call s:expect(l:snippet.text()).to_equal('THIS_IS_SELECTED_TEXT')
|
||||
End
|
||||
|
||||
It should return text3
|
||||
call vsnip#selected_text('')
|
||||
let l:snippet = s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT:default}')
|
||||
call s:expect(l:snippet.text()).to_equal('default')
|
||||
End
|
||||
|
||||
It should support whole word transform (upcase) on tabstop
|
||||
let l:snippet = s:Snippet.new(s:start_position, '${1:varName}, ${1/(.*)/${1:/upcase}/}')
|
||||
call s:expect(l:snippet.text()).to_equal('varName, VARNAME')
|
||||
End
|
||||
|
||||
It should support whole word transform (downcase) on variable
|
||||
call vsnip#selected_text('varName')
|
||||
let l:snippet = s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/downcase}/}')
|
||||
call s:expect(l:snippet.text()).to_equal('varname')
|
||||
End
|
||||
|
||||
It should support whole word transform (capitalize)
|
||||
call vsnip#selected_text('varName')
|
||||
let l:snippet = s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/capitalize}/}')
|
||||
call s:expect(l:snippet.text()).to_equal('VarName')
|
||||
End
|
||||
|
||||
It should support whole word transform (camelcase)
|
||||
call vsnip#selected_text('var_name')
|
||||
call s:expect(
|
||||
\ s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/camelcase}/}').text()
|
||||
\ ).to_equal('varName')
|
||||
|
||||
call vsnip#selected_text('VAR_NAME')
|
||||
call s:expect(
|
||||
\ s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/camelcase}/}').text()
|
||||
\ ).to_equal('varName')
|
||||
|
||||
call vsnip#selected_text('VarName')
|
||||
call s:expect(
|
||||
\ s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/camelcase}/}').text()
|
||||
\ ).to_equal('varName')
|
||||
End
|
||||
|
||||
It should support whole word transform (pascalcase)
|
||||
call vsnip#selected_text('var_name')
|
||||
call s:expect(
|
||||
\ s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/pascalcase}/}').text()
|
||||
\ ).to_equal('VarName')
|
||||
|
||||
call vsnip#selected_text('VAR_NAME')
|
||||
call s:expect(
|
||||
\ s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/pascalcase}/}').text()
|
||||
\ ).to_equal('VarName')
|
||||
|
||||
call vsnip#selected_text('varName')
|
||||
call s:expect(
|
||||
\ s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/${1:/pascalcase}/}').text()
|
||||
\ ).to_equal('VarName')
|
||||
End
|
||||
|
||||
It should support whole word transform with additional text
|
||||
call vsnip#selected_text('varName')
|
||||
let l:snippet = s:Snippet.new(s:start_position, '${TM_SELECTED_TEXT/(.*)/start-lowercase-${1:/downcase}/}-end')
|
||||
call s:expect(l:snippet.text()).to_equal('start-lowercase-varname-end')
|
||||
End
|
||||
End
|
||||
|
||||
Describe #range
|
||||
|
||||
It should return range1
|
||||
let l:snippet = s:Snippet.new(s:start_position, "01234\n56789")
|
||||
call s:expect(l:snippet.range()).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': s:start_position.line,
|
||||
\ 'character': s:start_position.character
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': s:start_position.line + 1,
|
||||
\ 'character': 5
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
It should return range2
|
||||
let l:snippet = s:Snippet.new(s:start_position, "012345")
|
||||
call s:expect(l:snippet.range()).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': s:start_position.line,
|
||||
\ 'character': s:start_position.character
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': s:start_position.line,
|
||||
\ 'character': 7
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #offset_to_position
|
||||
|
||||
It should return position from offset
|
||||
let l:snippet = s:Snippet.new(s:start_position, "class クラス {\n\tpublic constructor() {\n\t\t$0\n\t}\n}")
|
||||
call s:expect(l:snippet.offset_to_position(13)).to_equal({
|
||||
\ 'line': 2,
|
||||
\ 'character': 1
|
||||
\ })
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #position_to_offset
|
||||
|
||||
It should return offset from position
|
||||
let l:snippet = s:Snippet.new(s:start_position, "class クラス {\n\tpublic constructor() {\n\t\t$0\n\t}\n}")
|
||||
call s:expect(l:snippet.position_to_offset({
|
||||
\ 'line': 2,
|
||||
\ 'character': 1
|
||||
\ })).to_equal(13)
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #normalize
|
||||
|
||||
It should not normalize when does not exists adjacent text nodes
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1:i}${2:++})')
|
||||
let l:text = l:snippet.text()
|
||||
call s:expect(len(l:snippet.children)).to_equal(5)
|
||||
call l:snippet.normalize()
|
||||
call s:expect(len(l:snippet.children)).to_equal(5)
|
||||
call s:expect(l:text).to_equal(l:snippet.text())
|
||||
End
|
||||
|
||||
It should normalize adjacent text nodes
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log')
|
||||
call insert(l:snippet.children, vsnip#snippet#node#create_text('___'), 1)
|
||||
let l:text = l:snippet.text()
|
||||
call s:expect(len(l:snippet.children)).to_equal(3)
|
||||
call l:snippet.normalize()
|
||||
call s:expect(len(l:snippet.children)).to_equal(2)
|
||||
call s:expect(l:text).to_equal(l:snippet.text())
|
||||
End
|
||||
|
||||
It should normalize correctly when the node has the same structure children
|
||||
let l:snippet = s:Snippet.new(s:start_position, '')
|
||||
let l:snippet.children = vsnip#snippet#node#create_from_ast([{
|
||||
\ 'type': 'text',
|
||||
\ 'value': '*',
|
||||
\ 'escaped': '*',
|
||||
\ }, {
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 1,
|
||||
\ 'children': [{
|
||||
\ 'type': 'text',
|
||||
\ 'value': '',
|
||||
\ 'escaped': '',
|
||||
\ }]
|
||||
\ }, {
|
||||
\ 'type': 'text',
|
||||
\ 'value': '*',
|
||||
\ 'escaped': '*',
|
||||
\ }, {
|
||||
\ 'type': 'text',
|
||||
\ 'value': '_',
|
||||
\ 'escaped': '_',
|
||||
\ }, {
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 1,
|
||||
\ 'children': [{
|
||||
\ 'type': 'text',
|
||||
\ 'value': '',
|
||||
\ 'escaped': '',
|
||||
\ }]
|
||||
\ }, {
|
||||
\ 'type': 'text',
|
||||
\ 'value': '*',
|
||||
\ 'escaped': '*',
|
||||
\ }, {
|
||||
\ 'type': 'text',
|
||||
\ 'value': '__',
|
||||
\ 'escaped': '__',
|
||||
\ }])
|
||||
let l:text = l:snippet.text()
|
||||
call l:snippet.normalize()
|
||||
call s:expect(l:text).to_equal(l:snippet.text())
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #insert
|
||||
|
||||
It should insert node 1
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1}, ${2:${1}})')
|
||||
call l:snippet.insert({ 'line': 1, 'character': 13 }, s:Snippet.new(s:start_position, 'console.log(${3}, ${4:${3}})').children)
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(console.log(, ), )')
|
||||
End
|
||||
|
||||
It should insert node 2
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1}, ${2:${1}})')
|
||||
call l:snippet.insert({ 'line': 1, 'character': 15 }, s:Snippet.new(s:start_position, 'console.log()').children)
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(, console.log())')
|
||||
call s:expect(len(l:snippet.get_placeholder_nodes())).to_equal(5)
|
||||
End
|
||||
|
||||
It should insert node 3
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(aiueo)')
|
||||
call l:snippet.insert({ 'line': 1, 'character': 13 }, s:Snippet.new(s:start_position, '___').children)
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(___aiueo)')
|
||||
End
|
||||
|
||||
It should insert node 4
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(aiueo)')
|
||||
call l:snippet.insert({ 'line': 1, 'character': 15 }, s:Snippet.new(s:start_position, '___').children)
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(ai___ueo)')
|
||||
End
|
||||
|
||||
It should insert node 5
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(aiueo)')
|
||||
call l:snippet.insert({ 'line': 1, 'character': 18 }, [vsnip#snippet#node#create_text('___')])
|
||||
call s:expect(l:snippet.text()).to_equal('console.log(aiueo___)')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #get_next_jump_point
|
||||
|
||||
It should return next jump point 1
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1:012345})')
|
||||
call s:expect(l:snippet.get_next_jump_point(0).range).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 13
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 19
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
It should return next jump point 2
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1:0123${2:456}7890})')
|
||||
call s:expect(l:snippet.get_next_jump_point(0).range).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 13
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 24
|
||||
\ }
|
||||
\ })
|
||||
call s:expect(l:snippet.get_next_jump_point(1).range).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 17,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 20
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
It should return next jump point 3
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(${1:0${3:12}3${2:456}7890})')
|
||||
call s:expect(l:snippet.get_next_jump_point(0).range).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 13
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 24
|
||||
\ }
|
||||
\ })
|
||||
call s:expect(l:snippet.get_next_jump_point(1).range).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 17,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 20
|
||||
\ }
|
||||
\ })
|
||||
call s:expect(l:snippet.get_next_jump_point(2).range).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 14,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 16
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
It should return next jump point 4
|
||||
let l:snippet = s:Snippet.new(s:start_position, 'console.log(0${1}123456789${1}0)')
|
||||
call s:expect(l:snippet.get_next_jump_point(0).range).to_equal({
|
||||
\ 'start': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 14
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 1,
|
||||
\ 'character': 14
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
@@ -0,0 +1,231 @@
|
||||
let s:expect = themis#helper('expect')
|
||||
|
||||
Describe vsnip#snippet#parser
|
||||
|
||||
Describe #parse
|
||||
|
||||
It should parse text
|
||||
let l:parsed = vsnip#snippet#parser#parse('console.log()')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'console.log()',
|
||||
\ 'escaped': 'console.log()'
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse tabstop
|
||||
let l:parsed = vsnip#snippet#parser#parse('console.log($0$1${1/(.*)/${1:/capitalize}/})')
|
||||
call s:expect(len(l:parsed)).to_equal(5)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'console.log(',
|
||||
\ 'escaped': 'console.log('
|
||||
\ })
|
||||
call s:expect(l:parsed[1]).to_equal({
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 0,
|
||||
\ 'children': []
|
||||
\ })
|
||||
call s:expect(l:parsed[2]).to_equal({
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 1,
|
||||
\ 'children': []
|
||||
\ })
|
||||
call s:expect(l:parsed[3]).to_equal({
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 1,
|
||||
\ 'children': [],
|
||||
\ 'transform': {
|
||||
\ 'type': 'transform',
|
||||
\ 'regex': {
|
||||
\ 'type': 'regex',
|
||||
\ 'pattern': '(.*)',
|
||||
\ },
|
||||
\ 'format': [{
|
||||
\ 'type': 'format',
|
||||
\ 'id': 1,
|
||||
\ 'modifier': '/capitalize'
|
||||
\ }],
|
||||
\ 'option': v:null
|
||||
\ }
|
||||
\ })
|
||||
call s:expect(l:parsed[4]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': ')',
|
||||
\ 'escaped': ')'
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse choice
|
||||
let l:parsed = vsnip#snippet#parser#parse("${1|log,warn,error|}")
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 1,
|
||||
\ 'choice': [{
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'log',
|
||||
\ 'escaped': 'log'
|
||||
\ }, {
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'warn',
|
||||
\ 'escaped': 'warn'
|
||||
\ }, {
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'error',
|
||||
\ 'escaped': 'error'
|
||||
\ }],
|
||||
\ 'children': [{
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'log',
|
||||
\ 'escaped': 'log'
|
||||
\ }]
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse complex escaped chars
|
||||
let l:parsed = vsnip#snippet#parser#parse('\\\$variable\}')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': '\\\$variable\}',
|
||||
\ 'escaped': '\$variable}'
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse escapable char
|
||||
let l:parsed = vsnip#snippet#parser#parse('{\}')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': '{\}',
|
||||
\ 'escaped': '{}'
|
||||
\ })
|
||||
End
|
||||
|
||||
It should not remove unmeaningful escape
|
||||
let l:parsed = vsnip#snippet#parser#parse('\{}')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': '\{}',
|
||||
\ 'escaped': '\{}'
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse omitted backslash for the escapable non-stop char
|
||||
let l:parsed = vsnip#snippet#parser#parse('{}')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': '{}',
|
||||
\ 'escaped': '{}'
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse nested placeholder
|
||||
let l:parsed = vsnip#snippet#parser#parse('class $1${2: extends ${3:SuperClass}} { $0 }')
|
||||
call s:expect(len(l:parsed)).to_equal(6)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'class ',
|
||||
\ 'escaped': 'class '
|
||||
\ })
|
||||
call s:expect(l:parsed[1]).to_equal({
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 1,
|
||||
\ 'children': []
|
||||
\ })
|
||||
call s:expect(l:parsed[2]).to_equal({
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 2,
|
||||
\ 'children': [{
|
||||
\ 'type': 'text',
|
||||
\ 'raw': ' extends ',
|
||||
\ 'escaped': ' extends '
|
||||
\ }, {
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 3,
|
||||
\ 'children': [{
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'SuperClass',
|
||||
\ 'escaped': 'SuperClass'
|
||||
\ }]
|
||||
\ }]
|
||||
\ })
|
||||
call s:expect(l:parsed[3]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': ' { ',
|
||||
\ 'escaped': ' { '
|
||||
\ })
|
||||
call s:expect(l:parsed[4]).to_equal({
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 0,
|
||||
\ 'children': []
|
||||
\ })
|
||||
call s:expect(l:parsed[5]).to_equal({
|
||||
\ 'type': 'text',
|
||||
\ 'raw': ' }',
|
||||
\ 'escaped': ' }'
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse simple variable
|
||||
let l:parsed = vsnip#snippet#parser#parse('${variable:default}')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'variable',
|
||||
\ 'name': 'variable',
|
||||
\ 'children': [{
|
||||
\ 'type': 'text',
|
||||
\ 'raw': 'default',
|
||||
\ 'escaped': 'default',
|
||||
\ }]
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse variable with multiple children
|
||||
let l:parsed = vsnip#snippet#parser#parse('${variable: $1}')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'variable',
|
||||
\ 'name': 'variable',
|
||||
\ 'children': [{
|
||||
\ 'type': 'text',
|
||||
\ 'raw': ' ',
|
||||
\ 'escaped': ' ',
|
||||
\ }, {
|
||||
\ 'type': 'placeholder',
|
||||
\ 'id': 1,
|
||||
\ 'children': []
|
||||
\ }],
|
||||
\ })
|
||||
End
|
||||
|
||||
It should parse variable with regex
|
||||
let l:parsed = vsnip#snippet#parser#parse('${variable/(.*)/${1:/capitalize}/}')
|
||||
call s:expect(len(l:parsed)).to_equal(1)
|
||||
call s:expect(l:parsed[0]).to_equal({
|
||||
\ 'type': 'variable',
|
||||
\ 'name': 'variable',
|
||||
\ 'children': [],
|
||||
\ 'transform': {
|
||||
\ 'type': 'transform',
|
||||
\ 'regex': {
|
||||
\ 'type': 'regex',
|
||||
\ 'pattern': '(.*)',
|
||||
\ },
|
||||
\ 'format': [{
|
||||
\ 'type': 'format',
|
||||
\ 'id': 1,
|
||||
\ 'modifier': '/capitalize'
|
||||
\ }],
|
||||
\ 'option': v:null
|
||||
\ }
|
||||
\ })
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
97
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip/source.vimspec
Normal file
97
dot_vim/plugged/vim-vsnip/spec/autoload/vsnip/source.vimspec
Normal file
@@ -0,0 +1,97 @@
|
||||
let s:expect = themis#helper('expect')
|
||||
|
||||
Describe vsnip#source
|
||||
|
||||
Describe #filetypes
|
||||
|
||||
It should return all filetype
|
||||
enew!
|
||||
set filetype=javascript.jsx
|
||||
call s:expect(vsnip#source#filetypes(bufnr('%'))).to_equal([
|
||||
\ 'javascript',
|
||||
\ 'jsx',
|
||||
\ 'global'
|
||||
\ ])
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #find
|
||||
|
||||
It should load snippet for extended filetypes
|
||||
enew!
|
||||
set filetype=source_spec_enhanced
|
||||
let l:snippets = vsnip#source#find(bufnr('%'))
|
||||
call s:expect(l:snippets[0]).to_have_length(2)
|
||||
End
|
||||
|
||||
It should load snippet from vscode extension
|
||||
enew!
|
||||
set filetype=source_spec_vscode
|
||||
let l:snippets = vsnip#source#find(bufnr('%'))
|
||||
call s:expect(l:snippets[0]).to_have_length(1)
|
||||
End
|
||||
|
||||
It should format snippets
|
||||
enew!
|
||||
set filetype=source_spec
|
||||
let l:snippets = vsnip#source#find(bufnr('%'))
|
||||
call s:expect(sort(l:snippets[0])).to_equal(sort([{
|
||||
\ 'label': 'no-prefix-alias',
|
||||
\ 'description': '',
|
||||
\ 'prefix': ['---'],
|
||||
\ 'prefix_alias': [],
|
||||
\ 'body': [
|
||||
\ "${VIM:repeat('-', &tw)}"
|
||||
\ ]
|
||||
\ }, {
|
||||
\ 'label': 'prefix-alias',
|
||||
\ 'description': '',
|
||||
\ 'prefix': ['arrow-function'],
|
||||
\ 'prefix_alias': ['af'],
|
||||
\ 'body': [
|
||||
\ "() => "
|
||||
\ ]
|
||||
\ }]))
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe #snipmate
|
||||
|
||||
It should load snippets
|
||||
enew!
|
||||
set filetype=snipmate
|
||||
let l:snippets = vsnip#source#find(bufnr('%'))
|
||||
call s:expect(l:snippets[0]).to_have_length(2)
|
||||
End
|
||||
|
||||
It should format snippets
|
||||
enew!
|
||||
set filetype=snipmate
|
||||
let l:snippets = vsnip#source#find(bufnr('%'))
|
||||
call s:expect(sort(l:snippets[0])).to_equal(sort([{
|
||||
\ 'label': 'arrow-function',
|
||||
\ 'description': '',
|
||||
\ 'prefix': ['arrow-function'],
|
||||
\ 'prefix_alias': ['af'],
|
||||
\ 'body': [
|
||||
\ "() => "
|
||||
\ ]
|
||||
\ }, {
|
||||
\ 'label': 'fn',
|
||||
\ 'description': "vim's function",
|
||||
\ 'prefix': ['fn'],
|
||||
\ 'prefix_alias': [],
|
||||
\ 'body': [
|
||||
\ "function! $1($2) abort",
|
||||
\ "\t$0",
|
||||
\ "endfunction",
|
||||
\ ]
|
||||
\ }]))
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
709
dot_vim/plugged/vim-vsnip/spec/plugin/vsnip.vimspec
Normal file
709
dot_vim/plugged/vim-vsnip/spec/plugin/vsnip.vimspec
Normal file
@@ -0,0 +1,709 @@
|
||||
let s:expect = themis#helper('expect')
|
||||
|
||||
function! s:expect_selection(s, e) abort
|
||||
if &selection ==# 'exclusive' && &virtualedit ==# ''
|
||||
return
|
||||
endif
|
||||
|
||||
call s:expect(getpos("'<")[1 : 2]).to_equal([a:s[0], a:s[1]])
|
||||
if &selection ==# 'exclusive'
|
||||
let l:text = getline('.')
|
||||
let l:char = strcharpart(l:text, charidx(l:text, a:e[1] - 1), 1)
|
||||
let a:e[1] = a:e[1] + strlen(l:char)
|
||||
endif
|
||||
call s:expect(getpos("'>")[1 : 2]).to_equal([a:e[0], a:e[1]])
|
||||
endfunction
|
||||
|
||||
Describe vsnip
|
||||
|
||||
After each
|
||||
call vsnip#deactivate()
|
||||
End
|
||||
|
||||
Context expand
|
||||
|
||||
It should expand when prefix start col is 1
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec1')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 8])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should expand when prefix is in middle of line
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, '(spec1)')
|
||||
call cursor([1, 6])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['(snippet)'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should expand when prefix was selected in select-mode
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec1')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("v$\<C-g>\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should not expand when prefix is word and it does not separate by word boundary
|
||||
enew!
|
||||
set filetype=integration
|
||||
set iskeyword=@,48-57,_,192-255
|
||||
call setline(1, '(aspec1)')
|
||||
call cursor([1, 7])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['(aspec1', ')'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should jump to first placeholder when expanded snippet
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec2')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 1])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Context jump
|
||||
|
||||
It should jump to first of snippet
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec2')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 1])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should jump to middle of snippet
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec3')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 4])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should jump to last of snippet
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec4')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 8])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should select 1 length first of snippet text
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec5')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 1], [1, 1])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should select 1 length middle of snippet text
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec6')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 3], [1, 3])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should select 1 length last of snippet text
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec7')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 7], [1, 7])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should select 3 length first of snippet text
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec8')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 1], [1, 3])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should select 3 length middle of snippet text
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec9')
|
||||
call cursor([1, 5])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 3], [1, 5])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should select 3 length last of snippet text
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'spec10')
|
||||
call cursor([1, 6])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 5], [1, 7])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Context multibyte
|
||||
|
||||
It should jump to middle of snippet
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'マルチ1')
|
||||
call cursor([1, 10])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 7])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['あいう'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should select 4 length middle of snippet text
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'マルチ2')
|
||||
call cursor([1, 10])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 7], [1, 12])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['あいかkaかう'])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Context g:vsnip_deactivate_on
|
||||
It should deactivate snippet on edit the outside of snippet
|
||||
enew!
|
||||
set filetype=integration
|
||||
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfSnippet
|
||||
|
||||
call setline(1, [
|
||||
\ 'outside',
|
||||
\ 'deactivate',
|
||||
\ 'outside',
|
||||
\ ])
|
||||
call cursor([2, 11])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
let l:sequence = ''
|
||||
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(vsnip#get_session()).not.to_be_empty()
|
||||
endfunction
|
||||
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
||||
|
||||
function g:vsnip_assert.step2()
|
||||
call s:expect(vsnip#get_session()).not.to_be_empty()
|
||||
endfunction
|
||||
let l:sequence .= "funcname\<Plug>(vsnip-assert)"
|
||||
|
||||
function g:vsnip_assert.step3()
|
||||
call s:expect(vsnip#get_session()).not.to_be_empty()
|
||||
endfunction
|
||||
let l:sequence .= "\<Tab>return 1\<Plug>(vsnip-assert)"
|
||||
|
||||
function g:vsnip_assert.step4()
|
||||
call s:expect(vsnip#get_session()).to_be_empty()
|
||||
endfunction
|
||||
let l:sequence .= "\<Cmd>call cursor([1, 1])\<CR>modified\<Esc>"
|
||||
|
||||
call feedkeys(l:sequence, 'x')
|
||||
|
||||
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfSnippet
|
||||
End
|
||||
|
||||
It should deactivate snippet on edit the outside of current tabstop
|
||||
enew!
|
||||
set filetype=integration
|
||||
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfCurrentTabstop
|
||||
|
||||
call setline(1, [
|
||||
\ 'outside',
|
||||
\ 'deactivate',
|
||||
\ 'outside',
|
||||
\ ])
|
||||
call cursor([2, 11])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
let l:sequence = ''
|
||||
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(vsnip#get_session()).not.to_be_empty()
|
||||
endfunction
|
||||
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
||||
|
||||
function g:vsnip_assert.step2()
|
||||
call s:expect(vsnip#get_session()).not.to_be_empty()
|
||||
endfunction
|
||||
let l:sequence .= "funcname\<Plug>(vsnip-assert)"
|
||||
|
||||
function g:vsnip_assert.step3()
|
||||
call s:expect(vsnip#get_session()).to_be_empty()
|
||||
endfunction
|
||||
let l:sequence .= "\<Right>arguments\<Plug>(vsnip-assert)"
|
||||
|
||||
call feedkeys(l:sequence, 'x')
|
||||
|
||||
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfSnippet
|
||||
End
|
||||
End
|
||||
|
||||
Context realworld
|
||||
|
||||
It should work (complex example)
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'realworld1')
|
||||
call cursor([1, 10])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
let l:sequence = ''
|
||||
|
||||
" expand and jump
|
||||
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ '/** @class ClassName */',
|
||||
\ 'class ClassName extends ParentClassName {',
|
||||
\ ' public constructor() {',
|
||||
\ ' ',
|
||||
\ ' }',
|
||||
\ '}',
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" sync placeholder
|
||||
let l:sequence .= "ModifiedClassName\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step2()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ '/** @class ModifiedClassName */',
|
||||
\ 'class ModifiedClassName extends ParentClassName {',
|
||||
\ ' public constructor() {',
|
||||
\ ' ',
|
||||
\ ' }',
|
||||
\ '}',
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" edit nested placeholder
|
||||
let l:sequence .= "\<Tab>\<Tab>ModifiedParentClassName\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step3()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ '/** @class ModifiedClassName */',
|
||||
\ 'class ModifiedClassName extends ModifiedParentClassName {',
|
||||
\ ' public constructor() {',
|
||||
\ ' ',
|
||||
\ ' }',
|
||||
\ '}',
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" remove nested placeholder by <BS>
|
||||
let l:sequence .= "\<S-Tab>\<BS>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step4()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ '/** @class ModifiedClassName */',
|
||||
\ 'class ModifiedClassName {',
|
||||
\ ' public constructor() {',
|
||||
\ ' ',
|
||||
\ ' }',
|
||||
\ '}',
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" jump to final tabstop
|
||||
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step5()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([4, 5])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ '/** @class ModifiedClassName */',
|
||||
\ 'class ModifiedClassName {',
|
||||
\ ' public constructor() {',
|
||||
\ ' ',
|
||||
\ ' }',
|
||||
\ '}',
|
||||
\ ])
|
||||
endfunction
|
||||
call feedkeys(l:sequence, 'x')
|
||||
End
|
||||
|
||||
It should work ($VIM variable)
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'realworld2')
|
||||
call cursor([1, 10])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function! g:vsnip_assert.step1() abort
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ $USER
|
||||
\ ])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should work (indented $TM_SELECTED_TEXT char-wise)
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, [
|
||||
\ ' <div>',
|
||||
\ ' <span />',
|
||||
\ ' </div>'
|
||||
\ ])
|
||||
let g:vsnip_assert = {}
|
||||
function! g:vsnip_assert.step1() abort
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ ' <div>',
|
||||
\ ' <div>',
|
||||
\ ' <span />',
|
||||
\ ' </div>',
|
||||
\ ' </div>'
|
||||
\ ])
|
||||
endfunction
|
||||
call feedkeys("1G3|v3G7|\<Plug>(vsnip-cut-text)realworld3\<C-j>", 'x')
|
||||
End
|
||||
|
||||
It should work (indented $TM_SELECTED_TEXT line-wise)
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, [
|
||||
\ ' <div>',
|
||||
\ ' <span />',
|
||||
\ ' </div>'
|
||||
\ ])
|
||||
let g:vsnip_assert = {}
|
||||
function! g:vsnip_assert.step1() abort
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ ' <div>',
|
||||
\ ' <div>',
|
||||
\ ' <span />',
|
||||
\ ' </div>',
|
||||
\ ' </div>'
|
||||
\ ])
|
||||
endfunction
|
||||
call feedkeys("1GV3G\<Plug>(vsnip-cut-text)realworld3\<C-j>", 'x')
|
||||
End
|
||||
|
||||
It should work (no indented $TM_SELECTED_TEXT char-wise)
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, [
|
||||
\ ' <div>',
|
||||
\ ' <span />',
|
||||
\ ' </div>'
|
||||
\ ])
|
||||
let g:vsnip_assert = {}
|
||||
function! g:vsnip_assert.step1() abort
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ ' <div><div>',
|
||||
\ ' <span />',
|
||||
\ ' </div></div>'
|
||||
\ ])
|
||||
endfunction
|
||||
call feedkeys("1G3|v3G7|\<Plug>(vsnip-cut-text)realworld4\<C-j>", 'x')
|
||||
End
|
||||
|
||||
It should work (no indented $TM_SELECTED_TEXT line-wise)
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, [
|
||||
\ ' <div>',
|
||||
\ ' <span />',
|
||||
\ ' </div>'
|
||||
\ ])
|
||||
let g:vsnip_assert = {}
|
||||
function! g:vsnip_assert.step1() abort
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ ' <div><div>',
|
||||
\ ' <span />',
|
||||
\ ' </div></div>'
|
||||
\ ])
|
||||
endfunction
|
||||
call feedkeys("1GV3G\<Plug>(vsnip-cut-text)realworld4\<C-j>", 'x')
|
||||
End
|
||||
|
||||
It should work (modify follower placeholder manually)
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'realworld5')
|
||||
call cursor([1, 10])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
let l:sequence = ''
|
||||
|
||||
" expand and jump
|
||||
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ ', ________'
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" edit $1
|
||||
let l:sequence .= "foobar\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step2()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ 'foobar, ____foobar____'
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" edit $1's follower
|
||||
let l:sequence .= "\<Esc>1G16|dt_ibaz\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step3()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ 'foobar, ____foobaz____'
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" edit $1 again
|
||||
let l:sequence .= "\<Esc>1G1|dt,imodified\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step4()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ 'modified, ____foobaz____'
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" can jump to $2
|
||||
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step5()
|
||||
call s:expect_selection([1, 11], [1, 24])
|
||||
endfunction
|
||||
|
||||
" can jump to $3
|
||||
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step6()
|
||||
call s:expect_selection([1, 12], [1, 23])
|
||||
endfunction
|
||||
|
||||
call feedkeys(l:sequence, 'x')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Context issue
|
||||
|
||||
It should work issue82
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, "'")
|
||||
call cursor([1, 1])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 2])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(["''"])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should work issue85
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, 'issue85')
|
||||
call cursor([1, 7])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['for i=1,10', ' print(i)'])
|
||||
call s:expect_selection([1, 5], [1, 5])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should work issue106
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, ['foo', 'issue106'])
|
||||
call cursor([2, 8])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(vsnip#get_session()).to_be_empty()
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Esc>gg0i_\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should work issue122
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, ['foo', 'issue122>'])
|
||||
call cursor([2, 9])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(['foo', ''])
|
||||
endfunction
|
||||
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
||||
End
|
||||
|
||||
It should work issue129
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, ['issue129'])
|
||||
call cursor([1, 8])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
let l:sequence = ''
|
||||
|
||||
" expand
|
||||
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(["console.log('', );"])
|
||||
endfunction
|
||||
|
||||
" modify
|
||||
let l:sequence .= "\<Esc>1G13|dt,iMODIFY\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step2()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal(["console.log(MODIFY, );"])
|
||||
endfunction
|
||||
|
||||
" jump
|
||||
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step3()
|
||||
call s:expect(getcurpos()[1 : 2]).to_equal([1, 21])
|
||||
endfunction
|
||||
|
||||
call feedkeys(l:sequence, 'x')
|
||||
End
|
||||
|
||||
It should work issue139
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, ['issue139'])
|
||||
call cursor([1, 8])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
let l:sequence = ''
|
||||
|
||||
" expand
|
||||
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ 'for (size_t i=0; i < count; i++) {',
|
||||
\ ' ',
|
||||
\ '}'
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
" modify
|
||||
let l:sequence .= "\<BS>\<Tab>variable\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step2()
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ 'for (variable=0; variable < count; variable++) {',
|
||||
\ ' ',
|
||||
\ '}'
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
call feedkeys(l:sequence, 'x')
|
||||
End
|
||||
|
||||
It should work issue249
|
||||
enew!
|
||||
set filetype=integration
|
||||
call setline(1, ['issue249'])
|
||||
call cursor([1, 8])
|
||||
|
||||
let g:vsnip_assert = {}
|
||||
let l:sequence = ''
|
||||
|
||||
" expand
|
||||
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
||||
function g:vsnip_assert.step1()
|
||||
call s:expect_selection([1, 1], [1, 3])
|
||||
call s:expect(getbufline('%', '^', '$')).to_equal([
|
||||
\ 'FOO',
|
||||
\ '',
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
call feedkeys(l:sequence, 'x')
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Reference in New Issue
Block a user