diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index 5e490ea..916499e 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 23-Apr-2013. +" Last Change: 24-Apr-2013. let s:save_cpo = &cpo set cpo&vim @@ -157,9 +157,13 @@ function! zencoding#toString(...) else let group_itemno = 0 endif + if a:0 > 5 + let indent = a:6 + else + let indent = '' + endif let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1) - let indent = zencoding#getIndentation(type) let itemno = 0 let str = '' let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1) @@ -209,7 +213,7 @@ function! zencoding#toString(...) if len(current.child) let render_type = zencoding#getFileType(1) for n in current.child - let inner .= zencoding#toString(n, type, inline, filters, group_itemno) + let inner .= zencoding#toString(n, type, inline, filters, group_itemno, indent) endfor endif let spaces = matchstr(str, '\s*\ze\${child}') @@ -294,6 +298,7 @@ endfunction function! zencoding#expandAbbr(mode, abbr) range let type = zencoding#getFileType() let rtype = zencoding#getFileType(1) + let indent = zencoding#getIndentation(type) let expand = '' let filters = ['html'] let line = '' @@ -326,7 +331,7 @@ function! zencoding#expandAbbr(mode, abbr) range endif let items = zencoding#parseIntoTree(query, type).child for item in items - let expand .= zencoding#toString(item, type, 0, filters) + let expand .= zencoding#toString(item, type, 0, filters, 0, indent) endfor if zencoding#useFilter(filters, 'e') let expand = substitute(expand, '&', '\&', 'g') @@ -381,7 +386,7 @@ function! zencoding#expandAbbr(mode, abbr) range let items = zencoding#parseIntoTree(leader . "{".str."}", type).child endif for item in items - let expand .= zencoding#toString(item, type, 0, filters) + let expand .= zencoding#toString(item, type, 0, filters, 0, '') endfor if zencoding#useFilter(filters, 'e') let expand = substitute(expand, '&', '\&', 'g') @@ -421,7 +426,7 @@ function! zencoding#expandAbbr(mode, abbr) range endif let items = zencoding#parseIntoTree(str, rtype).child for item in items - let expand .= zencoding#toString(item, rtype, 0, filters) + let expand .= zencoding#toString(item, rtype, 0, filters, 0, indent) endfor if zencoding#useFilter(filters, 'e') let expand = substitute(expand, '&', '\&', 'g') @@ -620,6 +625,7 @@ function! zencoding#ExpandWord(abbr, type, orig) let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$' let str = a:abbr let type = a:type + let indent = zencoding#getIndentation(type) if len(type) == 0 | let type = 'html' | endif if str =~ mx @@ -633,7 +639,7 @@ function! zencoding#ExpandWord(abbr, type, orig) let items = zencoding#parseIntoTree(str, a:type).child let expand = '' for item in items - let expand .= zencoding#toString(item, a:type, 0, filters) + let expand .= zencoding#toString(item, a:type, 0, filters, 0, indent) endfor if zencoding#useFilter(filters, 'e') let expand = substitute(expand, '&', '\&', 'g') diff --git a/autoload/zencoding/lang/haml.vim b/autoload/zencoding/lang/haml.vim index be8de24..d8ba8b7 100644 --- a/autoload/zencoding/lang/haml.vim +++ b/autoload/zencoding/lang/haml.vim @@ -92,7 +92,7 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters, endif elseif len(current.child) > 0 for child in current.child - let inner .= zencoding#toString(child, type, inline, filters, itemno) + let inner .= zencoding#toString(child, type, inline, filters, itemno, indent) endfor let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g') diff --git a/autoload/zencoding/lang/html.vim b/autoload/zencoding/lang/html.vim index 12980cc..0700247 100644 --- a/autoload/zencoding/lang/html.vim +++ b/autoload/zencoding/lang/html.vim @@ -371,7 +371,7 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters, let dr = 1 endif endif - let inner = zencoding#toString(child, type, 0, filters, itemno) + let inner = zencoding#toString(child, type, 0, filters, itemno, indent) let inner = substitute(inner, "^\n", "", 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') diff --git a/autoload/zencoding/lang/slim.vim b/autoload/zencoding/lang/slim.vim index 16597c4..f2595de 100644 --- a/autoload/zencoding/lang/slim.vim +++ b/autoload/zencoding/lang/slim.vim @@ -68,7 +68,7 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters, endfor elseif len(current.child) > 0 for child in current.child - let inner .= zencoding#toString(child, type, inline, filters, itemno) + let inner .= zencoding#toString(child, type, inline, filters, itemno, indent) endfor let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')