mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-07 19:24:27 +08:00
plug map
This commit is contained in:
@@ -189,7 +189,7 @@ let s:zen_settings = {
|
|||||||
\ 'bdf:ow': 'border-fit:overwrite;',
|
\ 'bdf:ow': 'border-fit:overwrite;',
|
||||||
\ 'bdf:of': 'border-fit:overflow;',
|
\ 'bdf:of': 'border-fit:overflow;',
|
||||||
\ 'bdf:sp': 'border-fit:space;',
|
\ 'bdf:sp': 'border-fit:space;',
|
||||||
\ 'bdl': ['border-left:|;', 'border-length:|;'],
|
\ 'bdl': 'border-left:|;',
|
||||||
\ 'bdl:a': 'border-length:auto;',
|
\ 'bdl:a': 'border-length:auto;',
|
||||||
\ 'bdsp': 'border-spacing:|;',
|
\ 'bdsp': 'border-spacing:|;',
|
||||||
\ 'bds': 'border-style:|;',
|
\ 'bds': 'border-style:|;',
|
||||||
@@ -218,7 +218,7 @@ let s:zen_settings = {
|
|||||||
\ 'bdr+': 'border-right:1px solid #000;',
|
\ 'bdr+': 'border-right:1px solid #000;',
|
||||||
\ 'bdr:n': 'border-right:none;',
|
\ 'bdr:n': 'border-right:none;',
|
||||||
\ 'bdrw': 'border-right-width:|;',
|
\ 'bdrw': 'border-right-width:|;',
|
||||||
\ 'bdrs': ['border-right-style:|;', 'border-radius:|;'],
|
\ 'bdrs': 'border-right-style:|;',
|
||||||
\ 'bdrs:n': 'border-right-style:none;',
|
\ 'bdrs:n': 'border-right-style:none;',
|
||||||
\ 'bdrc': 'border-right-color:#000;',
|
\ 'bdrc': 'border-right-color:#000;',
|
||||||
\ 'bdb': 'border-bottom:|;',
|
\ 'bdb': 'border-bottom:|;',
|
||||||
@@ -228,12 +228,14 @@ let s:zen_settings = {
|
|||||||
\ 'bdbs': 'border-bottom-style:|;',
|
\ 'bdbs': 'border-bottom-style:|;',
|
||||||
\ 'bdbs:n': 'border-bottom-style:none;',
|
\ 'bdbs:n': 'border-bottom-style:none;',
|
||||||
\ 'bdbc': 'border-bottom-color:#000;',
|
\ 'bdbc': 'border-bottom-color:#000;',
|
||||||
|
\ 'bdln': 'border-length:|;',
|
||||||
\ 'bdl+': 'border-left:1px solid #000;',
|
\ 'bdl+': 'border-left:1px solid #000;',
|
||||||
\ 'bdl:n': 'border-left:none;',
|
\ 'bdl:n': 'border-left:none;',
|
||||||
\ 'bdlw': 'border-left-width:|;',
|
\ 'bdlw': 'border-left-width:|;',
|
||||||
\ 'bdls': 'border-left-style:|;',
|
\ 'bdls': 'border-left-style:|;',
|
||||||
\ 'bdls:n': 'border-left-style:none;',
|
\ 'bdls:n': 'border-left-style:none;',
|
||||||
\ 'bdlc': 'border-left-color:#000;',
|
\ 'bdlc': 'border-left-color:#000;',
|
||||||
|
\ 'bdrus': 'border-radius:|;',
|
||||||
\ 'bdtrrs': 'border-top-right-radius:|;',
|
\ 'bdtrrs': 'border-top-right-radius:|;',
|
||||||
\ 'bdtlrs': 'border-top-left-radius:|;',
|
\ 'bdtlrs': 'border-top-left-radius:|;',
|
||||||
\ 'bdbrrs': 'border-bottom-right-radius:|;',
|
\ 'bdbrrs': 'border-bottom-right-radius:|;',
|
||||||
@@ -721,7 +723,7 @@ let s:zen_settings = {
|
|||||||
\ }
|
\ }
|
||||||
\}
|
\}
|
||||||
|
|
||||||
function! s:parseIntoTree(abbr, type)
|
function! s:zen_parseIntoTree(abbr, type)
|
||||||
let abbr = a:abbr
|
let abbr = a:abbr
|
||||||
let type = a:type
|
let type = a:type
|
||||||
if len(type) == 0 | let type = 'html' | endif
|
if len(type) == 0 | let type = 'html' | endif
|
||||||
@@ -777,7 +779,7 @@ function! s:parseIntoTree(abbr, type)
|
|||||||
return root
|
return root
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:toString(...)
|
function! s:zen_toString(...)
|
||||||
let current = a:1
|
let current = a:1
|
||||||
if a:0 > 1
|
if a:0 > 1
|
||||||
let type = a:2
|
let type = a:2
|
||||||
@@ -803,7 +805,7 @@ function! s:toString(...)
|
|||||||
endwhile
|
endwhile
|
||||||
let inner = ''
|
let inner = ''
|
||||||
for child in current['child']
|
for child in current['child']
|
||||||
let inner .= s:toString(child, type)
|
let inner .= s:zen_toString(child, type)
|
||||||
endfor
|
endfor
|
||||||
if len(inner)
|
if len(inner)
|
||||||
let inner = substitute(inner, "\n", "\n\t", 'g')
|
let inner = substitute(inner, "\n", "\n\t", 'g')
|
||||||
@@ -818,27 +820,29 @@ function! s:toString(...)
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let str .= '' . current['snippet']
|
let str .= '' . current['snippet']
|
||||||
|
let inner = ''
|
||||||
if len(current['child'])
|
if len(current['child'])
|
||||||
let inner = ''
|
|
||||||
for n in current['child']
|
for n in current['child']
|
||||||
let inner .= s:toString(n, type)
|
let inner .= s:zen_toString(n, type)
|
||||||
endfor
|
endfor
|
||||||
let inner = substitute(inner, "\n", "\n\t", 'g')
|
let inner = substitute(inner, "\n", "\n\t", 'g')
|
||||||
let str = substitute(str, '\${child}', inner, '')
|
|
||||||
endif
|
endif
|
||||||
|
let str = substitute(str, '\${child}', inner, '')
|
||||||
endif
|
endif
|
||||||
let m = m + 1
|
let m = m + 1
|
||||||
endwhile
|
endwhile
|
||||||
return str
|
return str
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:expand()
|
function! s:zen_expand()
|
||||||
let expand = s:toString(s:parseIntoTree(getline('.'), '')['child'][0])
|
let line = getline('.')[:col('.')]
|
||||||
|
let line = matchstr(line, '\(\S*\)$')
|
||||||
|
let expand = s:zen_toString(s:zen_parseIntoTree(line, '')['child'][0])
|
||||||
if len(expand)
|
if len(expand)
|
||||||
if expand !~ '|'
|
if expand !~ '|'
|
||||||
let expand .= '|'
|
let expand .= '|'
|
||||||
endif
|
endif
|
||||||
silent! normal! 0d$
|
silent! exe "normal! d".(len(line)-1)."h"
|
||||||
silent! put! =expand
|
silent! put! =expand
|
||||||
call search('|', 'b')
|
call search('|', 'b')
|
||||||
endif
|
endif
|
||||||
@@ -849,7 +853,8 @@ function! ZenExpand(abbr, type)
|
|||||||
return s:toString(s:parseIntoTree(a:abbr, a:type)['child'][0])
|
return s:toString(s:parseIntoTree(a:abbr, a:type)['child'][0])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
inoremap <c-,> <c-r>=<sid>expand()<cr><del>
|
inoremap <plug>ZenCodingExpand <c-r>=<sid>zen_expand()<cr><del>
|
||||||
|
imap <c-z>, <plug>ZenCodingExpand
|
||||||
|
|
||||||
" test
|
" test
|
||||||
"echo ZenExpand('html:xt>div#header>div#logo+ul#nav>li.item-$*5>a', '')
|
"echo ZenExpand('html:xt>div#header>div#logo+ul#nav>li.item-$*5>a', '')
|
||||||
|
|||||||
Reference in New Issue
Block a user