support linear gradient.

This commit is contained in:
mattn
2012-10-16 17:07:47 +09:00
parent e4bbc7fcd4
commit 6575f65eaf
2 changed files with 47 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
"=============================================================================
" zencoding.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 24-Jul-2012.
" Last Change: 16-Oct-2012.
let s:save_cpo = &cpo
set cpo&vim
@@ -861,7 +861,7 @@ let s:zen_settings = {
\ 'bdr+': 'border-right:1px solid #000;',
\ 'bdr:n': 'border-right:none;',
\ 'bdrw': 'border-right-width:|;',
\ 'bdrs': 'border-right-style:|;',
\ 'bdrt': 'border-right-style:|;',
\ 'bdrs:n': 'border-right-style:none;',
\ 'bdrc': 'border-right-color:#000;',
\ 'bdb': 'border-bottom:|;',
@@ -878,7 +878,7 @@ let s:zen_settings = {
\ 'bdls': 'border-left-style:|;',
\ 'bdls:n': 'border-left-style:none;',
\ 'bdlc': 'border-left-color:#000;',
\ 'bdrz': 'border-radius:|;',
\ 'bdrs': 'border-radius:|;',
\ 'bdtrrz': 'border-top-right-radius:|;',
\ 'bdtlrz': 'border-top-left-radius:|;',
\ 'bdbrrz': 'border-bottom-right-radius:|;',

View File

@@ -5,7 +5,26 @@ endfunction
function! zencoding#lang#css#parseIntoTree(abbr, type)
let abbr = a:abbr
let type = a:type
let prefix = 0
let value = ''
" emmet
let prop = matchlist(abbr, '^\(-\{0,1}[a-zA-Z]\+\)\([0-9.]\+p\{0,1}\)$')
if len(prop)
let abbr = prop[1]
if abbr =~ '^-'
let prefix = 1
let abbr = abbr[1:]
endif
let value = prop[2]
if value =~ 'p$'
let value = substitute(prop[2], 'p$', '%', '')
elseif value =~ '\.'
let value .= 'em'
else
let value .= 'px'
endif
endif
let settings = zencoding#getSettings()
let indent = zencoding#getIndentation(type)
@@ -40,9 +59,33 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
let current.snippet = join(lines, "\n")
let current.name = ''
let current.snippet = substitute(current.snippet, ';', value . ';', '')
endif
let current.pos = 0
call add(root.child, current)
let lg = matchlist(abbr, '^\%(linear-gradient\|lg\)(\s*\(\w\+\)\s*,\s*\(\w\+\)\s*,\s*\(\w\+\)\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])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: -webkit-linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: -moz-linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: -o-linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
elseif prefix
let snippet = current.snippet
let current.snippet = '-webkit-' . snippet . "\n"
call add(root.child, deepcopy(current))
let current.snippet = '-moz-' . snippet . "\n"
call add(root.child, deepcopy(current))
call add(root.child, current)
else
call add(root.child, current)
endif
return root
endfunction