Fix completed snippet feature

This commit is contained in:
Shougo Matsushita 2015-12-12 01:51:49 +09:00
parent 3814544033
commit 7dc7ce803e
2 changed files with 16 additions and 9 deletions

View File

@ -50,7 +50,7 @@ function! neosnippet#handlers#_complete_done() "{{{
let abbr = split(item.info, '\n')[0] let abbr = split(item.info, '\n')[0]
endif endif
if abbr !~ '(.*)' if abbr !~ '('
return return
endif endif
@ -69,14 +69,16 @@ function! neosnippet#handlers#_complete_done() "{{{
let snippet .= printf('${%d:#:%s}', cnt, escape(arg, '{}')) let snippet .= printf('${%d:#:%s}', cnt, escape(arg, '{}'))
let cnt += 1 let cnt += 1
endfor endfor
if snippet !~ ')$'
let snippet .= ')'
endif
if s:is_auto_pairs() if s:is_auto_pairs()
" Remove auto pair from the snippet " Remove auto pair from the snippet
let snippet = substitute(snippet, ')$', '', '') let snippet = substitute(snippet, ')$', '', '')
else
if snippet !~ ')$'
let snippet .= ')'
endif endif
let snippet .= '${0}' let snippet .= '${0}'
endif
let options = neosnippet#parser#_initialize_snippet_options() let options = neosnippet#parser#_initialize_snippet_options()
let options.word = 1 let options.word = 1
@ -124,15 +126,16 @@ function! neosnippet#handlers#_get_in_paren(str) abort "{{{
endif endif
endif endif
if level > 0
let s .= c let s .= c
endif
endfor endfor
return s return ''
endfunction"}}} endfunction"}}}
function! s:is_auto_pairs() abort "{{{ function! s:is_auto_pairs() abort "{{{
return get(g:, 'deoplete#enable_auto_pairs', 0) return get(g:, 'neopairs#enable', 0)
\ || get(g:, 'neocomplete#enable_auto_pairs', 0)
endfunction"}}} endfunction"}}}
let &cpo = s:save_cpo let &cpo = s:save_cpo

View File

@ -8,5 +8,9 @@ function! s:suite.get_in_paren()
\ 'foobar, baz') \ 'foobar, baz')
call s:assert.equals(neosnippet#handlers#_get_in_paren('(foobar, (baz))'), call s:assert.equals(neosnippet#handlers#_get_in_paren('(foobar, (baz))'),
\ 'foobar, (baz)') \ 'foobar, (baz)')
call s:assert.equals(neosnippet#handlers#_get_in_paren('foobar('),
\ '')
call s:assert.equals(neosnippet#handlers#_get_in_paren('foobar(fname)'),
\ 'fname')
endfunction endfunction