mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-07 19:24:27 +08:00
fixed indentation.
This commit is contained in:
@@ -813,6 +813,7 @@ function! s:zen_toString(...)
|
|||||||
endif
|
endif
|
||||||
if len(type) == 0 | let type = 'html' | endif
|
if len(type) == 0 | let type = 'html' | endif
|
||||||
|
|
||||||
|
let indent = s:zen_settings['indentation']
|
||||||
let m = 1
|
let m = 1
|
||||||
let str = ''
|
let str = ''
|
||||||
while m <= current['multiplier']
|
while m <= current['multiplier']
|
||||||
@@ -833,9 +834,9 @@ function! s:zen_toString(...)
|
|||||||
let inner .= s:zen_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" . indent, 'g')
|
||||||
let inner = substitute(inner, "\t$", "", 'g')
|
let inner = substitute(inner, indent . "$", "", 'g')
|
||||||
let str .= ">\n\t" . inner . "</" . current['name'] . ">\n"
|
let str .= ">\n" . indent . inner . "</" . current['name'] . ">\n"
|
||||||
else
|
else
|
||||||
if stridx(','.s:zen_settings[type]['empty_elements'].',', ','.current['name'].',') != -1
|
if stridx(','.s:zen_settings[type]['empty_elements'].',', ','.current['name'].',') != -1
|
||||||
let str .= " />\n"
|
let str .= " />\n"
|
||||||
@@ -854,7 +855,7 @@ function! s:zen_toString(...)
|
|||||||
for n in current['child']
|
for n in current['child']
|
||||||
let inner .= s:zen_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" . indent, 'g')
|
||||||
endif
|
endif
|
||||||
let str = substitute(str, '\${child}', inner, '')
|
let str = substitute(str, '\${child}', inner, '')
|
||||||
endif
|
endif
|
||||||
@@ -865,15 +866,18 @@ endfunction
|
|||||||
|
|
||||||
function! s:zen_expand()
|
function! s:zen_expand()
|
||||||
let line = getline('.')[:col('.')]
|
let line = getline('.')[:col('.')]
|
||||||
let line = matchstr(line, '\(\S*\)$')
|
let part = matchstr(line, '\(\S*\)$')
|
||||||
let items = s:zen_parseIntoTree(line, '')['child']
|
let items = s:zen_parseIntoTree(part, '')['child']
|
||||||
let expand = len(items) ? s:zen_toString(items[0]) : ''
|
let expand = len(items) ? s:zen_toString(items[0]) : ''
|
||||||
if len(expand)
|
if len(expand)
|
||||||
if expand !~ '|'
|
if expand !~ '|'
|
||||||
let expand .= '|'
|
let expand .= '|'
|
||||||
endif
|
endif
|
||||||
let expand = repeat("\<c-h>", len(line)) . expand
|
silent! exec "normal! ".repeat("x", len(part))
|
||||||
return expand
|
let size = len(line) - len(part)
|
||||||
|
let indent = repeat(s:zen_settings['indentation'], size)
|
||||||
|
let expand = indent . substitute(expand, "\n", "\n" . indent, 'g')
|
||||||
|
silent! put! =expand
|
||||||
endif
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user