26 Commits

Author SHA1 Message Date
Yasuhiro Matsumoto
5fe726da47 fix abbreviation 2015-11-11 19:44:25 +09:00
Yasuhiro Matsumoto
451367a2ce add doc for emmet-update-tag
Close #285
2015-11-10 10:34:50 +09:00
Yasuhiro Matsumoto
f752a4250c add doc for emmet-expand-word 2015-11-10 10:25:11 +09:00
Yasuhiro Matsumoto
1672e5664c should behave on only html 2015-11-10 09:43:25 +09:00
Yasuhiro Matsumoto
5819343b88 oops. fixed bug 2015-11-10 09:41:17 +09:00
Yasuhiro Matsumoto
913dfe686d remove debug message 2015-11-10 09:39:13 +09:00
Yasuhiro Matsumoto
603d6e4fcd fix bug 2015-11-10 09:38:27 +09:00
Yasuhiro Matsumoto
136b87a330 expand snippets for filetypes like html.handlebars
Close #298
2015-11-10 09:36:15 +09:00
Yasuhiro Matsumoto
5eb1061a3d redirect expanding.
Close #237
2015-11-10 09:13:48 +09:00
Yasuhiro Matsumoto
4110fb0f7b ignore django template 2015-10-26 09:44:07 +09:00
Yasuhiro Matsumoto
1691ccc7e8 fix default_attributes 2015-10-20 10:49:55 +09:00
Yasuhiro Matsumoto
0bd0a38a29 fix merge configuration 2015-10-20 10:12:03 +09:00
Yasuhiro Matsumoto
13b842d9c4 default_attributes should be array of dictionary 2015-10-20 09:29:34 +09:00
Yasuhiro Matsumoto
fceb37243a appending array configuration into map
Close #301
2015-10-20 09:04:11 +09:00
Yasuhiro Matsumoto
abdf10e91c allow empty configuration 2015-10-02 19:01:19 +09:00
Yasuhiro Matsumoto
333fede99b fix #296 2015-09-29 14:51:44 +09:00
Yasuhiro Matsumoto
037c7e5720 add test for bem filter 2015-09-25 09:26:43 +09:00
Yasuhiro Matsumoto
5041c20aae don't use getchar(0). unittest.vim stop the test-sequence. 2015-09-25 09:19:16 +09:00
Yasuhiro Matsumoto
77747c762a fix bem filter. close #295 2015-09-25 09:18:47 +09:00
Yasuhiro Matsumoto
4933347202 fix #292 2015-08-31 14:24:14 +09:00
Yasuhiro Matsumoto
1c240c6d6d extendible configuration with '*' 2015-08-20 00:20:53 +09:00
Yasuhiro Matsumoto
2c429485ec fix #290. use getpos('.') instead 2015-08-18 21:57:16 +09:00
Yasuhiro Matsumoto
7a9412d3da fix #289. don't remove ${cursor} in attributes 2015-08-18 10:50:09 +09:00
Yasuhiro Matsumoto
6e1175326e Merge branch 'master' of https://github.com/mattn/emmet-vim 2015-08-17 20:33:14 +09:00
mattn
cee9e9d6c8 Merge pull request #286 from xnuk/master
Jade: add snippets
2015-08-17 09:34:40 +09:00
즈눅
0617f58dd6 Jade: add snippets 2015-08-15 05:34:52 +09:00
6 changed files with 285 additions and 172 deletions

View File

@@ -126,7 +126,8 @@ endfunction
function! emmet#mergeConfig(lhs, rhs) abort
let [lhs, rhs] = [a:lhs, a:rhs]
if type(lhs) ==# 3 && type(rhs) ==# 3
if type(lhs) ==# 3
if type(rhs) ==# 3
let lhs += rhs
if len(lhs)
call remove(lhs, 0, len(lhs)-1)
@@ -134,13 +135,32 @@ function! emmet#mergeConfig(lhs, rhs) abort
for rhi in rhs
call add(lhs, rhs[rhi])
endfor
elseif type(lhs) ==# 4 && type(rhs) ==# 4
elseif type(rhs) ==# 4
let lhs += map(keys(rhs), '{v:val : rhs[v:val]}')
endif
elseif type(lhs) ==# 4
if type(rhs) ==# 3
for V in rhs
if type(V) != 4
continue
endif
for k in keys(V)
let lhs[k] = V[k]
endfor
endfor
elseif type(rhs) ==# 4
for key in keys(rhs)
if type(rhs[key]) ==# 3
if !has_key(lhs, key)
let lhs[key] = []
endif
if type(lhs[key]) == 3
let lhs[key] += rhs[key]
elseif type(lhs[key]) == 4
for k in keys(rhs[key])
let lhs[key][k] = rhs[key][k]
endfor
endif
elseif type(rhs[key]) ==# 4
if has_key(lhs, key)
call emmet#mergeConfig(lhs[key], rhs[key])
@@ -152,6 +172,7 @@ function! emmet#mergeConfig(lhs, rhs) abort
endif
endfor
endif
endif
endfunction
function! emmet#newNode() abort
@@ -269,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
@@ -290,8 +312,18 @@ function! emmet#getResource(type, name, default) abort
if exists('b:emmet_' . a:name)
return get(b:, 'emmet_' . a:name)
endif
let global = {}
if has_key(s:emmet_settings, '*') && has_key(s:emmet_settings['*'], a:name)
let global = extend(global, s:emmet_settings['*'][a:name])
endif
for type in split(a:type, '\.')
if has_key(s:emmet_settings, a:type)
let types = [a:type]
else
let types = split(a:type, '\.')
endif
for type in types
if !has_key(s:emmet_settings, type)
continue
endif
@@ -318,22 +350,36 @@ function! emmet#getResource(type, name, default) abort
if has_key(s:emmet_settings[type], a:name)
if type(ret) ==# 3 || type(ret) ==# 4
call emmet#mergeConfig(ret, s:emmet_settings[type][a:name])
return extend(global, ret)
else
let ret = s:emmet_settings[type][a:name]
return s:emmet_settings[type][a:name]
endif
endif
if !empty(ret)
if type(ret) ==# 3 || type(ret) ==# 4
let ret = extend(global, ret)
endif
return ret
endif
endfor
return a:default
let ret = a:default
if type(ret) ==# 3 || type(ret) ==# 4
let ret = extend(global, ret)
endif
return ret
endfunction
function! emmet#getFileType(...) abort
let flg = get(a:000, 0, 0)
let type = ''
for part in split(&filetype, '\.')
if has_key(s:emmet_settings, &filetype)
let types = [&filetype]
else
let types = split(&filetype, '\.')
endif
for part in types
if emmet#lang#exists(part)
let type = part
break
@@ -496,8 +542,12 @@ function! emmet#expandAbbr(mode, abbr) range abort
let spl = ''
endif
let items = emmet#parseIntoTree(query, type).child
let itemno = 0
for item in items
let expand .= emmet#toString(item, rtype, 0, filters, 0, indent)
let inner = emmet#toString(item, rtype, 0, filters, 0, indent)
let inner = substitute(inner, '\$#', '$line'.(itemno*(a:lastline - a:firstline + 1)/len(items)+1).'$', 'g')
let expand .= inner
let itemno = itemno + 1
endfor
if emmet#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&', 'g')
@@ -674,7 +724,7 @@ function! emmet#expandAbbr(mode, abbr) range abort
if g:emmet_debug > 1
call getchar()
endif
if search('\ze\$\(cursor\|select\)\$')
if search('\ze\$\(cursor\|select\)\$', 'c')
let oldselection = &selection
let &selection = 'inclusive'
if foldclosed(line('.')) !=# -1
@@ -1577,8 +1627,7 @@ let s:emmet_settings = {
\ 'extends': 'css',
\ },
\ 'html': {
\ 'snippets': {
\ '!': "html:5",
\ 'abbreviations': {
\ '!!!': "<!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",
@@ -1589,67 +1638,30 @@ let s:emmet_settings = {
\ 'cc:ie6': "<!--[if lte IE 6]>\n\t${child}|\n<![endif]-->",
\ 'cc:ie': "<!--[if IE]>\n\t${child}|\n<![endif]-->",
\ 'cc:noie': "<!--[if !IE]><!-->\n\t${child}|\n<!--<![endif]-->",
\ '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"
\ ."<head>\n"
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\">\n"
\ ."\t<title></title>\n"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>",
\ 'html:4s': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
\ ."<html lang=\"${lang}\">\n"
\ ."<head>\n"
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\">\n"
\ ."\t<title></title>\n"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>",
\ 'html:xt': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
\ ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"${lang}\">\n"
\ ."<head>\n"
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\" />\n"
\ ."\t<title></title>\n"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>",
\ 'html:xs': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
\ ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"${lang}\">\n"
\ ."<head>\n"
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\" />\n"
\ ."\t<title></title>\n"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>",
\ 'html:xxs': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
\ ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"${lang}\">\n"
\ ."<head>\n"
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\" />\n"
\ ."\t<title></title>\n"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>",
\ 'html:5': "<!DOCTYPE html>\n"
\ ."<html lang=\"${lang}\">\n"
\ ."<head>\n"
\ ."\t<meta charset=\"${charset}\">\n"
\ ."\t<title></title>\n"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>",
\ },
\ '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': ''},
\ 'a:link': {'href': 'http://|'},
\ 'a:mail': {'href': 'mailto:|'},
\ 'abbr': {'title': ''},
\ 'acronym': {'title': ''},
\ 'base': {'href': ''},
\ 'bdo': {'dir': ''},
\ 'bdo:r': {'dir': 'rtl'},
\ 'bdo:l': {'dir': 'ltr'},
\ 'del': {'datetime': '${datetime}'},
\ 'ins': {'datetime': '${datetime}'},
\ 'a': [{'href': ''}],
\ 'a:link': [{'href': 'http://|'}],
\ 'a:mail': [{'href': 'mailto:|'}],
\ 'abbr': [{'title': ''}],
\ 'acronym': [{'title': ''}],
\ 'base': [{'href': ''}],
\ 'bdo': [{'dir': ''}],
\ 'bdo:r': [{'dir': 'rtl'}],
\ 'bdo:l': [{'dir': 'ltr'}],
\ 'del': [{'datetime': '${datetime}'}],
\ 'ins': [{'datetime': '${datetime}'}],
\ 'link:css': [{'rel': 'stylesheet'}, g:emmet_html5 ? {} : {'type': 'text/css'}, {'href': '|style.css'}, {'media': 'all'}],
\ 'link:print': [{'rel': 'stylesheet'}, g:emmet_html5 ? {} : {'type': 'text/css'}, {'href': '|print.css'}, {'media': 'print'}],
\ 'link:import': [{'rel': 'import'}, {'href': '|.html'}],
@@ -1662,9 +1674,9 @@ let s:emmet_settings = {
\ 'meta:vp': [{'name': 'viewport'}, {'content': 'width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'}],
\ 'meta:win': [{'http-equiv': 'Content-Type'}, {'content': 'text/html;charset=Win-1251'}],
\ 'meta:compat': [{'http-equiv': 'X-UA-Compatible'}, {'content': 'IE=7'}],
\ 'style': g:emmet_html5 ? {} : {'type': 'text/css'},
\ 'script': g:emmet_html5 ? {} : {'type': 'text/javascript'},
\ 'script:src': g:emmet_html5 ? {'src': ''} : [{'type': 'text/javascript'}, {'src': ''}],
\ 'style': g:emmet_html5 ? [] : [{'type': 'text/css'}],
\ 'script': [{'src': ''}] + (g:emmet_html5 ? [] : [{'type': 'text/javascript'}]),
\ 'script:src': [{'src': ''}] + (g:emmet_html5 ? [] : [{'type': 'text/javascript'}, {'src': ''}]),
\ 'img': [{'src': ''}, {'alt': ''}],
\ 'iframe': [{'src': ''}, {'frameborder': '0'}],
\ 'embed': [{'src': ''}, {'type': ''}],
@@ -1677,12 +1689,12 @@ let s:emmet_settings = {
\ 'area:r': [{'shape': 'rect'}, {'coords': ''}, {'href': ''}, {'alt': ''}],
\ 'area:p': [{'shape': 'poly'}, {'coords': ''}, {'href': ''}, {'alt': ''}],
\ 'link': [{'rel': 'stylesheet'}, {'href': ''}],
\ 'form': {'action': ''},
\ 'form:get': {'action': '', 'method': 'get'},
\ 'form:post': {'action': '', 'method': 'post'},
\ 'form:upload': {'action': '', 'method': 'post', 'enctype': 'multipart/form-data'},
\ 'label': {'for': ''},
\ 'input': {'type': ''},
\ 'form': [{'action': ''}],
\ 'form:get': [{'action': ''}, {'method': 'get'}],
\ 'form:post': [{'action': ''}, {'method': 'post'}],
\ 'form:upload': [{'action': ''}, {'method': 'post'}, {'enctype': 'multipart/form-data'}],
\ 'label': [{'for': ''}],
\ 'input': [{'type': ''}],
\ 'input:hidden': [{'type': 'hidden'}, {'name': ''}],
\ 'input:h': [{'type': 'hidden'}, {'name': ''}],
\ 'input:text': [{'type': 'text'}, {'name': ''}, {'id': ''}],
@@ -1715,14 +1727,14 @@ let s:emmet_settings = {
\ 'input:button': [{'type': 'button'}, {'value': ''}],
\ 'input:b': [{'type': 'button'}, {'value': ''}],
\ 'select': [{'name': ''}, {'id': ''}],
\ 'option': {'value': ''},
\ 'option': [{'value': ''}],
\ 'textarea': [{'name': ''}, {'id': ''}, {'cols': '30'}, {'rows': '10'}],
\ 'menu:context': {'type': 'context'},
\ 'menu:c': {'type': 'context'},
\ 'menu:toolbar': {'type': 'toolbar'},
\ 'menu:t': {'type': 'toolbar'},
\ 'video': {'src': ''},
\ 'audio': {'src': ''},
\ 'menu:context': [{'type': 'context'}],
\ 'menu:c': [{'type': 'context'}],
\ 'menu:toolbar': [{'type': 'toolbar'}],
\ 'menu:t': [{'type': 'toolbar'}],
\ 'video': [{'src': ''}],
\ 'audio': [{'src': ''}],
\ 'html:xml': [{'xmlns': 'http://www.w3.org/1999/xhtml'}, {'xml:lang': '${lang}'}],
\ },
\ 'aliases': {
@@ -1793,6 +1805,10 @@ let s:emmet_settings = {
\ 'html.django_template': {
\ 'extends': 'html',
\ },
\ 'jade': {
\ 'indentation': ' ',
\ 'extends': 'html',
\ },
\ 'xsl': {
\ 'extends': 'html',
\ 'default_attributes': {
@@ -1811,6 +1827,47 @@ let s:emmet_settings = {
\ 'each': {'select': ''},
\ 'ap': [{'select': ''}, {'mode': ''}]
\ },
\ "abbreviations": {
\ 'tm|tmatch': "<xsl:template match=\"\" mode=\"\">",
\ 'tn|tname': "<xsl:template name=\"\">",
\ 'call': "<xsl:call-template name=\"\"/>",
\ 'ap': "<xsl:apply-templates select=\"\" mode=\"\"/>",
\ 'api': "<xsl:apply-imports/>",
\ 'imp': "<xsl:import href=\"\"/>",
\ 'inc': "<xsl:include href=\"\"/>",
\ 'ch': "<xsl:choose>",
\ 'wh|xsl:when': "<xsl:when test=\"\">",
\ 'ot': "<xsl:otherwise>",
\ 'if': "<xsl:if test=\"\">",
\ 'par': "<xsl:param name=\"\">",
\ 'pare': "<xsl:param name=\"\" select=\"\"/>",
\ 'var': "<xsl:variable name=\"\">",
\ 'vare': "<xsl:variable name=\"\" select=\"\"/>",
\ 'wp': "<xsl:with-param name=\"\" select=\"\"/>",
\ 'key': "<xsl:key name=\"\" match=\"\" use=\"\"/>",
\ 'elem': "<xsl:element name=\"\">",
\ 'attr': "<xsl:attribute name=\"\">",
\ 'attrs': "<xsl:attribute-set name=\"\">",
\ 'cp': "<xsl:copy select=\"\"/>",
\ 'co': "<xsl:copy-of select=\"\"/>",
\ 'val': "<xsl:value-of select=\"\"/>",
\ 'for|each': "<xsl:for-each select=\"\">",
\ 'tex': "<xsl:text></xsl:text>",
\ 'com': "<xsl:comment>",
\ 'msg': "<xsl:message terminate=\"no\">",
\ 'fall': "<xsl:fallback>",
\ 'num': "<xsl:number value=\"\"/>",
\ 'nam': "<namespace-alias stylesheet-prefix=\"\" result-prefix=\"\"/>",
\ 'pres': "<xsl:preserve-space elements=\"\"/>",
\ 'strip': "<xsl:strip-space elements=\"\"/>",
\ 'proc': "<xsl:processing-instruction name=\"\">",
\ 'sort': "<xsl:sort select=\"\" order=\"\"/>",
\ 'choose+': "xsl:choose>xsl:when+xsl:otherwise",
\ 'xsl': "!!!+xsl:stylesheet[version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform]>{\n|}"
\ },
\ "snippets": {
\ "!!!": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
\ },
\ 'aliases': {
\ 'tmatch': 'xsl:template',
\ 'tname': 'xsl:template',
@@ -1841,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': {
@@ -1879,7 +1923,7 @@ let s:emmet_settings = {
\ ."\t<xsd:element name=\"\" type=\"\"/>\n"
\ ."</xsd:schema>\n"
\ }
\ }
\ },
\}
if exists('g:user_emmet_settings')

View File

@@ -56,7 +56,6 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
let tmp .= ' '
endif
endif
let Val = substitute(Val, '\${cursor}', '', '')
if attribute_style ==# 'hash'
let tmp .= ' :' . attr . ' => "' . Val . '"'
elseif attribute_style ==# 'html'

View File

@@ -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_\-\$]\+\)'
@@ -22,6 +22,13 @@ function! emmet#lang#html#findTokens(str) abort
endif
let pos = stridx(str, tag, pos) + len(tag)
endwhile
while 1
let tag = matchstr(str, '{%[^%]\{-}%}', pos)
if len(tag) == 0
break
endif
let pos = stridx(str, tag, pos) + len(tag)
endwhile
let last_pos = pos
while len(str) > 0
let token = matchstr(str, s:mx, pos)
@@ -116,7 +123,27 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
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 abbreviation = substitute(abbreviation, '|', '${cursor}', 'g')
endif
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
@@ -128,12 +155,21 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
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')
@@ -251,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
@@ -442,17 +481,17 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
if len(Val) > 0
let Val .= ' '
endif
if _val =~# '^\a_'
let lead = _val[0]
let Val .= lead . ' ' . _val
elseif _val =~# '^_'
if _val =~# '^_'
let lead = vals[0]
let Val .= lead . _val
elseif _val =~# '^-'
if len(lead) == 0
let pattr = current.parent.attr
if has_key(pattr, 'class')
let lead = pattr['class']
let lead = split(pattr['class'], '\s\+')[0]
endif
endif
let Val .= lead . ' ' . lead . _val
let Val .= lead . _val
else
let Val .= _val
endif
@@ -623,8 +662,8 @@ function! emmet#lang#html#parseTag(tag) abort
endfunction
function! emmet#lang#html#toggleComment() abort
let orgpos = emmet#util#getcurpos()
let curpos = emmet#util#getcurpos()
let orgpos = getpos('.')
let curpos = getpos('.')
let mx = '<\%#[^>]*>'
while 1
let block = emmet#util#searchRegion('<!--', '-->')
@@ -642,7 +681,7 @@ function! emmet#lang#html#toggleComment() abort
if pos1[0] == 0 && pos1[1] == 0
return
endif
let curpos = emmet#util#getcurpos()
let curpos = getpos('.')
continue
endif
let pos1 = block[0]

View File

@@ -56,7 +56,6 @@ function! emmet#lang#jade#toString(settings, current, type, inline, filters, ite
let tmp .= ' '
endif
endif
let Val = substitute(Val, '\${cursor}', '', '')
if attribute_style ==# 'hash'
let tmp .= '' . attr . '="' . Val . '"'
elseif attribute_style ==# 'html'

View File

@@ -17,20 +17,22 @@ Introduction |emmet-introduction|
Install |emmet-install|
Tutorial |emmet-tutorial|
1. Expand abbreviation |emmet-expand-abbr| |<C-y>,|
2. Wrap with abbreviation |emmet-wrap-with-abbreviation| |v_<C-y>,|
3. Balance tag inward |emmet-balance-tag-inward| |<C-y>d|
4. Balance tag outward |emmet-balance-tag-outward| |<C-y>D|
5. Go to next edit point |emmet-goto-next-point| |<C-y>n|
6. Go to previous edit point |emmet-goto-previous-point| |<C-y>N|
7. Add and update <img> size |emmet-update-image-size| |<C-y>i|
8. Merge lines |emmet-merge-lines| |<C-y>m|
9. Remove tag |emmet-remove-tag| |<C-y>k|
10. Split/join tag |emmet-split-join-tag| |<C-y>j|
11. Toggle comment |emmet-toggle-comment| |<C-y>/|
12. Make anchor from URL |emmet-make-anchor-url| |<C-y>a|
13. Make quoted text from URL |emmet-quoted-text-url| |<C-y>A|
14. Code pretty |emmet-code-pretty| |<C-y>c|
15. Lorem ipsum |emmet-lorem-ipsum|
2. Expand word |emmet-expand-word| |<C-y>;|
3. Update tag |emmet-update-tag| |<C-y>u|
4. Wrap with abbreviation |emmet-wrap-with-abbreviation| |v_<C-y>,|
5. Balance tag inward |emmet-balance-tag-inward| |<C-y>d|
6. Balance tag outward |emmet-balance-tag-outward| |<C-y>D|
7. Go to next edit point |emmet-goto-next-point| |<C-y>n|
8. Go to previous edit point |emmet-goto-previous-point| |<C-y>N|
9. Add and update <img> size |emmet-update-image-size| |<C-y>i|
10. Merge lines |emmet-merge-lines| |<C-y>m|
11. Remove tag |emmet-remove-tag| |<C-y>k|
12. Split/join tag |emmet-split-join-tag| |<C-y>j|
13. Toggle comment |emmet-toggle-comment| |<C-y>/|
14. Make anchor from URL |emmet-make-anchor-url| |<C-y>a|
15. Make quoted text from URL |emmet-quoted-text-url| |<C-y>A|
16. Code pretty |emmet-code-pretty| |<C-y>c|
17. Lorem ipsum |emmet-lorem-ipsum|
HTML expression syntax |emmet-html-expression-syntax|
1. Elements |emmet-html-syntax-elements|
2. Nesting operators |emmet-html-syntax-nesting-operators|
@@ -146,7 +148,33 @@ You should copy this section and create new buffer, paste and write as
</p>
</div>
<
2. Wrap with abbreviation *emmet-wrap-with-abbreviation* *v_<C-y>,*
2. Expand abbreviation *emmet-expand-word* *<C-y>;*
When you want to expand word except html tokens like below, use this.
>
<html
>foo
<
This will be expanded like:
>
<html
><foo></foo>
3. Update tag *emmet-update-tag* *<C-y>u*
The begining of tags '<div>' on below
>
<div>foo</div>
<
Type '<C-y>u' request 'Enter Abbreviation:'. Then type
>
.global
<
This will be expanded like:
>
<div class=".global">foo</div>
<
4. Wrap with abbreviation *emmet-wrap-with-abbreviation* *v_<C-y>,*
Write as below.
>
@@ -181,7 +209,7 @@ You should copy this section and create new buffer, paste and write as
<
See also: |emmet-filter-t|, |emmet-$#|
3. Balance tag inward *emmet-balance-tag-inward* *<C-y>d*
5. Balance tag inward *emmet-balance-tag-inward* *<C-y>d*
To select inward of '<ul>' tag, type '<C-y>d' in insert mode.
>
@@ -194,7 +222,7 @@ You should copy this section and create new buffer, paste and write as
If cursor is at '*', '<C-y>d' select from begin of '<ul>' to end of '</ul>'.
If cursor is at first of '<li>', it select '<li class="list1"></li>'.
4. Balance tag outward *emmet-balance-tag-outward* *<C-y>D*
6. Balance tag outward *emmet-balance-tag-outward* *<C-y>D*
To select outward of '<ul>' tag type '<C-y>D' in insert mode.
>
@@ -208,7 +236,7 @@ You should copy this section and create new buffer, paste and write as
to previous letter of '</ul>'.
If cursor is at first of '<li>', it select '<li class="list1"></li>'.
5. Go to next edit point *emmet-goto-next-point* *<C-y>n*
7. Go to next edit point *emmet-goto-next-point* *<C-y>n*
To jump next point that need to edit, type '<C-y>n' in insert mode.
>
@@ -220,7 +248,7 @@ You should copy this section and create new buffer, paste and write as
And type again '<C-y>n' to move a cursor
into inner of '<div>' specified id as 'bar'.
6. Go to previous edit point *emmet-goto-previous-point* *<C-y>N*
8. Go to previous edit point *emmet-goto-previous-point* *<C-y>N*
To jump previous point that need to edit, type '<C-y>N' in insert mode.
>
@@ -232,7 +260,7 @@ You should copy this section and create new buffer, paste and write as
And type again '<C-y>N' to move a cursor
into attribute value of 'foo'.
7. Add and update <img> size *emmet-update-image-size* *<C-y>i*
9. Add and update <img> size *emmet-update-image-size* *<C-y>i*
To add or update 'width' and 'height' attributes of image,
type '<C-y>i' on '<img>' tag
@@ -250,7 +278,7 @@ You should copy this section and create new buffer, paste and write as
Image size retrieved using 'identify' (ImageMagick.org) (if available)
or |xxd|.
8. Merge lines *emmet-merge-lines* *<C-y>m*
10. Merge lines *emmet-merge-lines* *<C-y>m*
To join multi line text like following, type |J|.
>
@@ -267,7 +295,7 @@ You should copy this section and create new buffer, paste and write as
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
</ul>
<
9. Remove tag *emmet-remove-tag* *<C-y>k*
11. Remove tag *emmet-remove-tag* *<C-y>k*
To remove tag in the block, type '<C-y>k'.
>
@@ -283,7 +311,7 @@ You should copy this section and create new buffer, paste and write as
<
And type '<C-y>k' in there again, then '<div>' will be removed.
10. Split/join tag *emmet-split-join-tag* *<C-y>j*
12. Split/join tag *emmet-split-join-tag* *<C-y>j*
To join block, type '<C-y>j'.
>
@@ -300,7 +328,7 @@ You should copy this section and create new buffer, paste and write as
<div class="foo">
</div>
<
11. Toggle comment *emmet-toggle-comment* *<C-y>/*
13. Toggle comment *emmet-toggle-comment* *<C-y>/*
Move cursor to block
>
@@ -320,7 +348,7 @@ You should copy this section and create new buffer, paste and write as
hello world
</div>
<
12. Make anchor from URL *emmet-make-anchor-url* *<C-y>a*
14. Make anchor from URL *emmet-make-anchor-url* *<C-y>a*
Move cursor to URL
>
@@ -332,7 +360,7 @@ You should copy this section and create new buffer, paste and write as
<
Text retrieved using command, specified by |g:emmet_curl_command|.
13. Make quoted text from URL *emmet-quoted-text-url* *<C-y>A*
15. Make quoted text from URL *emmet-quoted-text-url* *<C-y>A*
Move cursor to URL
>
@@ -348,7 +376,7 @@ You should copy this section and create new buffer, paste and write as
<
Text retrieved using command, specified by |g:emmet_curl_command|.
14. Code pretty *emmet-code-pretty* *<C-y>c*
16. Code pretty *emmet-code-pretty* *<C-y>c*
Select code block, for example select following code from 'int main()'.
>
@@ -366,7 +394,7 @@ You should copy this section and create new buffer, paste and write as
<
To convert text into html used command |:TOhtml|.
15. Lorem ipsum *emmet-lorem-ipsum*
17. Lorem ipsum *emmet-lorem-ipsum*
To insert dummy text (30 words by default).
>

View File

@@ -241,7 +241,7 @@ finish
},
{
'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
'result': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />\n\t<title></title>\n</head>\n<body>\n\t<div id=\"header\">\n\t\t<div id=\"logo\"></div>\n\t\t<ul id=\"nav\">\n\t\t\t<li class=\"item-1\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-2\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-3\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-4\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-5\"><a href=\"\"></a></li>\n\t\t</ul>\n\t</div>\n\t\n</body>\n</html>",
'result': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n\t<head>\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n\t\t<title>${1:Document}</title>\n\t</head>\n\t<body>\n\t<div id=\"header\">\n\t\t<div id=\"logo\"></div>\n\t\t<ul id=\"nav\">\n\t\t\t<li class=\"item-1\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-2\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-3\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-4\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-5\"><a href=\"\"></a></li>\n\t\t</ul>\n\t</div>\n\t\n</body>\n</html>",
},
{
'query': "ol>li*2",
@@ -535,6 +535,10 @@ finish
'query': "<small>a$$$$</small>",
'result': "<small><a href=\"\"></a></small>",
},
{
'query': "form.search-form._wide>input.-query-string+input:s.-btn_large|bem",
'result': "<form class=\"search-form search-form_wide\" action=\"\">\n\t<input class=\"search-form-query-string\" type=\"\">\n\t<input class=\"search-form-btn_large\" type=\"submit\" value=\"\">\n</form>\n",
},
],
},
{