Improve completed snippet feature

This commit is contained in:
Shougo Matsushita
2016-01-04 12:13:47 +09:00
parent 57301f8a5d
commit ac6ac62a5b
4 changed files with 74 additions and 30 deletions

View File

@@ -36,71 +36,92 @@ function! s:suite.get_completed_snippet()
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo()',
\ 'menu' : '', 'info' : ''
\ }), ')${1}')
\ }, ''), ')${1}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : '',
\ 'menu' : '', 'info' : ''
\ }), '${1})${2}')
\ }, ''), '${1})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge})${2}')
\ }, ''), '${1:#:hoge})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo', 'abbr' : 'foo(hoge)',
\ 'menu' : '', 'info' : ''
\ }), '')
\ }, ''), '(${1:#:hoge})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge, piyo)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge}, ${2:#:piyo})${3}')
\ }, ''), '${1:#:hoge}, ${2:#:piyo})${3}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge, piyo(foobar))',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge}, ${2:#:piyo()})${3}')
\ }, ''), '${1:#:hoge}, ${2:#:piyo()})${3}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge[, abc])',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge[, abc]})${2}')
\ }, ''), '${1:#:hoge[, abc]})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(...)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:...})${2}')
\ }, ''), '${1:#:...})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge, ...)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge}${2:#:, ...})${3}')
\ }, ''), '${1:#:hoge}${2:#:, ...})${3}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo{', 'abbr' : 'foo{}',
\ 'menu' : '', 'info' : ''
\ }), '}${1}')
\ }, ''), '}${1}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo{', 'abbr' : 'foo{',
\ 'menu' : '', 'info' : ''
\ }), '${1}}${2}')
\ }, ''), '${1}}${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo{', 'abbr' : 'foo{piyo}',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:piyo}}${2}')
\ }, ''), '${1:#:piyo}}${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary(', 'abbr' : 'Dictionary<Key, Value>(foo)',
\ 'word' : 'Dictionary', 'abbr' : 'Dictionary<Key, Value>(foo)',
\ 'menu' : '', 'info' : ''
\ }), '<${1:#:Key}, ${2:#:Value}>${3:#:foo})${4}')
\ }, ''), '<${1:#:Key}, ${2:#:Value}>(${3:#:foo})${4}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary(', 'abbr' : 'Dictionary<Key, Value> (foo)',
\ 'word' : 'Dictionary(',
\ 'abbr' : 'Dictionary<Key, Value> Dictionary(foo)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:foo})${2}')
\ }, ''), '${1:#:foo})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary(', 'abbr' : '',
\ 'menu' : '', 'info' : ''
\ }, '('), '')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary(', 'abbr' : 'Dictionary(foo)',
\ 'menu' : '', 'info' : ''
\ }, '('), '')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary(', 'abbr' : 'Dictionary(foo)',
\ 'menu' : '', 'info' : ''
\ }, ')'), '${1:#:foo}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary', 'abbr' : 'Dictionary(foo)',
\ 'menu' : '', 'info' : ''
\ }, ''), '(${1:#:foo})${2}')
endfunction