Merge commit '62ef855ef42e7c0fc9c0' into mustache

This commit is contained in:
mattn
2010-08-25 15:53:54 +09:00
2 changed files with 37 additions and 17 deletions

View File

@@ -41,7 +41,7 @@ if exists('g:user_zen_settings')
let g:user_zen_settings = s:old_user_zen_settings let g:user_zen_settings = s:old_user_zen_settings
endif endif
let &more=oldmore let &more=oldmore
finish finish
[ [
{ {
@@ -400,5 +400,22 @@ finish
}, },
], ],
}, },
{
'category': 'mustache',
'tests': [
{
'name': "div#{{foo}}",
'query': "div#{{foo}}",
'type': "mustache",
'result': "<div id=\"{{foo}}\"></div>\n",
},
{
'name': "div.{{foo}}",
'query': "div.{{foo}}",
'type': "mustache",
'result': "<div class=\"{{foo}}\"></div>\n",
},
],
},
] ]
" vim:set et: " vim:set et:

View File

@@ -10,7 +10,7 @@
" "
" This is vim script support expanding abbreviation like zen-coding. " This is vim script support expanding abbreviation like zen-coding.
" ref: http://code.google.com/p/zen-coding/ " ref: http://code.google.com/p/zen-coding/
" "
" Type abbreviation " Type abbreviation
" +------------------------------------- " +-------------------------------------
" | html:5_ " | html:5_
@@ -42,12 +42,12 @@
" | <div class="bar"></div> " | <div class="bar"></div>
" |</div> " |</div>
" +------------------------------------- " +-------------------------------------
" "
" Tips: " Tips:
" "
" You can customize behavior of expanding with overriding config. " You can customize behavior of expanding with overriding config.
" This configuration will be marged at loading plugin. " This configuration will be marged at loading plugin.
" "
" let g:user_zen_settings = { " let g:user_zen_settings = {
" \ 'indentation' : ' ', " \ 'indentation' : ' ',
" \ 'perl' : { " \ 'perl' : {
@@ -109,7 +109,7 @@ for s:item in [
\ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': '<esc>:call <sid>zen_anchorizeURL(1)<cr>a'}, \ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': '<esc>:call <sid>zen_anchorizeURL(1)<cr>a'},
\ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call <sid>zen_anchorizeURL(1)<cr>'}, \ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call <sid>zen_anchorizeURL(1)<cr>'},
\] \]
if !hasmapto('<plug>'.s:item.plug, s:item.mode) if !hasmapto('<plug>'.s:item.plug, s:item.mode)
exe s:item.mode . 'noremap <plug>' . s:item.plug . ' ' . s:item.func exe s:item.mode . 'noremap <plug>' . s:item.plug . ' ' . s:item.func
endif endif
@@ -846,6 +846,9 @@ let s:zen_settings = {
\ }, \ },
\ 'xhtml': { \ 'xhtml': {
\ 'extends': 'html' \ 'extends': 'html'
\ },
\ 'mustache': {
\ 'extends': 'html'
\ } \ }
\} \}
@@ -905,7 +908,7 @@ function! s:zen_parseIntoTree(abbr, type)
endif endif
let abbr = substitute(abbr, '\([a-zA-Z][a-zA-Z0-9]*\)+\([()]\|$\)', '\="(".s:zen_expandos(type, submatch(1)).")".submatch(2)', 'i') let abbr = substitute(abbr, '\([a-zA-Z][a-zA-Z0-9]*\)+\([()]\|$\)', '\="(".s:zen_expandos(type, submatch(1)).")".submatch(2)', 'i')
let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#]\{-}[a-zA-Z\!][a-zA-Z0-9:\!\-]*\|{[^}]\+}\)\(\%(\%(#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#]\{-}[a-zA-Z\!][a-zA-Z0-9:\!\-]*\|{[^}]\+}\)\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)'
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 } let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
let parent = root let parent = root
let last = root let last = root
@@ -980,7 +983,7 @@ function! s:zen_parseIntoTree(abbr, type)
if len(attributes) if len(attributes)
let attr = attributes let attr = attributes
while len(attr) while len(attr)
let item = matchstr(attr, '\(\%(\%(#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[a-zA-Z0-9_\-\$]\+\)*\)\)') let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
if len(item) == 0 if len(item) == 0
break break
endif endif
@@ -1370,16 +1373,16 @@ function! s:zen_getFileType()
let type = &ft let type = &ft
if type == 'xslt' | let type = 'xsl' | endif if type == 'xslt' | let type = 'xsl' | endif
if synIDattr(synID(line("."), col("."), 1), "name") =~ '^css' if synIDattr(synID(line("."), col("."), 1), "name") =~ '^css'
let type = 'css' let type = 'css'
endif endif
if synIDattr(synID(line("."), col("."), 1), "name") =~ '^html' if synIDattr(synID(line("."), col("."), 1), "name") =~ '^html'
let type = 'html' let type = 'html'
endif endif
if synIDattr(synID(line("."), col("."), 1), "name") =~ '^xml' if synIDattr(synID(line("."), col("."), 1), "name") =~ '^xml'
let type = 'xml' let type = 'xml'
endif endif
if synIDattr(synID(line("."), col("."), 1), "name") =~ '^javaScript' if synIDattr(synID(line("."), col("."), 1), "name") =~ '^javaScript'
let type = 'javascript' let type = 'javascript'
endif endif
if len(type) == 0 | let type = 'html' | endif if len(type) == 0 | let type = 'html' | endif
return type return type
@@ -1421,7 +1424,7 @@ function! s:zen_expandAbbr(mode) range
let expand = substitute(expand, '\$line\$', lpart, '') let expand = substitute(expand, '\$line\$', lpart, '')
endfor endfor
else else
let str = '' let str = ''
if a:firstline != a:lastline if a:firstline != a:lastline
let line = getline(a:firstline) let line = getline(a:firstline)
let part = substitute(line, '^\s*', '', '') let part = substitute(line, '^\s*', '', '')
@@ -1477,7 +1480,7 @@ function! s:zen_expandAbbr(mode) range
endif endif
if len(expand) if len(expand)
if expand !~ '\${cursor}' if expand !~ '\${cursor}'
if a:mode == 2 | if a:mode == 2 |
let expand = '${cursor}' . expand let expand = '${cursor}' . expand
else else
let expand .= '${cursor}' let expand .= '${cursor}'
@@ -1558,7 +1561,7 @@ function! s:zen_imageSize()
let fn = simplify(expand('%:h') . '/' . fn) let fn = simplify(expand('%:h') . '/' . fn)
endif endif
let [type, width, height] = ['', -1, -1] let [type, width, height] = ['', -1, -1]
if filereadable(fn) if filereadable(fn)
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g') let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
else else
@@ -2102,7 +2105,7 @@ function! s:region_is_valid(region)
return 1 return 1
endfunction endfunction
" search_region : make region from pattern which is composing start/end " search_region : make region from pattern which is composing start/end
" this function return array of position " this function return array of position
function! s:search_region(start, end) function! s:search_region(start, end)
return [searchpos(a:start, 'bcnW'), searchpos(a:end, 'cneW')] return [searchpos(a:start, 'bcnW'), searchpos(a:end, 'cneW')]