From 82c09728d757cb44fd2eb90e406ec48f704a4fbf Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 26 Mar 2013 12:43:43 +0900 Subject: [PATCH] Fix checking type for expanding abbreviation. Also move types htmldjango/drupal into default settings. --- autoload/zencoding.vim | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index 8f1c5c4..be30f7f 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 07-Jan-2013. +" Last Change: 26-Mar-2013. let s:save_cpo = &cpo set cpo&vim @@ -50,6 +50,26 @@ function! zencoding#getIndentation(...) return indent endfunction +function! zencoding#getBaseType(type) + if !has_key(s:zen_settings, a:type) + return '' + endif + if !has_key(s:zen_settings[a:type], 'extends') + return a:type + endif + let extends = s:zen_settings[a:type].extends + if type(extends) == 1 + let tmp = split(extends, '\s*,\s*') + let ext = tmp[0] + else + let ext = extends[0] + endif + if a:type != ext + return zencoding#getBaseType(ext) + endif + return '' +endfunction + function! zencoding#isExtends(type, extend) if a:type == a:extend return 1 @@ -238,9 +258,7 @@ endfunction function! zencoding#getFileType() let type = &ft - if type == 'xslt' | let type = 'xsl' | endif - if type == 'htmldjango' | let type = 'html' | endif - if type == 'html.django_template' | let type = 'html' | endif + let type = zencoding#getBaseType(type) if len(type) == 0 && zencoding#lang#exists(&ft) let type = &ft endif @@ -1155,6 +1173,9 @@ let s:zen_settings = { \ 'less': { \ 'extends': 'css', \ }, +\ 'css.drupal': { +\ 'extends': 'css', +\ }, \ 'html': { \ 'snippets': { \ 'cc:ie6': "", @@ -1354,6 +1375,12 @@ let s:zen_settings = { \ 'inline_elements': 'a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var', \ 'empty_element_suffix': ' />' \ }, +\ 'htmldjango': { +\ 'extends': 'html', +\ }, +\ 'html.django_template': { +\ 'extends': 'html', +\ }, \ 'xsl': { \ 'extends': 'html', \ 'default_attributes': { @@ -1392,6 +1419,9 @@ let s:zen_settings = { \ 'choose': 'xsl:choose>xsl:when+xsl:otherwise' \ } \ }, +\ 'xslt': { +\ 'extends': 'xsl', +\ }, \ 'haml': { \ 'indentation': ' ', \ 'extends': 'html',