forked from VimPlug/emmet-vim
replace $# as line for wrap abbreviation.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" zencoding.vim
|
" zencoding.vim
|
||||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||||
" Last Change: 12-Oct-2011.
|
" Last Change: 14-Oct-2011.
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@@ -335,7 +335,7 @@ function! s:zen_toString_haml(settings, current, type, inline, filters, itemno,
|
|||||||
for attr in keys(current.attr)
|
for attr in keys(current.attr)
|
||||||
let val = current.attr[attr]
|
let val = current.attr[attr]
|
||||||
if current.multiplier > 1
|
if current.multiplier > 1
|
||||||
while val =~ '\$\([^{]\|$\)'
|
while val =~ '\$\([^#{]\|$\)'
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
@@ -379,6 +379,9 @@ function! s:zen_toString_haml(settings, current, type, inline, filters, itemno,
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let str .= "\n"
|
let str .= "\n"
|
||||||
|
if !empty(current.parent) && empty(current.parent.parent)
|
||||||
|
let str = substitute(str, '\$#', '$line'.(itemno+1).'$', 'g')
|
||||||
|
endif
|
||||||
return str
|
return str
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -404,7 +407,7 @@ function! s:zen_toString_html(settings, current, type, inline, filters, itemno,
|
|||||||
endif
|
endif
|
||||||
let val = current.attr[attr]
|
let val = current.attr[attr]
|
||||||
if current.multiplier > 1
|
if current.multiplier > 1
|
||||||
while val =~ '\$\([^{]\|$\)'
|
while val =~ '\$\([^#{]\|$\)'
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
@@ -475,6 +478,9 @@ function! s:zen_toString_html(settings, current, type, inline, filters, itemno,
|
|||||||
if len(comment) > 0
|
if len(comment) > 0
|
||||||
let str .= "<!-- /" . comment . " -->" . (inline ? "" : "\n") . comment_indent
|
let str .= "<!-- /" . comment . " -->" . (inline ? "" : "\n") . comment_indent
|
||||||
endif
|
endif
|
||||||
|
if !empty(current.parent) && empty(current.parent.parent)
|
||||||
|
let str = substitute(str, '\$#', '$line'.(itemno+1).'$', 'g')
|
||||||
|
endif
|
||||||
return str
|
return str
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -637,7 +643,10 @@ function! zencoding#expandAbbr(mode) range
|
|||||||
let leader = substitute(leader, mx, '', '')
|
let leader = substitute(leader, mx, '', '')
|
||||||
endif
|
endif
|
||||||
if leader =~ '\*'
|
if leader =~ '\*'
|
||||||
let query = substitute(leader, '*', '*' . (a:lastline - a:firstline + 1), '') . '>{$line$}'
|
let query = substitute(leader, '*', '*' . (a:lastline - a:firstline + 1), '')
|
||||||
|
if query !~ '}\s*$'
|
||||||
|
let query .= '>{$line$}'
|
||||||
|
endif
|
||||||
let items = s:zen_parseIntoTree(query, type).child
|
let items = s:zen_parseIntoTree(query, type).child
|
||||||
for item in items
|
for item in items
|
||||||
let expand .= s:zen_toString(item, type, 0, filters)
|
let expand .= s:zen_toString(item, type, 0, filters)
|
||||||
@@ -647,12 +656,9 @@ function! zencoding#expandAbbr(mode) range
|
|||||||
for n in range(a:firstline, a:lastline)
|
for n in range(a:firstline, a:lastline)
|
||||||
let lline = getline(n)
|
let lline = getline(n)
|
||||||
let lpart = substitute(lline, '^\s*', '', '')
|
let lpart = substitute(lline, '^\s*', '', '')
|
||||||
let pos = stridx(expand, "$line$")
|
let expand = substitute(expand, '\$line'.(n-a:firstline+1).'\$', lpart, 'g')
|
||||||
if pos != -1
|
|
||||||
let expand = expand[:pos-1] . lpart . expand[pos+6:]
|
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
let expand = substitute(expand, '\$line\$', '', 'g')
|
let expand = substitute(expand, '\$line\d*\$', '', 'g')
|
||||||
else
|
else
|
||||||
let str = ''
|
let str = ''
|
||||||
if a:firstline != a:lastline
|
if a:firstline != a:lastline
|
||||||
|
|||||||
Reference in New Issue
Block a user