diff --git a/autoload/rainbow.vim b/autoload/rainbow.vim index d71f0fc..7e68eb9 100644 --- a/autoload/rainbow.vim +++ b/autoload/rainbow.vim @@ -28,20 +28,23 @@ fun s:resolve_parenthesis_with(init_state, p) elseif k == 'contained' let contained = 1 elseif k == 'kind' - let kind = v + let kind = s:trim(v) + let kind = kind == '' ? [''] : split(kind, ',', 1)->uniq() elseif k == 'upkind' - let upkind = v + let upkind = s:trim(v) + let upkind = upkind == '' ? [] : split(upkind, ',', 1)->uniq() else let paren .= s endif endfor + call extend(upkind, kind) let rst = [paren, contained, containedin, contains_prefix, contains, op, kind, upkind] "echom json_encode(rst) return rst endfun fun s:resolve_parenthesis_from_config(config) - return s:resolve_parenthesis_with(['', 0, '', a:config.contains_prefix, '', a:config.operators, '', ''], a:config.parentheses_options) + return s:resolve_parenthesis_with(['', 0, '', a:config.contains_prefix, '', a:config.operators, [''], []], a:config.parentheses_options) endfun fun s:synID(prefix, group, lv, id) @@ -62,17 +65,12 @@ fun rainbow#syn(config) let kindlist = {} for id in range(len(conf.parentheses)) let [paren, contained, containedin, contains_prefix, contains, op, kind, upkind] = s:resolve_parenthesis_with(glob_paran_opts, conf.parentheses[id]) - let kind = split(kind, ',') - if kind == [] - let kind = [''] - endif for k in kind if !has_key(kindlist, k) - let kindlist[k] = [] - endif + let kindlist[k] = [] + endif call add(kindlist[k], id) endfor - let upkind = split(upkind, ',', 1)->extend(kind)->uniq() for lv in range(cycle) let uplv = ((lv + cycle - 1) % cycle) let [rid, pid, upid] = [s:synID(prefix, 'r', lv, id), s:synID(prefix, 'p', lv, id), upkind->mapnew('"@".s:synGroupID(prefix, "Regions", uplv, v:val)')->join(',')] diff --git a/autoload/rainbow_main.vim b/autoload/rainbow_main.vim index dee0d7c..dfcabd4 100644 --- a/autoload/rainbow_main.vim +++ b/autoload/rainbow_main.vim @@ -45,11 +45,13 @@ let s:rainbow_conf = { \ 'parentheses': ['start=/(/ end=/)/', 'start=/{/ end=/}/', 'start=/\v\[\ze($|!(\=*\[))/ end=/\]/'], \ }, \ 'zsh': { -\ 'parentheses': ['start=/((/ end=/))/ kind=arithQuote upkind=,', 'start=/\v\(\ze($|[^(])/ end=/)/', -\ 'start=/(/ end=/)/ contained containedin=zshMathSubst upkind=arithQuote', -\ 'start=/\$\zs((/ end=/))/ contained containedin=zshMathSubst upkind=arithQuote', +\ 'parentheses': [ +\ 'start=/((/ end=/))/ kind=arithQuote upkind=,', +\ 'start=/\$((/ end=/))/ kind=arithQuote', +\ 'start=/(/ end=/)/ contained kind=arithInner upkind=arithQuote', +\ 'start=/\v\(\ze($|[^(])/ end=/)/', \ 'start=/\V[[/ end=/]]/', 'start=/\v\[\ze($|[^[])/ end=/]/', -\ 'start=/{/ end=/}/'] +\ 'start=/{/ end=/}/'], \ }, \ 'perl': { \ 'syn_name_prefix': 'perlBlockFoldRainbow',