mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 10:44:24 +08:00
Merge branch 'master' of github.com:mattn/zencoding-vim
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"=============================================================================
|
||||
" zencoding.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 22-Nov-2010.
|
||||
" Last Change: 24-Feb-2011.
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
@@ -61,8 +61,12 @@ function! s:zen_parseIntoTree(abbr, type)
|
||||
let indent = s:zen_settings.indentation
|
||||
endif
|
||||
|
||||
let abbr = substitute(abbr, '\([a-zA-Z][a-zA-Z0-9]*\)+\([()]\|$\)', '\="(".s:zen_getExpandos(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_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.{[{}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}\)*\)'
|
||||
if s:zen_isExtends(type, "html")
|
||||
let abbr = substitute(abbr, '\([a-zA-Z][a-zA-Z0-9]*\)+\([()]\|$\)', '\="(".s:zen_getExpandos(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_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.{[{}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}\)*\)'
|
||||
else
|
||||
let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:\!\+\-]*\|{[^}]\+}\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[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}\)*\)'
|
||||
endif
|
||||
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
|
||||
let parent = root
|
||||
let last = root
|
||||
@@ -85,6 +89,10 @@ function! s:zen_parseIntoTree(abbr, type)
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if tag_name =~ '^\.'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if multiplier <= 0 | let multiplier = 1 | endif
|
||||
|
||||
" make default node
|
||||
@@ -327,8 +335,8 @@ function! s:zen_toString_haml(settings, current, type, inline, filters, itemno,
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
if current.multiplier > 1
|
||||
while val =~ '\$[^{]*'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]*\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
while val =~ '\$\([^{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
endif
|
||||
if attr == 'id'
|
||||
@@ -345,8 +353,6 @@ function! s:zen_toString_haml(settings, current, type, inline, filters, itemno,
|
||||
endif
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current.name.',') != -1 && len(current.value) == 0
|
||||
let str .= "/"
|
||||
elseif stridx(','.settings.html.block_elements.',', ','.current.name.',') != -1 && (len(current.child) == 0 && len(current.value) == 0)
|
||||
let str .= '<'
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
@@ -434,9 +440,13 @@ function! s:zen_toString_html(settings, current, type, inline, filters, itemno,
|
||||
elseif len(current.child)
|
||||
if inline == 0
|
||||
if stridx(','.settings.html.inline_elements.',', ','.current.name.',') == -1
|
||||
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
||||
let inner = substitute(inner, indent . "$", "", 'g')
|
||||
let str .= ">\n" . indent . inner . "</" . current.name . ">\n"
|
||||
if inner =~ "\n$"
|
||||
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
||||
let inner = substitute(inner, indent . "$", "", 'g')
|
||||
let str .= ">\n" . indent . inner . "</" . current.name . ">\n"
|
||||
else
|
||||
let str .= ">\n" . indent . inner . indent . "\n</" . current.name . ">\n"
|
||||
endif
|
||||
else
|
||||
let str .= ">" . inner . "</" . current.name . ">\n"
|
||||
endif
|
||||
@@ -585,6 +595,8 @@ endfunction
|
||||
function! s:zen_getFileType()
|
||||
let type = &ft
|
||||
if type == 'xslt' | let type = 'xsl' | endif
|
||||
if type == 'htmldjango' | let type = 'html' | endif
|
||||
if type == 'html.django_template' | let type = 'html' | endif
|
||||
if synIDattr(synID(line("."), col("."), 1), "name") =~ '^css'
|
||||
let type = 'css'
|
||||
endif
|
||||
@@ -634,8 +646,12 @@ function! zencoding#expandAbbr(mode) range
|
||||
for n in range(a:firstline, a:lastline)
|
||||
let lline = getline(n)
|
||||
let lpart = substitute(lline, '^\s*', '', '')
|
||||
let expand = substitute(expand, '\$line\$', lpart, '')
|
||||
let pos = stridx(expand, "$line$")
|
||||
if pos != -1
|
||||
let expand = expand[:pos-1] . lpart . expand[pos+6:]
|
||||
endif
|
||||
endfor
|
||||
let expand = substitute(expand, '\$line\$', '', 'g')
|
||||
else
|
||||
let str = ''
|
||||
if a:firstline != a:lastline
|
||||
@@ -676,9 +692,6 @@ function! zencoding#expandAbbr(mode) range
|
||||
else
|
||||
let part = matchstr(line, '\(\S.*\)$')
|
||||
endif
|
||||
if part =~ '!'
|
||||
let part = substitute(part, '.*!', '!', '')
|
||||
endif
|
||||
let rest = getline('.')[len(line):]
|
||||
let str = part
|
||||
let mx = '|\(\%(html\|haml\|e\|c\|fc\|xsl\)\s*,\{0,1}\s*\)*$'
|
||||
@@ -729,6 +742,9 @@ function! zencoding#expandAbbr(mode) range
|
||||
silent! exe "normal! v7h\"_s"
|
||||
let &selection = oldselection
|
||||
endif
|
||||
if g:zencoding_debug > 1
|
||||
call getchar()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#moveNextPrev(flag)
|
||||
@@ -775,8 +791,8 @@ function! zencoding#imageSize()
|
||||
endif
|
||||
if hex =~ '^47494638'
|
||||
let type = 'gif'
|
||||
let width = eval('0x'.hex[18:19].hex[16:17])
|
||||
let height = eval('0x'.hex[14:15].hex[12:13])
|
||||
let width = eval('0x'.hex[14:15].hex[12:13])
|
||||
let height = eval('0x'.hex[18:19].hex[16:17])
|
||||
endif
|
||||
|
||||
if width == -1 && height == -1
|
||||
@@ -1791,7 +1807,8 @@ let s:zen_settings = {
|
||||
\ 'pgba:r': 'page-break-after:right;',
|
||||
\ 'orp': 'orphans:|;',
|
||||
\ 'wid': 'widows:|;'
|
||||
\ }
|
||||
\ },
|
||||
\ 'filters': 'fc'
|
||||
\ },
|
||||
\ 'html': {
|
||||
\ 'snippets': {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"=============================================================================
|
||||
" File: zencoding.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 22-Nov-2010.
|
||||
" Version: 0.50
|
||||
" Last Change: 14-Jan-2011.
|
||||
" Version: 0.52
|
||||
" WebPage: http://github.com/mattn/zencoding-vim
|
||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
||||
" SeeAlso: http://code.google.com/p/zen-coding/
|
||||
|
||||
27
unittest.vim
27
unittest.vim
@@ -23,6 +23,7 @@ function! s:testExpandAbbr()
|
||||
else
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo "failed test #".(n+1) | echohl None
|
||||
set more
|
||||
echo " expect:".tests[n].result
|
||||
echo " got:".res
|
||||
echo ""
|
||||
@@ -412,6 +413,12 @@ finish
|
||||
'type': "html",
|
||||
'result': "<div>\n\t<a id=\"foo\" href=\"\">bar</a>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': ".content{Hello!}",
|
||||
'query': ".content{Hello!}",
|
||||
'type': "html",
|
||||
'result': "<div class=\"content\">Hello!</div>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -435,6 +442,12 @@ finish
|
||||
'type': "css",
|
||||
'result': "float: left;",
|
||||
},
|
||||
{
|
||||
'name': "bg+",
|
||||
'query': "bg+",
|
||||
'type': "css",
|
||||
'result': "background:#FFF url() 0 0 no-repeat;",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -450,7 +463,19 @@ finish
|
||||
'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml",
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml",
|
||||
'type': "haml",
|
||||
'result': "%div\n %p<\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
|
||||
'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
|
||||
},
|
||||
{
|
||||
'name': "a*3|haml",
|
||||
'query': "a*3|haml",
|
||||
'type': "haml",
|
||||
'result': "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n",
|
||||
},
|
||||
{
|
||||
'name': ".content{Hello!}|haml",
|
||||
'query': ".content{Hello!}|haml",
|
||||
'type': "haml",
|
||||
'result': "%div.content Hello!\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ script_name: ZenCoding.vim
|
||||
script_id: '2981'
|
||||
script_type: utility
|
||||
script_package: zencoding-vim.zip
|
||||
script_version: '0.50'
|
||||
script_version: '0.51'
|
||||
required_vim_version: '7.0'
|
||||
summary: vim plugins for HTML and CSS hi-speed coding.
|
||||
|
||||
@@ -98,6 +98,14 @@ install_details: |
|
||||
# git clone http://github.com/mattn/zencoding-vim.git
|
||||
|
||||
versions:
|
||||
- '0.52': |
|
||||
[fix] broken wrap expanding.
|
||||
- '0.51': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] wrap expanding with '&'.
|
||||
[fix] expand .content to class="content".
|
||||
[fix] haml expanding.
|
||||
[fix] bg+ snippet
|
||||
- '0.50': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed parsing '#{{foo}}' and '.{{bar}}'.
|
||||
|
||||
Reference in New Issue
Block a user