Fix completed snippet feature
This commit is contained in:
parent
3814544033
commit
7dc7ce803e
@ -50,7 +50,7 @@ function! neosnippet#handlers#_complete_done() "{{{
|
||||
let abbr = split(item.info, '\n')[0]
|
||||
endif
|
||||
|
||||
if abbr !~ '(.*)'
|
||||
if abbr !~ '('
|
||||
return
|
||||
endif
|
||||
|
||||
@ -69,14 +69,16 @@ function! neosnippet#handlers#_complete_done() "{{{
|
||||
let snippet .= printf('${%d:#:%s}', cnt, escape(arg, '{}'))
|
||||
let cnt += 1
|
||||
endfor
|
||||
if snippet !~ ')$'
|
||||
let snippet .= ')'
|
||||
endif
|
||||
|
||||
if s:is_auto_pairs()
|
||||
" Remove auto pair from the snippet
|
||||
let snippet = substitute(snippet, ')$', '', '')
|
||||
else
|
||||
if snippet !~ ')$'
|
||||
let snippet .= ')'
|
||||
endif
|
||||
let snippet .= '${0}'
|
||||
endif
|
||||
|
||||
let options = neosnippet#parser#_initialize_snippet_options()
|
||||
let options.word = 1
|
||||
@ -124,15 +126,16 @@ function! neosnippet#handlers#_get_in_paren(str) abort "{{{
|
||||
endif
|
||||
endif
|
||||
|
||||
if level > 0
|
||||
let s .= c
|
||||
endif
|
||||
endfor
|
||||
|
||||
return s
|
||||
return ''
|
||||
endfunction"}}}
|
||||
|
||||
function! s:is_auto_pairs() abort "{{{
|
||||
return get(g:, 'deoplete#enable_auto_pairs', 0)
|
||||
\ || get(g:, 'neocomplete#enable_auto_pairs', 0)
|
||||
return get(g:, 'neopairs#enable', 0)
|
||||
endfunction"}}}
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
@ -8,5 +8,9 @@ function! s:suite.get_in_paren()
|
||||
\ 'foobar, baz')
|
||||
call s:assert.equals(neosnippet#handlers#_get_in_paren('(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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user