Fix #417 completed snippets parser

Bu işleme şunda yer alıyor:
Shougo Matsushita 2018-02-18 18:53:18 +09:00
ebeveyn 3071a45a4c
işleme e70864c53c
3 değiştirilmiş dosya ile 25 ekleme ve 30 silme

Dosyayı Görüntüle

@ -26,12 +26,6 @@ call neosnippet#util#set_default(
\ 'g:neosnippet#enable_optional_arguments', 1)
call neosnippet#util#set_default(
\ 'g:neosnippet#enable_auto_clear_markers', 1)
call neosnippet#util#set_default(
\ 'g:neosnippet#completed_pairs', {})
call neosnippet#util#set_default(
\ 'g:neosnippet#_completed_pairs',
\ {'_':{ '(' : ')', '{' : '}', '"' : '"', '[' : ']' }})
function! neosnippet#expandable_or_jumpable() abort
return neosnippet#mappings#expandable_or_jumpable()

Dosyayı Görüntüle

@ -297,27 +297,33 @@ function! neosnippet#parser#_get_completed_snippet(completed_item, cur_text, nex
endif
" Set abbr
let abbr = ''
let abbrs = []
if get(item, 'info', '') =~# '^.\+('
let abbr = matchstr(item.info, '^\_s*\zs.*')
elseif get(item, 'abbr', '') =~# '^.\+('
let abbr = item.abbr
elseif get(item, 'menu', '') =~# '^.\+('
let abbr = item.menu
elseif item.word =~# '^.\+(' || get(item, 'kind', '') == 'f'
let abbr = item.word
call add(abbrs, matchstr(item.info, '^\_s*\zs.*'))
endif
let abbr = escape(abbr, '\')
if get(item, 'abbr', '') =~# '^.\+('
call add(abbrs, item.abbr)
endif
if get(item, 'menu', '') =~# '^.\+('
call add(abbrs, item.menu)
endif
if item.word =~# '^.\+(' || get(item, 'kind', '') == 'f'
call add(abbrs, item.word)
endif
call map(abbrs, "escape(v:val, '\')")
let pairs = neosnippet#util#get_buffer_config(
\ &filetype, '',
\ 'g:neosnippet#completed_pairs', 'g:neosnippet#_completed_pairs', {})
" () Only supported
let pairs = {'(': ')'}
let no_key = index(keys(pairs), item.word[-1:]) < 0
let word_pattern = '\<' . neosnippet#util#escape_pattern(item.word)
let angle_pattern = word_pattern . '<.\+>(.*)'
let no_key = index(keys(pairs), item.word[-1:]) < 0
if no_key && abbr !~# word_pattern . '\%(<.\+>\)\?(.*)'
let check_pattern = word_pattern . '\%(<.\+>\)\?(.*)'
let abbrs = filter(abbrs, '!no_key || v:val =~# check_pattern')
if empty(abbrs)
return ''
endif
let abbr = abbrs[0]
let key = no_key ? '(' : item.word[-1:]
if a:next_text[:0] ==# key

Dosyayı Görüntüle

@ -87,11 +87,6 @@ function! s:suite.get_completed_snippet() abort
\ 'menu' : '', 'info' : ''
\ }, 'foo(', ''), '${1:#:hoge}${2:#:, ...})${3}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo{', 'abbr' : 'foo{',
\ 'menu' : '', 'info' : ''
\ }, 'foo{', ''), '${1}}${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary', 'abbr' : 'Dictionary<Key, Value>(foo)',
\ 'menu' : '', 'info' : ''
@ -128,14 +123,14 @@ function! s:suite.get_completed_snippet() abort
\ 'menu' : '', 'info' : ''
\ }, 'forEach', ''), '(${1:#:BiConsumer<>})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'for[', 'abbr' : '',
\ 'menu' : '', 'info' : ''
\ }, 'for[', ''), '${1}]${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'something', 'abbr' : 'something(else)',
\ 'menu' : '', 'info' : '', 'snippet' : '(${1:custom})${2}'
\ }, 'something', ''), '(${1:custom})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'something', 'abbr' : 'something(else)',
\ 'menu' : '', 'info' : 'func()', 'snippet' : '(${1:custom})${2}'
\ }, 'something', ''), '(${1:custom})${2}')
endfunction