forked from VimPlug/emmet-vim
filter to split to separated columns with wrap-with-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: 06-Jul-2012.
|
" Last Change: 23-Jul-2012.
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@@ -14,9 +14,20 @@ function! zencoding#getExpandos(type, key)
|
|||||||
return a:key
|
return a:key
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#splitFilterArg(filters)
|
||||||
|
for f in a:filters
|
||||||
|
if f =~ '^/'
|
||||||
|
return f[1:]
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! zencoding#useFilter(filters, filter)
|
function! zencoding#useFilter(filters, filter)
|
||||||
for f in a:filters
|
for f in a:filters
|
||||||
if f == a:filter
|
if a:filter == '/' && f =~ '^/'
|
||||||
|
return 1
|
||||||
|
elseif f == a:filter
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -269,9 +280,9 @@ function! zencoding#expandAbbr(mode, abbr) range
|
|||||||
if len(leader) == 0
|
if len(leader) == 0
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\)\s*,\{0,1}\s*\)*$'
|
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
|
||||||
if leader =~ mx
|
if leader =~ mx
|
||||||
let filters = split(matchstr(leader, mx)[1:], '\s*,\s*')
|
let filters = map(split(matchstr(leader, mx)[1:], '\s*[^\\]\zs,\s*'), 'substitute(v:val, "\\\\,", ",", "g")')
|
||||||
let leader = substitute(leader, mx, '', '')
|
let leader = substitute(leader, mx, '', '')
|
||||||
endif
|
endif
|
||||||
if leader =~ '\*'
|
if leader =~ '\*'
|
||||||
@@ -279,6 +290,11 @@ function! zencoding#expandAbbr(mode, abbr) range
|
|||||||
if query !~ '}\s*$'
|
if query !~ '}\s*$'
|
||||||
let query .= '>{$#}'
|
let query .= '>{$#}'
|
||||||
endif
|
endif
|
||||||
|
if zencoding#useFilter(filters, '/')
|
||||||
|
let spl = zencoding#splitFilterArg(filters)
|
||||||
|
let fline = getline(a:firstline)
|
||||||
|
let query = substitute(query, '>\{0,1}{\$#}\s*$', '{\\$column\\$}*' . len(split(fline, spl)), '')
|
||||||
|
endif
|
||||||
let items = zencoding#parseIntoTree(query, type).child
|
let items = zencoding#parseIntoTree(query, type).child
|
||||||
for item in items
|
for item in items
|
||||||
let expand .= zencoding#toString(item, type, 0, filters)
|
let expand .= zencoding#toString(item, type, 0, filters)
|
||||||
@@ -297,7 +313,13 @@ function! zencoding#expandAbbr(mode, abbr) range
|
|||||||
let lpart = substitute(lpart, '^[0-9.-]\+\s\+', '', '')
|
let lpart = substitute(lpart, '^[0-9.-]\+\s\+', '', '')
|
||||||
let lpart = substitute(lpart, '\s\+$', '', '')
|
let lpart = substitute(lpart, '\s\+$', '', '')
|
||||||
endif
|
endif
|
||||||
|
if zencoding#useFilter(filters, '/')
|
||||||
|
for column in split(lpart, spl)
|
||||||
|
let expand = substitute(expand, '\$column\$', '\=column', '')
|
||||||
|
endfor
|
||||||
|
else
|
||||||
let expand = substitute(expand, '\$line'.(n-a:firstline+1).'\$', '\=lpart', 'g')
|
let expand = substitute(expand, '\$line'.(n-a:firstline+1).'\$', '\=lpart', 'g')
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
let expand = substitute(expand, '\$line\d*\$', '', 'g')
|
let expand = substitute(expand, '\$line\d*\$', '', 'g')
|
||||||
let content = join(getline(a:firstline, a:lastline), "\n")
|
let content = join(getline(a:firstline, a:lastline), "\n")
|
||||||
@@ -362,7 +384,7 @@ function! zencoding#expandAbbr(mode, abbr) range
|
|||||||
endif
|
endif
|
||||||
let rest = getline('.')[len(line):]
|
let rest = getline('.')[len(line):]
|
||||||
let str = part
|
let str = part
|
||||||
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\)\s*,\{0,1}\s*\)*$'
|
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
|
||||||
if str =~ mx
|
if str =~ mx
|
||||||
let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
|
let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
|
||||||
let str = substitute(str, mx, '', '')
|
let str = substitute(str, mx, '', '')
|
||||||
@@ -565,7 +587,7 @@ function! zencoding#codePretty() range
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#ExpandWord(abbr, type, orig)
|
function! zencoding#ExpandWord(abbr, type, orig)
|
||||||
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\)\s*,\{0,1}\s*\)*$'
|
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
|
||||||
let str = a:abbr
|
let str = a:abbr
|
||||||
let type = a:type
|
let type = a:type
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user