support (bg+)+c like format.

This commit is contained in:
mattn
2012-10-24 11:13:34 +09:00
parent 95455cc4c8
commit 672af42b71

View File

@@ -8,20 +8,28 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
let prefix = 0
let value = ''
let settings = zencoding#getSettings()
let indent = zencoding#getIndentation(type)
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
" emmet
let prop = matchlist(abbr, '^\(-\{0,1}[a-zA-Z]\+\)\(\%([0-9.-]\+[pe]\{0,1}-\{0,1}\|-auto\)*\)$')
let tokens = split(abbr, '+\ze[^)!]')
for n in range(len(tokens))
let token = tokens[n]
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+[pe]\{0,1}-\{0,1}\|-auto\)*\)$')
if len(prop)
let abbr = prop[1]
if abbr =~ '^-'
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
if token =~ '^-'
let prefix = 1
let abbr = abbr[1:]
let token = token[1:]
endif
let value = ''
for v in split(prop[2], '\d\zs-')
if len(value) > 0
let value .= ' '
endif
if abbr =~ '^[z]'
if token =~ '^[z]'
" TODO
let value .= substitute(v, '[^0-9.]*$', '', '')
elseif v =~ 'p$'
@@ -37,12 +45,8 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
endif
endfor
endif
let settings = zencoding#getSettings()
let indent = zencoding#getIndentation(type)
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
let tag_name = abbr
let tag_name = token
if tag_name =~ '.!$'
let tag_name = tag_name[:-2]
let important = 1
@@ -72,13 +76,16 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
let current.snippet = join(lines, "\n")
let current.name = ''
let current.snippet = substitute(current.snippet, ';', value . ';', '')
if use_pipe_for_cursor
if use_pipe_for_cursor && len(value) > 0 && stridx(value, '${cursor}') == -1
let current.snippet = substitute(current.snippet, '${cursor}', '', 'g') . '${cursor}'
endif
if n < len(tokens) - 1
let current.snippet .= "\n"
endif
endif
let current.pos = 0
let lg = matchlist(abbr, '^\%(linear-gradient\|lg\)(\s*\(\w\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\w\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
if len(lg)
let current.name = ''
let current.snippet = printf("background-image: -webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3])
@@ -102,6 +109,7 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
else
call add(root.child, current)
endif
endfor
return root
endfunction