diff --git a/autoload/emmet.vim b/autoload/emmet.vim
index fe1913c..a9b98c4 100644
--- a/autoload/emmet.vim
+++ b/autoload/emmet.vim
@@ -290,6 +290,7 @@ function! emmet#toString(...) abort
else
let inner = current.value[1:-2]
endif
+ let inner = substitute(inner, '\${child}', '', '')
let inner = substitute(inner, "\n", "\n" . indent, 'g')
let str = substitute(str, '\${child}', inner, '')
endif
@@ -1626,8 +1627,7 @@ let s:emmet_settings = {
\ 'extends': 'css',
\ },
\ 'html': {
-\ 'snippets': {
-\ '!': "html:5",
+\ 'abbreviations': {
\ '!!!': "\n",
\ '!!!4t': "\n",
\ '!!!4s': "\n",
@@ -1638,54 +1638,17 @@ let s:emmet_settings = {
\ 'cc:ie6': "",
\ 'cc:ie': "",
\ 'cc:noie': "\n\t${child}|\n",
-\ 'html:4t': "\n"
-\ ."\n"
-\ ."
\n"
-\ ."\t\n"
-\ ."\t\n"
-\ ."\n"
-\ ."\n\t${child}|\n\n"
-\ ."",
-\ 'html:4s': "\n"
-\ ."\n"
-\ ."\n"
-\ ."\t\n"
-\ ."\t\n"
-\ ."\n"
-\ ."\n\t${child}|\n\n"
-\ ."",
-\ 'html:xt': "\n"
-\ ."\n"
-\ ."\n"
-\ ."\t\n"
-\ ."\t\n"
-\ ."\n"
-\ ."\n\t${child}|\n\n"
-\ ."",
-\ 'html:xs': "\n"
-\ ."\n"
-\ ."\n"
-\ ."\t\n"
-\ ."\t\n"
-\ ."\n"
-\ ."\n\t${child}|\n\n"
-\ ."",
-\ 'html:xxs': "\n"
-\ ."\n"
-\ ."\n"
-\ ."\t\n"
-\ ."\t\n"
-\ ."\n"
-\ ."\n\t${child}|\n\n"
-\ ."",
-\ 'html:5': "\n"
-\ ."\n"
-\ ."\n"
-\ ."\t\n"
-\ ."\t\n"
-\ ."\n"
-\ ."\n\t${child}|\n\n"
-\ ."",
+\ },
+\ 'snippets': {
+\ '!': "html:5",
+\ 'doc': "html>(head>meta[charset=${charset}]+title{${1:Document}})+body>${child}",
+\ 'doc4': "html>(head>meta[http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\"]+title{${1:Document}})+body>${child}",
+\ 'html:4t': "!!!4t+doc4[lang=${lang}]",
+\ 'html:4s': "!!!4s+doc4[lang=${lang}]",
+\ 'html:xt': "!!!xt+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]",
+\ 'html:xs': "!!!xs+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]",
+\ 'html:xxs': "!!!xxs+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]",
+\ 'html:5': "!!!+doc[lang=${lang}]",
\ },
\ 'default_attributes': {
\ 'a': [{'href': ''}],
@@ -1845,51 +1808,6 @@ let s:emmet_settings = {
\ 'jade': {
\ 'indentation': ' ',
\ 'extends': 'html',
-\ 'snippets': {
-\ '!!!': "doctype html\n",
-\ '!!!4t': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"\n",
-\ '!!!4s': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"\n",
-\ '!!!xt': "doctype transitional\n",
-\ '!!!xs': "doctype strict\n",
-\ '!!!xxs': "doctype 1.1\n",
-\ 'c': "\/\/ |${child}",
-\ 'html:4t': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"\n"
-\ ."html(lang=\"${lang}\")\n"
-\ ."\thead\n"
-\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
-\ ."\t\ttitle\n"
-\ ."\tbody\n\t\t${child}|",
-\ 'html:4s': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"\n"
-\ ."html(lang=\"${lang}\")\n"
-\ ."\thead\n"
-\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
-\ ."\t\ttitle\n"
-\ ."\tbody\n\t\t${child}|",
-\ 'html:xt': "doctype transitional\n"
-\ ."html(xmlns=\"http://www.w3.org/1999/xhtml\", xml:lang=\"${lang}\")\n"
-\ ."\thead\n"
-\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
-\ ."\t\ttitle\n"
-\ ."\tbody\n\t\t${child}|",
-\ 'html:xs': "doctype strict\n"
-\ ."html(xmlns=\"http://www.w3.org/1999/xhtml\", xml:lang=\"${lang}\")\n"
-\ ."\thead\n"
-\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
-\ ."\t\ttitle\n"
-\ ."\tbody\n\t\t${child}|",
-\ 'html:xxs': "doctype 1.1\n"
-\ ."html(xmlns=\"http://www.w3.org/1999/xhtml\", xml:lang=\"${lang}\")\n"
-\ ."\thead\n"
-\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
-\ ."\t\ttitle\n"
-\ ."\tbody\n\t\t${child}|",
-\ 'html:5': "doctype html\n"
-\ ."html(lang=\"${lang}\")\n"
-\ ."\thead\n"
-\ ."\t\tmeta(charset=\"${charset}\")\n"
-\ ."\t\ttitle\n"
-\ ."\tbody\n\t\t${child}|",
-\ },
\ },
\ 'xsl': {
\ 'extends': 'html',
@@ -1909,6 +1827,47 @@ let s:emmet_settings = {
\ 'each': {'select': ''},
\ 'ap': [{'select': ''}, {'mode': ''}]
\ },
+\ "abbreviations": {
+\ 'tm|tmatch': "",
+\ 'tn|tname': "",
+\ 'call': "",
+\ 'ap': "",
+\ 'api': "",
+\ 'imp': "",
+\ 'inc': "",
+\ 'ch': "",
+\ 'wh|xsl:when': "",
+\ 'ot': "",
+\ 'if': "",
+\ 'par': "",
+\ 'pare': "",
+\ 'var': "",
+\ 'vare': "",
+\ 'wp': "",
+\ 'key': "",
+\ 'elem': "",
+\ 'attr': "",
+\ 'attrs': "",
+\ 'cp': "",
+\ 'co': "",
+\ 'val': "",
+\ 'for|each': "",
+\ 'tex': "",
+\ 'com': "",
+\ 'msg': "",
+\ 'fall': "",
+\ 'num': "",
+\ 'nam': "",
+\ 'pres': "",
+\ 'strip': "",
+\ 'proc': "",
+\ 'sort': "",
+\ 'choose+': "xsl:choose>xsl:when+xsl:otherwise",
+\ 'xsl': "!!!+xsl:stylesheet[version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform]>{\n|}"
+\ },
+\ "snippets": {
+\ "!!!": ""
+\ },
\ 'aliases': {
\ 'tmatch': 'xsl:template',
\ 'tname': 'xsl:template',
@@ -1939,28 +1898,15 @@ let s:emmet_settings = {
\ 'haml': {
\ 'indentation': ' ',
\ 'extends': 'html',
-\ 'snippets': {
-\ 'html:5': "!!! 5\n"
-\ ."%html{:lang => \"${lang}\"}\n"
-\ ."\t%head\n"
-\ ."\t\t%meta{:charset => \"${charset}\"}\n"
-\ ."\t\t%title\n"
-\ ."\t%body\n"
-\ ."\t\t${child}|\n",
+\ 'abbreviations': {
+\ '!!!': "!!! 5",
\ },
\ 'attribute_style': 'hash',
\ },
\ 'slim': {
\ 'indentation': ' ',
\ 'extends': 'html',
-\ 'snippets': {
-\ 'html:5': "doctype 5\n"
-\ ."html lang=\"${lang}\"\n"
-\ ."\thead\n"
-\ ."\t\tmeta charset=\"${charset}\"\n"
-\ ."\t\ttitle\n"
-\ ."\tbody\n"
-\ ."\t\t${child}|\n",
+\ 'abbreviations': {
\ },
\ },
\ 'xhtml': {
diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim
index 968a55e..bc259a4 100644
--- a/autoload/emmet/lang/html.vim
+++ b/autoload/emmet/lang/html.vim
@@ -1,6 +1,6 @@
let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
\ .'\((*\)\{-}\s*'
-\ .'\([@#.]\{-}[a-zA-Z_\!][a-zA-Z0-9:_\!\-$]*\|{\%([^%$}]\+\|\$#\|\${\w\+}\|\$\+\)*}*[ \t\r\n}]*\|\[[^\]]\+\]\)'
+\ .'\([@#.]\{-}[a-zA-Z_\!][a-zA-Z0-9:_\!\-$]*\|\${[^}]\+}\|{\%([^%$}]\+\|\$#\|\${\w\+}\|\$\+\)*}*[ \t\r\n}]*\|\[[^\]]\+\]\)'
\ .'\('
\ .'\%('
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
@@ -123,29 +123,54 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
- " snippets
- let snippets = emmet#getResource(type, 'snippets', {})
- if !empty(snippets)
- let snippet_name = tag_name
- if has_key(snippets, snippet_name)
- let snippet = snippet_name
- while has_key(snippets, snippet)
- let snippet = snippets[snippet]
+ let abbreviations = emmet#getResource(type, 'abbreviations', {})
+ if !empty(abbreviations)
+ let abbreviation_name = tag_name
+ if has_key(abbreviations, abbreviation_name)
+ let abbreviation = abbreviation_name
+ while has_key(abbreviations, abbreviation)
+ let abbreviation = abbreviations[abbreviation]
endwhile
if use_pipe_for_cursor
- let snippet = substitute(snippet, '|', '${cursor}', 'g')
+ let abbreviation = substitute(abbreviation, '|', '${cursor}', 'g')
endif
- " just redirect to expanding
- if type == 'html' && snippet !~ '^\s*[{\[<]'
- return emmet#lang#html#parseIntoTree(snippet, a:type)
- endif
- let lines = split(snippet, "\n", 1)
+ let lines = split(abbreviation, "\n", 1)
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
let current.snippet = join(lines, "\n")
let current.name = ''
endif
endif
+ " snippets
+ let snippets = emmet#getResource(type, 'snippets', {})
+ if empty(current.snippet)
+ let snippets = emmet#getResource(type, 'snippets', {})
+ if !empty(snippets)
+ let snippet_name = tag_name
+ if has_key(snippets, snippet_name)
+ let snippet = snippet_name
+ while has_key(snippets, snippet)
+ let snippet = snippets[snippet]
+ endwhile
+ if use_pipe_for_cursor
+ let snippet = substitute(snippet, '|', '${cursor}', 'g')
+ endif
+ if emmet#isExtends(type, 'html') && snippet !~ '^\s*[{\[<]'
+ let current = emmet#lang#html#parseIntoTree(snippet, a:type)
+ if current.name == '' && current.value == '' && current.snippet == '' && len(current.child) > 0
+ let parent.child += current.child[:-2]
+ let current = current.child[-1]
+ endif
+ else
+ let lines = split(snippet, "\n", 1)
+ call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
+ let current.snippet = join(lines, "\n")
+ let current.name = ''
+ endif
+ endif
+ endif
+ endif
+
let custom_expands = emmet#getResource(type, 'custom_expands', {})
if empty(custom_expands) && has_key(settings, 'custom_expands')
let custom_expands = settings['custom_expands']
@@ -218,7 +243,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
let atts = item[1:-2]
if matchstr(atts, '^\s*\zs[0-9a-zA-Z-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') ==# ''
let ks = []
- if has_key(default_attributes, current.name)
+ if has_key(default_attributes, current.name)
let dfa = default_attributes[current.name]
let ks = type(dfa) == 3 ? keys(dfa[0]) : keys(dfa)
endif
@@ -262,6 +287,9 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
if tag_name =~# '^{.*}$'
let current.name = ''
let current.value = tag_name
+ elseif tag_name =~# '^\$\?{.*}$'
+ let current.name = ''
+ let current.value = '{' . tag_name . '}'
else
let current.value = value
endif
diff --git a/unittest.vim b/unittest.vim
index 52bdfec..c9f4305 100644
--- a/unittest.vim
+++ b/unittest.vim
@@ -241,7 +241,7 @@ finish
},
{
'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
- 'result': "\n\n\n\t\n\t\n\n\n\t\n\t\n\n",
+ 'result': "\n\n\t\n\t\t\n\t\t${1:Document}\n\t\n\t\n\t\n\t\n\n",
},
{
'query': "ol>li*2",