mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-08 11:34:46 +08:00
support (bg+)+c like format.
This commit is contained in:
@@ -8,20 +8,28 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
|
|||||||
let prefix = 0
|
let prefix = 0
|
||||||
let value = ''
|
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
|
" 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)
|
if len(prop)
|
||||||
let abbr = prop[1]
|
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
|
||||||
if abbr =~ '^-'
|
if token =~ '^-'
|
||||||
let prefix = 1
|
let prefix = 1
|
||||||
let abbr = abbr[1:]
|
let token = token[1:]
|
||||||
endif
|
endif
|
||||||
let value = ''
|
let value = ''
|
||||||
for v in split(prop[2], '\d\zs-')
|
for v in split(prop[2], '\d\zs-')
|
||||||
if len(value) > 0
|
if len(value) > 0
|
||||||
let value .= ' '
|
let value .= ' '
|
||||||
endif
|
endif
|
||||||
if abbr =~ '^[z]'
|
if token =~ '^[z]'
|
||||||
" TODO
|
" TODO
|
||||||
let value .= substitute(v, '[^0-9.]*$', '', '')
|
let value .= substitute(v, '[^0-9.]*$', '', '')
|
||||||
elseif v =~ 'p$'
|
elseif v =~ 'p$'
|
||||||
@@ -37,12 +45,8 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
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 = token
|
||||||
|
|
||||||
let tag_name = abbr
|
|
||||||
if tag_name =~ '.!$'
|
if tag_name =~ '.!$'
|
||||||
let tag_name = tag_name[:-2]
|
let tag_name = tag_name[:-2]
|
||||||
let important = 1
|
let important = 1
|
||||||
@@ -72,13 +76,16 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
|
|||||||
let current.snippet = join(lines, "\n")
|
let current.snippet = join(lines, "\n")
|
||||||
let current.name = ''
|
let current.name = ''
|
||||||
let current.snippet = substitute(current.snippet, ';', value . ';', '')
|
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}'
|
let current.snippet = substitute(current.snippet, '${cursor}', '', 'g') . '${cursor}'
|
||||||
endif
|
endif
|
||||||
|
if n < len(tokens) - 1
|
||||||
|
let current.snippet .= "\n"
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let current.pos = 0
|
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)
|
if len(lg)
|
||||||
let current.name = ''
|
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])
|
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
|
else
|
||||||
call add(root.child, current)
|
call add(root.child, current)
|
||||||
endif
|
endif
|
||||||
|
endfor
|
||||||
return root
|
return root
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user