From 19e085c7bb383155acb447948f1ebc4e957ecce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=98=A5=E5=A5=95?= <373852389@qq.com> Date: Tue, 11 Oct 2016 11:14:46 +0800 Subject: [PATCH] add the emmet-vim --- sources_forked/emmet-vim/.gitignore | 1 + sources_forked/emmet-vim/.gitmodules | 4 + sources_forked/emmet-vim/Makefile | 11 + sources_forked/emmet-vim/README.mkd | 149 ++ sources_forked/emmet-vim/TODO | 0 sources_forked/emmet-vim/TUTORIAL | 212 ++ sources_forked/emmet-vim/autoload/emmet.vim | 1994 +++++++++++++++++ .../emmet-vim/autoload/emmet/lang.vim | 11 + .../emmet-vim/autoload/emmet/lang/css.vim | 350 +++ .../emmet-vim/autoload/emmet/lang/haml.vim | 334 +++ .../emmet-vim/autoload/emmet/lang/html.vim | 947 ++++++++ .../emmet-vim/autoload/emmet/lang/jade.vim | 331 +++ .../emmet-vim/autoload/emmet/lang/less.vim | 47 + .../emmet-vim/autoload/emmet/lang/sass.vim | 160 ++ .../emmet-vim/autoload/emmet/lang/scss.vim | 125 ++ .../emmet-vim/autoload/emmet/lang/slim.vim | 281 +++ .../emmet-vim/autoload/emmet/lorem/en.vim | 65 + .../emmet-vim/autoload/emmet/lorem/ja.vim | 27 + .../emmet-vim/autoload/emmet/util.vim | 349 +++ sources_forked/emmet-vim/doc/emmet.txt | 1773 +++++++++++++++ sources_forked/emmet-vim/doc/screenshot.gif | Bin 0 -> 33279 bytes sources_forked/emmet-vim/emmet.vim.vimup | 277 +++ sources_forked/emmet-vim/plugin/emmet.vim | 177 ++ sources_forked/emmet-vim/unittest.vim | 1023 +++++++++ 24 files changed, 8648 insertions(+) create mode 100755 sources_forked/emmet-vim/.gitignore create mode 100755 sources_forked/emmet-vim/.gitmodules create mode 100755 sources_forked/emmet-vim/Makefile create mode 100755 sources_forked/emmet-vim/README.mkd create mode 100755 sources_forked/emmet-vim/TODO create mode 100755 sources_forked/emmet-vim/TUTORIAL create mode 100755 sources_forked/emmet-vim/autoload/emmet.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/css.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/haml.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/html.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/jade.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/less.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/sass.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/scss.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lang/slim.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lorem/en.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/lorem/ja.vim create mode 100755 sources_forked/emmet-vim/autoload/emmet/util.vim create mode 100755 sources_forked/emmet-vim/doc/emmet.txt create mode 100755 sources_forked/emmet-vim/doc/screenshot.gif create mode 100755 sources_forked/emmet-vim/emmet.vim.vimup create mode 100755 sources_forked/emmet-vim/plugin/emmet.vim create mode 100755 sources_forked/emmet-vim/unittest.vim diff --git a/sources_forked/emmet-vim/.gitignore b/sources_forked/emmet-vim/.gitignore new file mode 100755 index 00000000..0a56e3fc --- /dev/null +++ b/sources_forked/emmet-vim/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_forked/emmet-vim/.gitmodules b/sources_forked/emmet-vim/.gitmodules new file mode 100755 index 00000000..2dc018d9 --- /dev/null +++ b/sources_forked/emmet-vim/.gitmodules @@ -0,0 +1,4 @@ +[submodule "docs"] + path = docs + url = https://github.com/mattn/emmet-vim + branch = gh-pages diff --git a/sources_forked/emmet-vim/Makefile b/sources_forked/emmet-vim/Makefile new file mode 100755 index 00000000..1c060231 --- /dev/null +++ b/sources_forked/emmet-vim/Makefile @@ -0,0 +1,11 @@ +all : emmet-vim.zip + +remove-zip: + -rm doc/tags + -rm emmet-vim.zip + +emmet-vim.zip: remove-zip + zip -r emmet-vim.zip autoload plugin doc + +release: emmet-vim.zip + vimup update-script emmet.vim diff --git a/sources_forked/emmet-vim/README.mkd b/sources_forked/emmet-vim/README.mkd new file mode 100755 index 00000000..8bb52b26 --- /dev/null +++ b/sources_forked/emmet-vim/README.mkd @@ -0,0 +1,149 @@ +# Emmet-vim + +[emmet-vim](http://mattn.github.com/emmet-vim) is a vim plug-in +which provides support for expanding abbreviations similar to +[emmet](http://emmet.io/). + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mattn/emmet-vim/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + +![](https://raw.githubusercontent.com/mattn/emmet-vim/master/doc/screenshot.gif) + +## Installation + +[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981): + + cd ~/.vim + unzip emmet-vim.zip + +To install using pathogen.vim: + + cd ~/.vim/bundle + git clone https://github.com/mattn/emmet-vim.git + +To install using [Vundle](https://github.com/gmarik/vundle): + + " add this line to your .vimrc file + Plugin 'mattn/emmet-vim' + +To checkout the source from repository: + + cd ~/.vim/bundle + git clone https://github.com/mattn/emmet-vim.git + +or: + + git clone https://github.com/mattn/emmet-vim.git + cd emmet-vim + cp plugin/emmet.vim ~/.vim/plugin/ + cp autoload/emmet.vim ~/.vim/autoload/ + cp -a autoload/emmet ~/.vim/autoload/ + + +## Quick Tutorial + +Open or create a New File: + + vim index.html + +Type ("\_" is the cursor position): + + html:5_ + +Then type `,` (Ctrly,), and you should see: + +```html + + + + + + + + _ + + +``` + +[More Tutorials](https://raw.github.com/mattn/emmet-vim/master/TUTORIAL) + + +## Enable in different mode + +If you don't want to enable emmet in all modes, +you can use set these options in `vimrc`: + +```vim +let g:user_emmet_mode='n' "only enable normal mode functions. +let g:user_emmet_mode='inv' "enable all functions, which is equal to +let g:user_emmet_mode='a' "enable all function in all mode. +``` + +## Enable just for html/css + +```vim +let g:user_emmet_install_global = 0 +autocmd FileType html,css EmmetInstall +``` + +## Redefine trigger key +To remap the default `` leader: + +```vim +let g:user_emmet_leader_key='' +``` + +Note that the trailing `,` still needs to be entered, so the new keymap would be `,`. + +## Adding custom snippets +If you have installed the [web-api](https://github.com/mattn/webapi-vim) for **emmet-vim** you can also add your own snippets using a custom **snippets.json** file. + +Once you have installed the [web-api](https://github.com/mattn/webapi-vim) add this line to your **.vimrc**: +``` +let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.snippets_custom.json')), "\n")) +``` +You can change the **path** to your **snippets_custom.json** according to your preferences. + +[Here](http://docs.emmet.io/customization/snippets/) you can find instructions about creating your customized **snippets.json** file. + +## Project Authors + +[Yasuhiro Matsumoto](http://mattn.kaoriya.net/) + +## Links + +### Emmet official site: + +* + +### zen-coding official site: + +* + +### emmet.vim: + +* + +### development repository: + +* + +### my blog posts about zencoding-vim: + +* + +* + +### Japanese blog posts about zencoding-vim: + +* + +* + +* + +* + +### A Chinese translation of the tutorial: + +* + diff --git a/sources_forked/emmet-vim/TODO b/sources_forked/emmet-vim/TODO new file mode 100755 index 00000000..e69de29b diff --git a/sources_forked/emmet-vim/TUTORIAL b/sources_forked/emmet-vim/TUTORIAL new file mode 100755 index 00000000..7d4ba615 --- /dev/null +++ b/sources_forked/emmet-vim/TUTORIAL @@ -0,0 +1,212 @@ +Tutorial for Emmet.vim + + mattn + +1. Expand an Abbreviation + + Type the abbreviation as 'div>p#foo$*3>a' and type ','. + --------------------- +
+

+ +

+

+ +

+

+ +

+
+ --------------------- + +2. Wrap with an Abbreviation + + Write as below. + --------------------- + test1 + test2 + test3 + --------------------- + Then do visual select(line wise) and type ','. + Once you get to the 'Tag:' prompt, type 'ul>li*'. + --------------------- +
    +
  • test1
  • +
  • test2
  • +
  • test3
  • +
+ --------------------- + + If you type a tag, such as 'blockquote', then you'll see the following: + --------------------- +
+ test1 + test2 + test3 +
+ --------------------- + +3. Balance a Tag Inward + + type 'd' in insert mode. + +4. Balance a Tag Outward + + type 'D' in insert mode. + +5. Go to the Next Edit Point + + type 'n' in insert mode. + +6. Go to the Previous Edit Point + + type 'N' in insert mode. + +7. Update an ’s Size + + Move cursor to the img tag. + --------------------- + + --------------------- + Type 'i' on img tag + --------------------- + + --------------------- + +8. Merge Lines + + select the lines, which include '
  • ' + --------------------- +
      +
    • +
    • +
    • +
    + --------------------- + and then type 'm' + --------------------- +
      +
    • +
    + --------------------- + +9. Remove a Tag + + Move cursor in block + --------------------- + + --------------------- + Type 'k' in insert mode. + --------------------- +
    + +
    + --------------------- + + And type 'k' in there again. + --------------------- + + --------------------- + +10. Split/Join Tag + + Move the cursor inside block + --------------------- +
    + cursor is here +
    + --------------------- + Type 'j' in insert mode. + --------------------- +
    + --------------------- + + And then type 'j' in there again. + --------------------- +
    +
    + --------------------- + +11. Toggle Comment + + Move cursor inside the block + --------------------- +
    + hello world +
    + --------------------- + Type '/' in insert mode. + --------------------- + + --------------------- + Type '/' in there again. + --------------------- +
    + hello world +
    + --------------------- + +12. Make an anchor from a URL + + Move cursor to URL + --------------------- + http://www.google.com/ + --------------------- + Type 'a' + --------------------- + Google + --------------------- + +13. Make some quoted text from a URL + + Move cursor to the URL + --------------------- + http://github.com/ + --------------------- + Type 'A' + --------------------- +
    + Secure source code hosting and collaborative development - GitHub
    +

    How does it work? Get up and running in seconds by forking a project, pushing an existing repository...

    + http://github.com/ +
    + --------------------- + +14. Installing emmet.vim for the language you are using: + + # cd ~/.vim + # unzip emmet-vim.zip + + Or if you are using pathogen.vim: + + # cd ~/.vim/bundle # or make directory + # unzip /path/to/emmet-vim.zip + + Or if you get the sources from the repository: + + # cd ~/.vim/bundle # or make directory + # git clone http://github.com/mattn/emmet-vim.git + +15. Enable emmet.vim for the language you using. + + You can customize the behavior of the languages you are using. + + --------------------- + # cat >> ~/.vimrc + let g:user_emmet_settings = { + \ 'php' : { + \ 'extends' : 'html', + \ 'filters' : 'c', + \ }, + \ 'xml' : { + \ 'extends' : 'html', + \ }, + \ 'haml' : { + \ 'extends' : 'html', + \ }, + \} + --------------------- diff --git a/sources_forked/emmet-vim/autoload/emmet.vim b/sources_forked/emmet-vim/autoload/emmet.vim new file mode 100755 index 00000000..5939e684 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet.vim @@ -0,0 +1,1994 @@ +"============================================================================= +" emmet.vim +" Author: Yasuhiro Matsumoto +" Last Change: 26-Jul-2015. + +let s:save_cpo = &cpoptions +set cpoptions&vim + +let s:filtermx = '|\(\%(bem\|html\|haml\|slim\|e\|c\|s\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$' + +function! emmet#getExpandos(type, key) abort + let expandos = emmet#getResource(a:type, 'expandos', {}) + if has_key(expandos, a:key) + return expandos[a:key] + endif + return a:key +endfunction + +function! emmet#splitFilterArg(filters) abort + for f in a:filters + if f =~# '^/' + return f[1:] + endif + endfor + return '' +endfunction + +function! emmet#useFilter(filters, filter) abort + for f in a:filters + if a:filter ==# '/' && f =~# '^/' + return 1 + elseif f ==# a:filter + return 1 + endif + endfor + return 0 +endfunction + +function! emmet#getIndentation(...) abort + if a:0 > 0 + let type = a:1 + else + let type = emmet#getFileType() + endif + if has_key(s:emmet_settings, type) && has_key(s:emmet_settings[type], 'indentation') + let indent = s:emmet_settings[type].indentation + elseif has_key(s:emmet_settings, 'indentation') + let indent = s:emmet_settings.indentation + elseif has_key(s:emmet_settings.variables, 'indentation') + let indent = s:emmet_settings.variables.indentation + else + let sw = exists('*shiftwidth') ? shiftwidth() : &l:shiftwidth + let indent = (&l:expandtab || &l:tabstop !=# sw) ? repeat(' ', sw) : "\t" + endif + return indent +endfunction + +function! emmet#getBaseType(type) abort + if !has_key(s:emmet_settings, a:type) + return '' + endif + if !has_key(s:emmet_settings[a:type], 'extends') + return a:type + endif + let extends = s:emmet_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 emmet#getBaseType(ext) + endif + return '' +endfunction + +function! emmet#isExtends(type, extend) abort + if a:type ==# a:extend + return 1 + endif + if !has_key(s:emmet_settings, a:type) + return 0 + endif + if !has_key(s:emmet_settings[a:type], 'extends') + return 0 + endif + let extends = s:emmet_settings[a:type].extends + if type(extends) ==# 1 + let tmp = split(extends, '\s*,\s*') + unlet! extends + let extends = tmp + endif + for ext in extends + if a:extend ==# ext + return 1 + endif + endfor + return 0 +endfunction + +function! emmet#parseIntoTree(abbr, type) abort + let abbr = a:abbr + let type = a:type + let rtype = emmet#lang#exists(type) ? type : 'html' + return emmet#lang#{rtype}#parseIntoTree(abbr, type) +endfunction + +function! emmet#expandAbbrIntelligent(feedkey) abort + if !emmet#isExpandable() + return a:feedkey + endif + return "\(emmet-expand-abbr)" +endfunction + +function! emmet#isExpandable() abort + let line = getline('.') + if col('.') < len(line) + let line = matchstr(line, '^\(.*\%'.col('.').'c\)') + endif + let part = matchstr(line, '\(\S.*\)$') + let type = emmet#getFileType() + let ftype = emmet#lang#exists(type) ? type : 'html' + let part = emmet#lang#{ftype}#findTokens(part) + return len(part) > 0 +endfunction + +function! emmet#mergeConfig(lhs, rhs) abort + let [lhs, rhs] = [a:lhs, a:rhs] + if type(lhs) ==# 3 + if type(rhs) ==# 3 + let lhs += rhs + if len(lhs) + call remove(lhs, 0, len(lhs)-1) + endif + for rhi in rhs + call add(lhs, rhs[rhi]) + endfor + 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]) + else + let lhs[key] = rhs[key] + endif + else + let lhs[key] = rhs[key] + endif + endfor + endif + endif +endfunction + +function! emmet#newNode() abort + return { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'basevalue': 0, 'basedirect': 1, 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'], 'block': 0 } +endfunction + +function! s:itemno(itemno, current) abort + let current = a:current + if current.basedirect > 0 + if current.basevalue ==# 0 + return a:itemno + else + return current.basevalue - 1 + a:itemno + endif + else + if current.basevalue ==# 0 + return current.multiplier - 1 - a:itemno + else + return current.multiplier + current.basevalue - 2 - a:itemno + endif + endif +endfunction + +function! emmet#toString(...) abort + let current = a:1 + if a:0 > 1 + let type = a:2 + else + let type = &filetype + endif + if len(type) ==# 0 | let type = 'html' | endif + if a:0 > 2 + let inline = a:3 + else + let inline = 0 + endif + if a:0 > 3 + if type(a:4) ==# 1 + let filters = split(a:4, '\s*,\s*') + else + let filters = a:4 + endif + else + let filters = ['html'] + endif + if a:0 > 4 + let group_itemno = a:5 + else + let group_itemno = 0 + endif + if a:0 > 5 + let indent = a:6 + else + let indent = '' + endif + + let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) + let itemno = 0 + let str = '' + let rtype = emmet#lang#exists(type) ? type : 'html' + while itemno < current.multiplier + if len(current.name) + if current.multiplier ==# 1 + let inner = emmet#lang#{rtype}#toString(s:emmet_settings, current, type, inline, filters, s:itemno(group_itemno, current), indent) + else + let inner = emmet#lang#{rtype}#toString(s:emmet_settings, current, type, inline, filters, s:itemno(itemno, current), indent) + endif + if current.multiplier > 1 + let inner = substitute(inner, '\$#', '$line'.(itemno+1).'$', 'g') + endif + let str .= inner + else + let snippet = current.snippet + if len(snippet) ==# 0 + let snippets = emmet#getResource(type, 'snippets', {}) + if !empty(snippets) && has_key(snippets, 'emmet_snippet') + let snippet = snippets['emmet_snippet'] + endif + endif + if len(snippet) > 0 + let tmp = snippet + let tmp = substitute(tmp, '\${emmet_name}', current.name, 'g') + let snippet_node = emmet#newNode() + let snippet_node.value = '{'.tmp.'}' + let snippet_node.important = current.important + let snippet_node.multiplier = current.multiplier + let str .= emmet#lang#{rtype}#toString(s:emmet_settings, snippet_node, type, inline, filters, s:itemno(group_itemno, current), indent) + if current.multiplier > 1 + let str .= "\n" + endif + else + if len(current.name) + let str .= current.name + endif + if len(current.value) + let text = current.value[1:-2] + if dollar_expr + " TODO: regexp engine specified + if exists('®expengine') + let text = substitute(text, '\%#=1\%(\\\)\@\ 0 + let key = get(matcharr, 1) + if key !~# '^\d\+:' + let key = substitute(key, '\\{', '{', 'g') + let key = substitute(key, '\\}', '}', 'g') + let value = emmet#getDollarValueByKey(key) + if type(value) ==# type('') + let expr = get(matcharr, 0) + call add(dollar_list, {'expr': expr, 'value': value}) + endif + endif + else + break + endif + let expand = substitute(expand, dollar_reg, '', '') + endwhile + return dollar_list +endfunction + +function! emmet#getDollarValueByKey(key) abort + let ret = 0 + let key = a:key + let ftsetting = get(s:emmet_settings, emmet#getFileType()) + if type(ftsetting) ==# 4 && has_key(ftsetting, key) + let V = get(ftsetting, key) + if type(V) ==# 1 | return V | endif + endif + if type(ret) !=# 1 && has_key(s:emmet_settings.variables, key) + let V = get(s:emmet_settings.variables, key) + if type(V) ==# 1 | return V | endif + endif + if has_key(s:emmet_settings, 'custom_expands') && type(s:emmet_settings['custom_expands']) ==# 4 + for k in keys(s:emmet_settings['custom_expands']) + if key =~# k + let V = get(s:emmet_settings['custom_expands'], k) + if type(V) ==# 1 | return V | endif + if type(V) ==# 2 | return V(key) | endif + endif + endfor + endif + return ret +endfunction + +function! emmet#reExpandDollarExpr(expand, times) abort + let expand = a:expand + let dollar_exprs = emmet#getDollarExprs(expand) + if len(dollar_exprs) > 0 + if a:times < 9 + for n in range(len(dollar_exprs)) + let pair = get(dollar_exprs, n) + let pat = get(pair, 'expr') + let sub = get(pair, 'value') + let expand = substitute(expand, pat, sub, '') + endfor + return emmet#reExpandDollarExpr(expand, a:times + 1) + endif + endif + return expand +endfunction + +function! emmet#expandDollarExpr(expand) abort + return emmet#reExpandDollarExpr(a:expand, 0) +endfunction + +function! emmet#expandCursorExpr(expand, mode) abort + let expand = a:expand + if expand !~# '\${cursor}' + if a:mode ==# 2 + let expand = '${cursor}' . expand + else + let expand .= '${cursor}' + endif + endif + let expand = substitute(expand, '\${\d\+:\?\([^}]\+\)}', '$select$$cursor$\1$select$', 'g') + let expand = substitute(expand, '\${\d\+}', '$select$$cursor$$select$', 'g') + let expand = substitute(expand, '\${cursor}', '$cursor$', '') + let expand = substitute(expand, '\${cursor}', '', 'g') + let expand = substitute(expand, '\${cursor}', '', 'g') + return expand +endfunction + +function! emmet#unescapeDollarExpr(expand) abort + return substitute(a:expand, '\\\$', '$', 'g') +endfunction + +function! emmet#expandAbbr(mode, abbr) range abort + let type = emmet#getFileType() + let rtype = emmet#getFileType(1) + let indent = emmet#getIndentation(type) + let expand = '' + let line = '' + let part = '' + let rest = '' + + let filters = emmet#getFilters(type) + if len(filters) ==# 0 + let filters = ['html'] + endif + + if a:mode ==# 2 + let leader = substitute(input('Tag: ', ''), '^\s*\(.*\)\s*$', '\1', 'g') + if len(leader) ==# 0 + return '' + endif + if leader =~# s:filtermx + let filters = map(split(matchstr(leader, s:filtermx)[1:], '\s*[^\\]\zs,\s*'), 'substitute(v:val, "\\\\\\\\zs.\\\\ze", "&", "g")') + let leader = substitute(leader, s:filtermx, '', '') + endif + if leader =~# '\*' + let query = substitute(leader, '*', '*' . (a:lastline - a:firstline + 1), '') + if query !~# '}\s*$' && query !~# '\$#' + let query .= '>{$#}' + endif + if emmet#useFilter(filters, '/') + let spl = emmet#splitFilterArg(filters) + let fline = getline(a:firstline) + let query = substitute(query, '>\{0,1}{\$#}\s*$', '{\\$column\\$}*' . len(split(fline, spl)), '') + else + let spl = '' + endif + let items = emmet#parseIntoTree(query, type).child + let itemno = 0 + for item in items + 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') + let expand = substitute(expand, '<', '\<', 'g') + let expand = substitute(expand, '>', '\>', 'g') + endif + let line = getline(a:firstline) + let part = substitute(line, '^\s*', '', '') + for n in range(a:firstline, a:lastline) + let lline = getline(n) + let lpart = substitute(lline, '^\s\+', '', '') + if emmet#useFilter(filters, 't') + let lpart = substitute(lpart, '^[0-9.-]\+\s\+', '', '') + let lpart = substitute(lpart, '\s\+$', '', '') + endif + if emmet#useFilter(filters, '/') + for column in split(lpart, spl) + let expand = substitute(expand, '\$column\$', '\=column', '') + endfor + else + let expand = substitute(expand, '\$line'.(n-a:firstline+1).'\$', '\=lpart', 'g') + endif + endfor + let expand = substitute(expand, '\$line\d*\$', '', 'g') + let expand = substitute(expand, '\$column\$', '', 'g') + let content = join(getline(a:firstline, a:lastline), "\n") + if stridx(expand, '$#') < len(expand)-2 + let expand = substitute(expand, '^\(.*\)\$#\s*$', '\1', '') + endif + let expand = substitute(expand, '\$#', '\=content', 'g') + else + let str = '' + if visualmode() ==# 'V' + let line = getline(a:firstline) + let lspaces = matchstr(line, '^\s*', '', '') + let part = substitute(line, '^\s*', '', '') + for n in range(a:firstline, a:lastline) + if len(leader) > 0 + let line = getline(a:firstline) + let spaces = matchstr(line, '^\s*', '', '') + if len(spaces) >= len(lspaces) + let str .= indent . getline(n)[len(lspaces):] . "\n" + else + let str .= getline(n) . "\n" + endif + else + let lpart = substitute(getline(n), '^\s*', '', '') + let str .= lpart . "\n" + endif + endfor + if stridx(leader, '{$#}') ==# -1 + let leader .= '{$#}' + endif + let items = emmet#parseIntoTree(leader, type).child + else + let save_regcont = @" + let save_regtype = getregtype('"') + silent! normal! gvygv + let str = @" + call setreg('"', save_regcont, save_regtype) + if stridx(leader, '{$#}') ==# -1 + let leader .= '{$#}' + endif + let items = emmet#parseIntoTree(leader, type).child + endif + for item in items + let expand .= emmet#toString(item, rtype, 0, filters, 0, '') + endfor + if emmet#useFilter(filters, 'e') + let expand = substitute(expand, '&', '\&', 'g') + let expand = substitute(expand, '<', '\<', 'g') + let expand = substitute(expand, '>', '\>', 'g') + endif + if stridx(leader, '{$#}') !=# -1 + let expand = substitute(expand, '\$#', '\="\n" . str', 'g') + endif + endif + elseif a:mode ==# 4 + let line = getline('.') + let spaces = matchstr(line, '^\s*') + if line !~# '^\s*$' + put =spaces.a:abbr + else + call setline('.', spaces.a:abbr) + endif + normal! $ + call emmet#expandAbbr(0, '') + return '' + else + let line = getline('.') + if col('.') < len(line) + let line = matchstr(line, '^\(.*\%'.col('.').'c\)') + endif + if a:mode ==# 1 + let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$') + else + let part = matchstr(line, '\(\S.*\)$') + let ftype = emmet#lang#exists(type) ? type : 'html' + let part = emmet#lang#{ftype}#findTokens(part) + let line = line[0: strridx(line, part) + len(part) - 1] + endif + if col('.') ==# col('$') + let rest = '' + else + let rest = getline('.')[len(line):] + endif + let str = part + if str =~# s:filtermx + let filters = split(matchstr(str, s:filtermx)[1:], '\s*,\s*') + let str = substitute(str, s:filtermx, '', '') + endif + let items = emmet#parseIntoTree(str, rtype).child + for item in items + let expand .= emmet#toString(item, rtype, 0, filters, 0, indent) + endfor + if emmet#useFilter(filters, 'e') + let expand = substitute(expand, '&', '\&', 'g') + let expand = substitute(expand, '<', '\<', 'g') + let expand = substitute(expand, '>', '\>', 'g') + endif + let expand = substitute(expand, '\$line\([0-9]\+\)\$', '\=submatch(1)', 'g') + endif + let expand = emmet#expandDollarExpr(expand) + let expand = emmet#expandCursorExpr(expand, a:mode) + if len(expand) + if has_key(s:emmet_settings, 'timezone') && len(s:emmet_settings.timezone) + let expand = substitute(expand, '${datetime}', strftime('%Y-%m-%dT%H:%M:%S') . s:emmet_settings.timezone, 'g') + else + " TODO: on windows, %z/%Z is 'Tokyo(Standard)' + let expand = substitute(expand, '${datetime}', strftime('%Y-%m-%dT%H:%M:%S %z'), 'g') + endif + let expand = emmet#unescapeDollarExpr(expand) + if a:mode ==# 2 && visualmode() ==# 'v' + if a:firstline ==# a:lastline + let expand = substitute(expand, '[\r\n]\s*', '', 'g') + else + let expand = substitute(expand, '[\n]$', '', 'g') + endif + silent! normal! gv + let col = col('''<') + silent! normal! c + let line = getline('.') + let lhs = matchstr(line, '.*\%<'.col.'c.') + let rhs = matchstr(line, '\%>'.(col-1).'c.*') + let expand = lhs.expand.rhs + let lines = split(expand, '\n') + call setline(line('.'), lines[0]) + if len(lines) > 1 + call append(line('.'), lines[1:]) + endif + else + if line[:-len(part)-1] =~# '^\s\+$' + let indent = line[:-len(part)-1] + else + let indent = '' + endif + let expand = substitute(expand, '[\r\n]\s*$', '', 'g') + if emmet#useFilter(filters, 's') + let epart = substitute(expand, '[\r\n]\s*', '', 'g') + else + let epart = substitute(expand, '[\r\n]', "\n" . indent, 'g') + endif + let expand = line[:-len(part)-1] . epart . rest + let lines = split(expand, '[\r\n]', 1) + if a:mode ==# 2 + silent! exe 'normal! gvc' + endif + call setline('.', lines[0]) + if len(lines) > 1 + call append('.', lines[1:]) + endif + endif + endif + if g:emmet_debug > 1 + call getchar() + endif + if search('\ze\$\(cursor\|select\)\$', 'c') + let oldselection = &selection + let &selection = 'inclusive' + if foldclosed(line('.')) !=# -1 + silent! foldopen + endif + let pos = emmet#util#getcurpos() + let use_selection = emmet#getResource(type, 'use_selection', 0) + try + let l:gdefault = &gdefault + let &gdefault = 0 + if use_selection && getline('.')[col('.')-1:] =~# '^\$select' + let pos[2] += 1 + silent! s/\$select\$// + let next = searchpos('.\ze\$select\$', 'nW') + silent! %s/\$\(cursor\|select\)\$//g + call emmet#util#selectRegion([pos[1:2], next]) + return "\gv" + else + silent! %s/\$\(cursor\|select\)\$//g + silent! call setpos('.', pos) + if col('.') < col('$') + return "\" + endif + endif + finally + let &gdefault = l:gdefault + endtry + let &selection = oldselection + endif + return '' +endfunction + +function! emmet#updateTag() abort + let type = emmet#getFileType() + let region = emmet#util#searchRegion('<\S', '>') + if !emmet#util#regionIsValid(region) || !emmet#util#cursorInRegion(region) + return '' + endif + let content = emmet#util#getContent(region) + let content = matchstr(content, '^<[^><]\+>') + if content !~# '^<[^><]\+>$' + return '' + endif + let current = emmet#lang#html#parseTag(content) + if empty(current) + return '' + endif + + let str = substitute(input('Enter Abbreviation: ', ''), '^\s*\(.*\)\s*$', '\1', 'g') + let item = emmet#parseIntoTree(str, type).child[0] + for k in keys(item.attr) + let current.attr[k] = item.attr[k] + endfor + let html = substitute(emmet#toString(current, 'html', 1), '\n', '', '') + let html = substitute(html, '\${cursor}', '', '') + let html = matchstr(html, '^<[^><]\+>') + call emmet#util#setContent(region, html) + return '' +endfunction + +function! emmet#moveNextPrevItem(flag) abort + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + return emmet#lang#{rtype}#moveNextPrevItem(a:flag) +endfunction + +function! emmet#moveNextPrev(flag) abort + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + return emmet#lang#{rtype}#moveNextPrev(a:flag) +endfunction + +function! emmet#imageSize() abort + let orgpos = emmet#util#getcurpos() + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + call emmet#lang#{rtype}#imageSize() + silent! call setpos('.', orgpos) + return '' +endfunction + +function! emmet#encodeImage() abort + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + return emmet#lang#{rtype}#encodeImage() +endfunction + +function! emmet#toggleComment() abort + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + call emmet#lang#{rtype}#toggleComment() + return '' +endfunction + +function! emmet#balanceTag(flag) range abort + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + return emmet#lang#{rtype}#balanceTag(a:flag) +endfunction + +function! emmet#splitJoinTag() abort + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + return emmet#lang#{rtype}#splitJoinTag() +endfunction + +function! emmet#mergeLines() range abort + let lines = join(map(getline(a:firstline, a:lastline), 'matchstr(v:val, "^\\s*\\zs.*\\ze\\s*$")'), '') + let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '') + silent! exe 'normal! gvc' + call setline('.', indent . lines) +endfunction + +function! emmet#removeTag() abort + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + call emmet#lang#{rtype}#removeTag() + return '' +endfunction + +function! emmet#anchorizeURL(flag) abort + let mx = 'https\=:\/\/[-!#$%&*+,./:;=?@0-9a-zA-Z_~]\+' + let pos1 = searchpos(mx, 'bcnW') + let url = matchstr(getline(pos1[0])[pos1[1]-1:], mx) + let block = [pos1, [pos1[0], pos1[1] + len(url) - 1]] + if !emmet#util#cursorInRegion(block) + return '' + endif + + let mx = '.*]*>\s*\zs\([^<]\+\)\ze\s*<\/title[^>]*>.*' + let content = emmet#util#getContentFromURL(url) + let content = substitute(content, '\r', '', 'g') + let content = substitute(content, '[ \n]\+', ' ', 'g') + let content = substitute(content, '', '', 'g') + let title = matchstr(content, mx) + + let type = emmet#getFileType() + let rtype = emmet#lang#exists(type) ? type : 'html' + if &filetype ==# 'markdown' + let expand = printf('[%s](%s)', substitute(title, '[\[\]]', '\\&', 'g'), url) + elseif a:flag ==# 0 + let a = emmet#lang#html#parseTag('') + let a.attr.href = url + let a.value = '{' . title . '}' + let expand = emmet#toString(a, rtype, 0, []) + let expand = substitute(expand, '\${cursor}', '', 'g') + else + let body = emmet#util#getTextFromHTML(content) + let body = '{' . substitute(body, '^\(.\{0,100}\).*', '\1', '') . '...}' + + let blockquote = emmet#lang#html#parseTag('
    ') + let a = emmet#lang#html#parseTag('') + let a.attr.href = url + let a.value = '{' . title . '}' + call add(blockquote.child, a) + call add(blockquote.child, emmet#lang#html#parseTag('
    ')) + let p = emmet#lang#html#parseTag('

    ') + let p.value = body + call add(blockquote.child, p) + let cite = emmet#lang#html#parseTag('') + let cite.value = '{' . url . '}' + call add(blockquote.child, cite) + let expand = emmet#toString(blockquote, rtype, 0, []) + let expand = substitute(expand, '\${cursor}', '', 'g') + endif + let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '') + let expand = substitute(expand, "\n", "\n" . indent, 'g') + call emmet#util#setContent(block, expand) + return '' +endfunction + +function! emmet#codePretty() range abort + let type = input('FileType: ', &filetype, 'filetype') + if len(type) ==# 0 + return + endif + let block = emmet#util#getVisualBlock() + let content = emmet#util#getContent(block) + silent! 1new + let &l:filetype = type + call setline(1, split(content, "\n")) + let old_lazyredraw = &lazyredraw + set lazyredraw + silent! TOhtml + let &lazyredraw = old_lazyredraw + let content = join(getline(1, '$'), "\n") + silent! bw! + silent! bw! + let content = matchstr(content, ']*>[\s\n]*\zs.*\ze') + call emmet#util#setContent(block, content) +endfunction + +function! emmet#expandWord(abbr, type, orig) abort + let str = a:abbr + let type = a:type + let indent = emmet#getIndentation(type) + + if len(type) ==# 0 | let type = 'html' | endif + if str =~# s:filtermx + let filters = split(matchstr(str, s:filtermx)[1:], '\s*,\s*') + let str = substitute(str, s:filtermx, '', '') + else + let filters = emmet#getFilters(a:type) + if len(filters) ==# 0 + let filters = ['html'] + endif + endif + let str = substitute(str, '|', '${cursor}', 'g') + let items = emmet#parseIntoTree(str, a:type).child + let expand = '' + for item in items + let expand .= emmet#toString(item, a:type, 0, filters, 0, indent) + endfor + if emmet#useFilter(filters, 'e') + let expand = substitute(expand, '&', '\&', 'g') + let expand = substitute(expand, '<', '\<', 'g') + let expand = substitute(expand, '>', '\>', 'g') + endif + if emmet#useFilter(filters, 's') + let expand = substitute(expand, "\n\s\*", '', 'g') + endif + if a:orig ==# 0 + let expand = emmet#expandDollarExpr(expand) + let expand = substitute(expand, '\${cursor}', '', 'g') + endif + return expand +endfunction + +function! emmet#getSnippets(type) abort + let type = a:type + if len(type) ==# 0 || !has_key(s:emmet_settings, type) + let type = 'html' + endif + return emmet#getResource(type, 'snippets', {}) +endfunction + +function! emmet#completeTag(findstart, base) abort + if a:findstart + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~# '[a-zA-Z0-9:_\@\-]' + let start -= 1 + endwhile + return start + else + let type = emmet#getFileType() + let res = [] + + let snippets = emmet#getResource(type, 'snippets', {}) + for item in keys(snippets) + if stridx(item, a:base) !=# -1 + call add(res, substitute(item, '\${cursor}\||', '', 'g')) + endif + endfor + let aliases = emmet#getResource(type, 'aliases', {}) + for item in values(aliases) + if stridx(item, a:base) !=# -1 + call add(res, substitute(item, '\${cursor}\||', '', 'g')) + endif + endfor + return res + endif +endfunction + +unlet! s:emmet_settings +let s:emmet_settings = { +\ 'variables': { +\ 'lang': "en", +\ 'locale': "en-US", +\ 'charset': "UTF-8", +\ 'newline': "\n", +\ 'use_selection': 0, +\ }, +\ 'custom_expands' : { +\ '^\%(lorem\|lipsum\)\(\d*\)$' : function('emmet#lorem#en#expand'), +\ }, +\ 'css': { +\ 'snippets': { +\ "@i": "@import url(|);", +\ "@import": "@import url(|);", +\ "@m": "@media ${1:screen} {\n\t|\n}", +\ "@media": "@media ${1:screen} {\n\t|\n}", +\ "@f": "@font-face {\n\tfont-family:|;\n\tsrc:url(|);\n}", +\ "@f+": "@font-face {\n\tfont-family: '${1:FontName}';\n\tsrc: url('${2:FileName}.eot');\n\tsrc: url('${2:FileName}.eot?#iefix') format('embedded-opentype'),\n\t\t url('${2:FileName}.woff') format('woff'),\n\t\t url('${2:FileName}.ttf') format('truetype'),\n\t\t url('${2:FileName}.svg#${1:FontName}') format('svg');\n\tfont-style: ${3:normal};\n\tfont-weight: ${4:normal};\n}", +\ "@kf": "@-webkit-keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}\n@-o-keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}\n@-moz-keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}\n@keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}", +\ "anim": "animation:|;", +\ "anim-": "animation:${1:name} ${2:duration} ${3:timing-function} ${4:delay} ${5:iteration-count} ${6:direction} ${7:fill-mode};", +\ "animdel": "animation-delay:${1:time};", +\ "animdir": "animation-direction:${1:normal};", +\ "animdir:n": "animation-direction:normal;", +\ "animdir:r": "animation-direction:reverse;", +\ "animdir:a": "animation-direction:alternate;", +\ "animdir:ar": "animation-direction:alternate-reverse;", +\ "animdur": "animation-duration:${1:0}s;", +\ "animfm": "animation-fill-mode:${1:both};", +\ "animfm:f": "animation-fill-mode:forwards;", +\ "animfm:b": "animation-fill-mode:backwards;", +\ "animfm:bt": "animation-fill-mode:both;", +\ "animfm:bh": "animation-fill-mode:both;", +\ "animic": "animation-iteration-count:${1:1};", +\ "animic:i": "animation-iteration-count:infinite;", +\ "animn": "animation-name:${1:none};", +\ "animps": "animation-play-state:${1:running};", +\ "animps:p": "animation-play-state:paused;", +\ "animps:r": "animation-play-state:running;", +\ "animtf": "animation-timing-function:${1:linear};", +\ "animtf:e": "animation-timing-function:ease;", +\ "animtf:ei": "animation-timing-function:ease-in;", +\ "animtf:eo": "animation-timing-function:ease-out;", +\ "animtf:eio": "animation-timing-function:ease-in-out;", +\ "animtf:l": "animation-timing-function:linear;", +\ "animtf:cb": "animation-timing-function:cubic-bezier(${1:0.1}, ${2:0.7}, ${3:1.0}, ${3:0.1});", +\ "ap": "appearance:${none};", +\ "!": "!important", +\ "pos": "position:${1:relative};", +\ "pos:s": "position:static;", +\ "pos:a": "position:absolute;", +\ "pos:r": "position:relative;", +\ "pos:f": "position:fixed;", +\ "t": "top:|;", +\ "t:a": "top:auto;", +\ "r": "right:|;", +\ "r:a": "right:auto;", +\ "b": "bottom:|;", +\ "b:a": "bottom:auto;", +\ "l": "left:|;", +\ "l:a": "left:auto;", +\ "z": "z-index:|;", +\ "z:a": "z-index:auto;", +\ "fl": "float:${1:left};", +\ "fl:n": "float:none;", +\ "fl:l": "float:left;", +\ "fl:r": "float:right;", +\ "cl": "clear:${1:both};", +\ "cl:n": "clear:none;", +\ "cl:l": "clear:left;", +\ "cl:r": "clear:right;", +\ "cl:b": "clear:both;", +\ "colm": "columns:|;", +\ "colmc": "column-count:|;", +\ "colmf": "column-fill:|;", +\ "colmg": "column-gap:|;", +\ "colmr": "column-rule:|;", +\ "colmrc": "column-rule-color:|;", +\ "colmrs": "column-rule-style:|;", +\ "colmrw": "column-rule-width:|;", +\ "colms": "column-span:|;", +\ "colmw": "column-width:|;", +\ "d": "display:${1:block};", +\ "d:n": "display:none;", +\ "d:b": "display:block;", +\ "d:f": "display:flex;", +\ "d:i": "display:inline;", +\ "d:ib": "display:inline-block;", +\ "d:ib+": "display: inline-block;\n*display: inline;\n*zoom: 1;", +\ "d:li": "display:list-item;", +\ "d:ri": "display:run-in;", +\ "d:cp": "display:compact;", +\ "d:tb": "display:table;", +\ "d:itb": "display:inline-table;", +\ "d:tbcp": "display:table-caption;", +\ "d:tbcl": "display:table-column;", +\ "d:tbclg": "display:table-column-group;", +\ "d:tbhg": "display:table-header-group;", +\ "d:tbfg": "display:table-footer-group;", +\ "d:tbr": "display:table-row;", +\ "d:tbrg": "display:table-row-group;", +\ "d:tbc": "display:table-cell;", +\ "d:rb": "display:ruby;", +\ "d:rbb": "display:ruby-base;", +\ "d:rbbg": "display:ruby-base-group;", +\ "d:rbt": "display:ruby-text;", +\ "d:rbtg": "display:ruby-text-group;", +\ "v": "visibility:${1:hidden};", +\ "v:v": "visibility:visible;", +\ "v:h": "visibility:hidden;", +\ "v:c": "visibility:collapse;", +\ "ov": "overflow:${1:hidden};", +\ "ov:v": "overflow:visible;", +\ "ov:h": "overflow:hidden;", +\ "ov:s": "overflow:scroll;", +\ "ov:a": "overflow:auto;", +\ "ovx": "overflow-x:${1:hidden};", +\ "ovx:v": "overflow-x:visible;", +\ "ovx:h": "overflow-x:hidden;", +\ "ovx:s": "overflow-x:scroll;", +\ "ovx:a": "overflow-x:auto;", +\ "ovy": "overflow-y:${1:hidden};", +\ "ovy:v": "overflow-y:visible;", +\ "ovy:h": "overflow-y:hidden;", +\ "ovy:s": "overflow-y:scroll;", +\ "ovy:a": "overflow-y:auto;", +\ "ovs": "overflow-style:${1:scrollbar};", +\ "ovs:a": "overflow-style:auto;", +\ "ovs:s": "overflow-style:scrollbar;", +\ "ovs:p": "overflow-style:panner;", +\ "ovs:m": "overflow-style:move;", +\ "ovs:mq": "overflow-style:marquee;", +\ "zoo": "zoom:1;", +\ "zm": "zoom:1;", +\ "cp": "clip:|;", +\ "cp:a": "clip:auto;", +\ "cp:r": "clip:rect(${1:top} ${2:right} ${3:bottom} ${4:left});", +\ "bxz": "box-sizing:${1:border-box};", +\ "bxz:cb": "box-sizing:content-box;", +\ "bxz:bb": "box-sizing:border-box;", +\ "bxsh": "box-shadow:${1:inset }${2:hoff} ${3:voff} ${4:blur} ${5:color};", +\ "bxsh:r": "box-shadow:${1:inset }${2:hoff} ${3:voff} ${4:blur} ${5:spread }rgb(${6:0}, ${7:0}, ${8:0});", +\ "bxsh:ra": "box-shadow:${1:inset }${2:h} ${3:v} ${4:blur} ${5:spread }rgba(${6:0}, ${7:0}, ${8:0}, .${9:5});", +\ "bxsh:n": "box-shadow:none;", +\ "m": "margin:|;", +\ "m:a": "margin:auto;", +\ "mt": "margin-top:|;", +\ "mt:a": "margin-top:auto;", +\ "mr": "margin-right:|;", +\ "mr:a": "margin-right:auto;", +\ "mb": "margin-bottom:|;", +\ "mb:a": "margin-bottom:auto;", +\ "ml": "margin-left:|;", +\ "ml:a": "margin-left:auto;", +\ "p": "padding:|;", +\ "pt": "padding-top:|;", +\ "pr": "padding-right:|;", +\ "pb": "padding-bottom:|;", +\ "pl": "padding-left:|;", +\ "w": "width:|;", +\ "w:a": "width:auto;", +\ "h": "height:|;", +\ "h:a": "height:auto;", +\ "maw": "max-width:|;", +\ "maw:n": "max-width:none;", +\ "mah": "max-height:|;", +\ "mah:n": "max-height:none;", +\ "miw": "min-width:|;", +\ "mih": "min-height:|;", +\ "mar": "max-resolution:${1:res};", +\ "mir": "min-resolution:${1:res};", +\ "ori": "orientation:|;", +\ "ori:l": "orientation:landscape;", +\ "ori:p": "orientation:portrait;", +\ "ol": "outline:|;", +\ "ol:n": "outline:none;", +\ "olo": "outline-offset:|;", +\ "olw": "outline-width:|;", +\ "olw:tn": "outline-width:thin;", +\ "olw:m": "outline-width:medium;", +\ "olw:tc": "outline-width:thick;", +\ "ols": "outline-style:|;", +\ "ols:n": "outline-style:none;", +\ "ols:dt": "outline-style:dotted;", +\ "ols:ds": "outline-style:dashed;", +\ "ols:s": "outline-style:solid;", +\ "ols:db": "outline-style:double;", +\ "ols:g": "outline-style:groove;", +\ "ols:r": "outline-style:ridge;", +\ "ols:i": "outline-style:inset;", +\ "ols:o": "outline-style:outset;", +\ "olc": "outline-color:#${1:000};", +\ "olc:i": "outline-color:invert;", +\ "bfv": "backface-visibility:|;", +\ "bfv:h": "backface-visibility:hidden;", +\ "bfv:v": "backface-visibility:visible;", +\ "bd": "border:|;", +\ "bd+": "border:${1:1px} ${2:solid} ${3:#000};", +\ "bd:n": "border:none;", +\ "bdbk": "border-break:${1:close};", +\ "bdbk:c": "border-break:close;", +\ "bdcl": "border-collapse:|;", +\ "bdcl:c": "border-collapse:collapse;", +\ "bdcl:s": "border-collapse:separate;", +\ "bdc": "border-color:#${1:000};", +\ "bdc:t": "border-color:transparent;", +\ "bdi": "border-image:url(|);", +\ "bdi:n": "border-image:none;", +\ "bdti": "border-top-image:url(|);", +\ "bdti:n": "border-top-image:none;", +\ "bdri": "border-right-image:url(|);", +\ "bdri:n": "border-right-image:none;", +\ "bdbi": "border-bottom-image:url(|);", +\ "bdbi:n": "border-bottom-image:none;", +\ "bdli": "border-left-image:url(|);", +\ "bdli:n": "border-left-image:none;", +\ "bdci": "border-corner-image:url(|);", +\ "bdci:n": "border-corner-image:none;", +\ "bdci:c": "border-corner-image:continue;", +\ "bdtli": "border-top-left-image:url(|);", +\ "bdtli:n": "border-top-left-image:none;", +\ "bdtli:c": "border-top-left-image:continue;", +\ "bdtri": "border-top-right-image:url(|);", +\ "bdtri:n": "border-top-right-image:none;", +\ "bdtri:c": "border-top-right-image:continue;", +\ "bdbri": "border-bottom-right-image:url(|);", +\ "bdbri:n": "border-bottom-right-image:none;", +\ "bdbri:c": "border-bottom-right-image:continue;", +\ "bdbli": "border-bottom-left-image:url(|);", +\ "bdbli:n": "border-bottom-left-image:none;", +\ "bdbli:c": "border-bottom-left-image:continue;", +\ "bdf": "border-fit:${1:repeat};", +\ "bdf:c": "border-fit:clip;", +\ "bdf:r": "border-fit:repeat;", +\ "bdf:sc": "border-fit:scale;", +\ "bdf:st": "border-fit:stretch;", +\ "bdf:ow": "border-fit:overwrite;", +\ "bdf:of": "border-fit:overflow;", +\ "bdf:sp": "border-fit:space;", +\ "bdlen": "border-length:|;", +\ "bdlen:a": "border-length:auto;", +\ "bdsp": "border-spacing:|;", +\ "bds": "border-style:|;", +\ "bds:n": "border-style:none;", +\ "bds:h": "border-style:hidden;", +\ "bds:dt": "border-style:dotted;", +\ "bds:ds": "border-style:dashed;", +\ "bds:s": "border-style:solid;", +\ "bds:db": "border-style:double;", +\ "bds:dtds": "border-style:dot-dash;", +\ "bds:dtdtds": "border-style:dot-dot-dash;", +\ "bds:w": "border-style:wave;", +\ "bds:g": "border-style:groove;", +\ "bds:r": "border-style:ridge;", +\ "bds:i": "border-style:inset;", +\ "bds:o": "border-style:outset;", +\ "bdw": "border-width:|;", +\ "bdtw": "border-top-width:|;", +\ "bdrw": "border-right-width:|;", +\ "bdbw": "border-bottom-width:|;", +\ "bdlw": "border-left-width:|;", +\ "bdt": "border-top:|;", +\ "bt": "border-top:|;", +\ "bdt+": "border-top:${1:1px} ${2:solid} ${3:#000};", +\ "bdt:n": "border-top:none;", +\ "bdts": "border-top-style:|;", +\ "bdts:n": "border-top-style:none;", +\ "bdtc": "border-top-color:#${1:000};", +\ "bdtc:t": "border-top-color:transparent;", +\ "bdr": "border-right:|;", +\ "br": "border-right:|;", +\ "bdr+": "border-right:${1:1px} ${2:solid} ${3:#000};", +\ "bdr:n": "border-right:none;", +\ "bdrst": "border-right-style:|;", +\ "bdrst:n": "border-right-style:none;", +\ "bdrc": "border-right-color:#${1:000};", +\ "bdrc:t": "border-right-color:transparent;", +\ "bdb": "border-bottom:|;", +\ "bb": "border-bottom:|;", +\ "bdb+": "border-bottom:${1:1px} ${2:solid} ${3:#000};", +\ "bdb:n": "border-bottom:none;", +\ "bdbs": "border-bottom-style:|;", +\ "bdbs:n": "border-bottom-style:none;", +\ "bdbc": "border-bottom-color:#${1:000};", +\ "bdbc:t": "border-bottom-color:transparent;", +\ "bdl": "border-left:|;", +\ "bl": "border-left:|;", +\ "bdl+": "border-left:${1:1px} ${2:solid} ${3:#000};", +\ "bdl:n": "border-left:none;", +\ "bdls": "border-left-style:|;", +\ "bdls:n": "border-left-style:none;", +\ "bdlc": "border-left-color:#${1:000};", +\ "bdlc:t": "border-left-color:transparent;", +\ "bdrs": "border-radius:|;", +\ "bdtrrs": "border-top-right-radius:|;", +\ "bdtlrs": "border-top-left-radius:|;", +\ "bdbrrs": "border-bottom-right-radius:|;", +\ "bdblrs": "border-bottom-left-radius:|;", +\ "bg": "background:#${1:000};", +\ "bg+": "background:${1:#fff} url(${2}) ${3:0} ${4:0} ${5:no-repeat};", +\ "bg:n": "background:none;", +\ "bg:ie": "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1:x}.png',sizingMethod='${2:crop}');", +\ "bgc": "background-color:#${1:fff};", +\ "bgc:t": "background-color:transparent;", +\ "bgi": "background-image:url(|);", +\ "bgi:n": "background-image:none;", +\ "bgr": "background-repeat:|;", +\ "bgr:n": "background-repeat:no-repeat;", +\ "bgr:x": "background-repeat:repeat-x;", +\ "bgr:y": "background-repeat:repeat-y;", +\ "bgr:sp": "background-repeat:space;", +\ "bgr:rd": "background-repeat:round;", +\ "bga": "background-attachment:|;", +\ "bga:f": "background-attachment:fixed;", +\ "bga:s": "background-attachment:scroll;", +\ "bgp": "background-position:${1:0} ${2:0};", +\ "bgpx": "background-position-x:|;", +\ "bgpy": "background-position-y:|;", +\ "bgbk": "background-break:|;", +\ "bgbk:bb": "background-break:bounding-box;", +\ "bgbk:eb": "background-break:each-box;", +\ "bgbk:c": "background-break:continuous;", +\ "bgcp": "background-clip:${1:padding-box};", +\ "bgcp:bb": "background-clip:border-box;", +\ "bgcp:pb": "background-clip:padding-box;", +\ "bgcp:cb": "background-clip:content-box;", +\ "bgcp:nc": "background-clip:no-clip;", +\ "bgo": "background-origin:|;", +\ "bgo:pb": "background-origin:padding-box;", +\ "bgo:bb": "background-origin:border-box;", +\ "bgo:cb": "background-origin:content-box;", +\ "bgsz": "background-size:|;", +\ "bgsz:a": "background-size:auto;", +\ "bgsz:ct": "background-size:contain;", +\ "bgsz:cv": "background-size:cover;", +\ "c": "color:#${1:000};", +\ "c:r": "color:rgb(${1:0}, ${2:0}, ${3:0});", +\ "c:ra": "color:rgba(${1:0}, ${2:0}, ${3:0}, .${4:5});", +\ "cm": "/* |${child} */", +\ "cnt": "content:'|';", +\ "cnt:n": "content:normal;", +\ "cnt:oq": "content:open-quote;", +\ "cnt:noq": "content:no-open-quote;", +\ "cnt:cq": "content:close-quote;", +\ "cnt:ncq": "content:no-close-quote;", +\ "cnt:a": "content:attr(|);", +\ "cnt:c": "content:counter(|);", +\ "cnt:cs": "content:counters(|);", +\ "tbl": "table-layout:|;", +\ "tbl:a": "table-layout:auto;", +\ "tbl:f": "table-layout:fixed;", +\ "cps": "caption-side:|;", +\ "cps:t": "caption-side:top;", +\ "cps:b": "caption-side:bottom;", +\ "ec": "empty-cells:|;", +\ "ec:s": "empty-cells:show;", +\ "ec:h": "empty-cells:hide;", +\ "lis": "list-style:|;", +\ "lis:n": "list-style:none;", +\ "lisp": "list-style-position:|;", +\ "lisp:i": "list-style-position:inside;", +\ "lisp:o": "list-style-position:outside;", +\ "list": "list-style-type:|;", +\ "list:n": "list-style-type:none;", +\ "list:d": "list-style-type:disc;", +\ "list:c": "list-style-type:circle;", +\ "list:s": "list-style-type:square;", +\ "list:dc": "list-style-type:decimal;", +\ "list:dclz": "list-style-type:decimal-leading-zero;", +\ "list:lr": "list-style-type:lower-roman;", +\ "list:ur": "list-style-type:upper-roman;", +\ "lisi": "list-style-image:|;", +\ "lisi:n": "list-style-image:none;", +\ "q": "quotes:|;", +\ "q:n": "quotes:none;", +\ "q:ru": "quotes:'\\00AB' '\\00BB' '\\201E' '\\201C';", +\ "q:en": "quotes:'\\201C' '\\201D' '\\2018' '\\2019';", +\ "ct": "content:|;", +\ "ct:n": "content:normal;", +\ "ct:oq": "content:open-quote;", +\ "ct:noq": "content:no-open-quote;", +\ "ct:cq": "content:close-quote;", +\ "ct:ncq": "content:no-close-quote;", +\ "ct:a": "content:attr(|);", +\ "ct:c": "content:counter(|);", +\ "ct:cs": "content:counters(|);", +\ "coi": "counter-increment:|;", +\ "cor": "counter-reset:|;", +\ "va": "vertical-align:${1:top};", +\ "va:sup": "vertical-align:super;", +\ "va:t": "vertical-align:top;", +\ "va:tt": "vertical-align:text-top;", +\ "va:m": "vertical-align:middle;", +\ "va:bl": "vertical-align:baseline;", +\ "va:b": "vertical-align:bottom;", +\ "va:tb": "vertical-align:text-bottom;", +\ "va:sub": "vertical-align:sub;", +\ "ta": "text-align:${1:left};", +\ "ta:l": "text-align:left;", +\ "ta:c": "text-align:center;", +\ "ta:r": "text-align:right;", +\ "ta:j": "text-align:justify;", +\ "ta-lst": "text-align-last:|;", +\ "tal:a": "text-align-last:auto;", +\ "tal:l": "text-align-last:left;", +\ "tal:c": "text-align-last:center;", +\ "tal:r": "text-align-last:right;", +\ "td": "text-decoration:${1:none};", +\ "td:n": "text-decoration:none;", +\ "td:u": "text-decoration:underline;", +\ "td:o": "text-decoration:overline;", +\ "td:l": "text-decoration:line-through;", +\ "te": "text-emphasis:|;", +\ "te:n": "text-emphasis:none;", +\ "te:ac": "text-emphasis:accent;", +\ "te:dt": "text-emphasis:dot;", +\ "te:c": "text-emphasis:circle;", +\ "te:ds": "text-emphasis:disc;", +\ "te:b": "text-emphasis:before;", +\ "te:a": "text-emphasis:after;", +\ "th": "text-height:|;", +\ "th:a": "text-height:auto;", +\ "th:f": "text-height:font-size;", +\ "th:t": "text-height:text-size;", +\ "th:m": "text-height:max-size;", +\ "ti": "text-indent:|;", +\ "ti:-": "text-indent:-9999px;", +\ "tj": "text-justify:|;", +\ "tj:a": "text-justify:auto;", +\ "tj:iw": "text-justify:inter-word;", +\ "tj:ii": "text-justify:inter-ideograph;", +\ "tj:ic": "text-justify:inter-cluster;", +\ "tj:d": "text-justify:distribute;", +\ "tj:k": "text-justify:kashida;", +\ "tj:t": "text-justify:tibetan;", +\ "tov": "text-overflow:${ellipsis};", +\ "tov:e": "text-overflow:ellipsis;", +\ "tov:c": "text-overflow:clip;", +\ "to": "text-outline:|;", +\ "to+": "text-outline:${1:0} ${2:0} ${3:#000};", +\ "to:n": "text-outline:none;", +\ "tr": "text-replace:|;", +\ "tr:n": "text-replace:none;", +\ "tt": "text-transform:${1:uppercase};", +\ "tt:n": "text-transform:none;", +\ "tt:c": "text-transform:capitalize;", +\ "tt:u": "text-transform:uppercase;", +\ "tt:l": "text-transform:lowercase;", +\ "tw": "text-wrap:|;", +\ "tw:n": "text-wrap:normal;", +\ "tw:no": "text-wrap:none;", +\ "tw:u": "text-wrap:unrestricted;", +\ "tw:s": "text-wrap:suppress;", +\ "tsh": "text-shadow:${1:hoff} ${2:voff} ${3:blur} ${4:#000};", +\ "tsh:r": "text-shadow:${1:h} ${2:v} ${3:blur} rgb(${4:0}, ${5:0}, ${6:0});", +\ "tsh:ra": "text-shadow:${1:h} ${2:v} ${3:blur} rgba(${4:0}, ${5:0}, ${6:0}, .${7:5});", +\ "tsh+": "text-shadow:${1:0} ${2:0} ${3:0} ${4:#000};", +\ "tsh:n": "text-shadow:none;", +\ "trf": "transform:|;", +\ "trf:skx": "transform: skewX(${1:angle});", +\ "trf:sky": "transform: skewY(${1:angle});", +\ "trf:sc": "transform: scale(${1:x}, ${2:y});", +\ "trf:scx": "transform: scaleX(${1:x});", +\ "trf:scy": "transform: scaleY(${1:y});", +\ "trf:scz": "transform: scaleZ(${1:z});", +\ "trf:sc3": "transform: scale3d(${1:x}, ${2:y}, ${3:z});", +\ "trf:r": "transform: rotate(${1:angle});", +\ "trf:rx": "transform: rotateX(${1:angle});", +\ "trf:ry": "transform: rotateY(${1:angle});", +\ "trf:rz": "transform: rotateZ(${1:angle});", +\ "trf:t": "transform: translate(${1:x}, ${2:y});", +\ "trf:tx": "transform: translateX(${1:x});", +\ "trf:ty": "transform: translateY(${1:y});", +\ "trf:tz": "transform: translateZ(${1:z});", +\ "trf:t3": "transform: translate3d(${1:tx}, ${2:ty}, ${3:tz});", +\ "trfo": "transform-origin:|;", +\ "trfs": "transform-style:${1:preserve-3d};", +\ "trs": "transition:${1:prop} ${2:time};", +\ "trsde": "transition-delay:${1:time};", +\ "trsdu": "transition-duration:${1:time};", +\ "trsp": "transition-property:${1:prop};", +\ "trstf": "transition-timing-function:${1:tfunc};", +\ "lh": "line-height:|;", +\ "whs": "white-space:|;", +\ "whs:n": "white-space:normal;", +\ "whs:p": "white-space:pre;", +\ "whs:nw": "white-space:nowrap;", +\ "whs:pw": "white-space:pre-wrap;", +\ "whs:pl": "white-space:pre-line;", +\ "whsc": "white-space-collapse:|;", +\ "whsc:n": "white-space-collapse:normal;", +\ "whsc:k": "white-space-collapse:keep-all;", +\ "whsc:l": "white-space-collapse:loose;", +\ "whsc:bs": "white-space-collapse:break-strict;", +\ "whsc:ba": "white-space-collapse:break-all;", +\ "wob": "word-break:|;", +\ "wob:n": "word-break:normal;", +\ "wob:k": "word-break:keep-all;", +\ "wob:ba": "word-break:break-all;", +\ "wos": "word-spacing:|;", +\ "wow": "word-wrap:|;", +\ "wow:nm": "word-wrap:normal;", +\ "wow:n": "word-wrap:none;", +\ "wow:u": "word-wrap:unrestricted;", +\ "wow:s": "word-wrap:suppress;", +\ "wow:b": "word-wrap:break-word;", +\ "wm": "writing-mode:${1:lr-tb};", +\ "wm:lrt": "writing-mode:lr-tb;", +\ "wm:lrb": "writing-mode:lr-bt;", +\ "wm:rlt": "writing-mode:rl-tb;", +\ "wm:rlb": "writing-mode:rl-bt;", +\ "wm:tbr": "writing-mode:tb-rl;", +\ "wm:tbl": "writing-mode:tb-lr;", +\ "wm:btl": "writing-mode:bt-lr;", +\ "wm:btr": "writing-mode:bt-rl;", +\ "lts": "letter-spacing:|;", +\ "lts-n": "letter-spacing:normal;", +\ "f": "font:|;", +\ "f+": "font:${1:1em} ${2:Arial,sans-serif};", +\ "fw": "font-weight:|;", +\ "fw:n": "font-weight:normal;", +\ "fw:b": "font-weight:bold;", +\ "fw:br": "font-weight:bolder;", +\ "fw:lr": "font-weight:lighter;", +\ "fs": "font-style:${italic};", +\ "fs:n": "font-style:normal;", +\ "fs:i": "font-style:italic;", +\ "fs:o": "font-style:oblique;", +\ "fv": "font-variant:|;", +\ "fv:n": "font-variant:normal;", +\ "fv:sc": "font-variant:small-caps;", +\ "fz": "font-size:|;", +\ "fza": "font-size-adjust:|;", +\ "fza:n": "font-size-adjust:none;", +\ "ff": "font-family:|;", +\ "ff:s": "font-family:serif;", +\ "ff:ss": "font-family:sans-serif;", +\ "ff:c": "font-family:cursive;", +\ "ff:f": "font-family:fantasy;", +\ "ff:m": "font-family:monospace;", +\ "ff:a": "font-family: Arial, \"Helvetica Neue\", Helvetica, sans-serif;", +\ "ff:t": "font-family: \"Times New Roman\", Times, Baskerville, Georgia, serif;", +\ "ff:v": "font-family: Verdana, Geneva, sans-serif;", +\ "fef": "font-effect:|;", +\ "fef:n": "font-effect:none;", +\ "fef:eg": "font-effect:engrave;", +\ "fef:eb": "font-effect:emboss;", +\ "fef:o": "font-effect:outline;", +\ "fem": "font-emphasize:|;", +\ "femp": "font-emphasize-position:|;", +\ "femp:b": "font-emphasize-position:before;", +\ "femp:a": "font-emphasize-position:after;", +\ "fems": "font-emphasize-style:|;", +\ "fems:n": "font-emphasize-style:none;", +\ "fems:ac": "font-emphasize-style:accent;", +\ "fems:dt": "font-emphasize-style:dot;", +\ "fems:c": "font-emphasize-style:circle;", +\ "fems:ds": "font-emphasize-style:disc;", +\ "fsm": "font-smooth:|;", +\ "fsm:a": "font-smooth:auto;", +\ "fsm:n": "font-smooth:never;", +\ "fsm:aw": "font-smooth:always;", +\ "fst": "font-stretch:|;", +\ "fst:n": "font-stretch:normal;", +\ "fst:uc": "font-stretch:ultra-condensed;", +\ "fst:ec": "font-stretch:extra-condensed;", +\ "fst:c": "font-stretch:condensed;", +\ "fst:sc": "font-stretch:semi-condensed;", +\ "fst:se": "font-stretch:semi-expanded;", +\ "fst:e": "font-stretch:expanded;", +\ "fst:ee": "font-stretch:extra-expanded;", +\ "fst:ue": "font-stretch:ultra-expanded;", +\ "op": "opacity:|;", +\ "op+": "opacity: $1;\nfilter: alpha(opacity=$2);", +\ "op:ie": "filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);", +\ "op:ms": "-ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)';", +\ "rsz": "resize:|;", +\ "rsz:n": "resize:none;", +\ "rsz:b": "resize:both;", +\ "rsz:h": "resize:horizontal;", +\ "rsz:v": "resize:vertical;", +\ "cur": "cursor:${pointer};", +\ "cur:a": "cursor:auto;", +\ "cur:d": "cursor:default;", +\ "cur:c": "cursor:crosshair;", +\ "cur:ha": "cursor:hand;", +\ "cur:he": "cursor:help;", +\ "cur:m": "cursor:move;", +\ "cur:p": "cursor:pointer;", +\ "cur:t": "cursor:text;", +\ "pgbb": "page-break-before:|;", +\ "pgbb:au": "page-break-before:auto;", +\ "pgbb:al": "page-break-before:always;", +\ "pgbb:l": "page-break-before:left;", +\ "pgbb:r": "page-break-before:right;", +\ "pgbi": "page-break-inside:|;", +\ "pgbi:au": "page-break-inside:auto;", +\ "pgbi:av": "page-break-inside:avoid;", +\ "pgba": "page-break-after:|;", +\ "pgba:au": "page-break-after:auto;", +\ "pgba:al": "page-break-after:always;", +\ "pgba:l": "page-break-after:left;", +\ "pgba:r": "page-break-after:right;", +\ "orp": "orphans:|;", +\ "us": "user-select:${none};", +\ "wid": "widows:|;", +\ "wfsm": "-webkit-font-smoothing:${antialiased};", +\ "wfsm:a": "-webkit-font-smoothing:antialiased;", +\ "wfsm:s": "-webkit-font-smoothing:subpixel-antialiased;", +\ "wfsm:sa": "-webkit-font-smoothing:subpixel-antialiased;", +\ "wfsm:n": "-webkit-font-smoothing:none;" +\ }, +\ 'filters': 'fc', +\ }, +\ 'sass': { +\ 'extends': 'css', +\ 'snippets': { +\ '@if': "@if {\n\t|\n}", +\ '@e': "@else {\n\t|\n}", +\ '@in': "@include |", +\ '@ex': "@extend |", +\ '@mx': "@mixin {\n\t|\n}", +\ '@fn': "@function {\n\t|\n}", +\ '@r': "@return |", +\ }, +\ }, +\ 'scss': { +\ 'extends': 'css', +\ }, +\ 'less': { +\ 'extends': 'css', +\ }, +\ 'css.drupal': { +\ 'extends': 'css', +\ }, +\ 'html': { +\ 'snippets': { +\ '!': "html:5", +\ '!!!': "\n", +\ '!!!4t': "\n", +\ '!!!4s': "\n", +\ '!!!xt': "\n", +\ '!!!xs': "\n", +\ '!!!xxs': "\n", +\ 'c': "", +\ '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" +\ ."", +\ }, +\ '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}'}], +\ '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'}], +\ 'link:im': [{'rel': 'import'}, {'href': '|.html'}], +\ 'link:favicon': [{'rel': 'shortcut icon'}, {'type': 'image/x-icon'}, {'href': '|favicon.ico'}], +\ 'link:touch': [{'rel': 'apple-touch-icon'}, {'href': '|favicon.png'}], +\ 'link:rss': [{'rel': 'alternate'}, {'type': 'application/rss+xml'}, {'title': 'RSS'}, {'href': '|rss.xml'}], +\ 'link:atom': [{'rel': 'alternate'}, {'type': 'application/atom+xml'}, {'title': 'Atom'}, {'href': 'atom.xml'}], +\ 'meta:utf': [{'http-equiv': 'Content-Type'}, {'content': 'text/html;charset=UTF-8'}], +\ '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': [{'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': ''}], +\ 'object': [{'data': ''}, {'type': ''}], +\ 'param': [{'name': ''}, {'value': ''}], +\ 'map': {'name': ''}, +\ 'area': [{'shape': ''}, {'coords': ''}, {'href': ''}, {'alt': ''}], +\ 'area:d': [{'shape': 'default'}, {'href': ''}, {'alt': ''}], +\ 'area:c': [{'shape': 'circle'}, {'coords': ''}, {'href': ''}, {'alt': ''}], +\ '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': ''}], +\ 'input:hidden': [{'type': 'hidden'}, {'name': ''}], +\ 'input:h': [{'type': 'hidden'}, {'name': ''}], +\ 'input:text': [{'type': 'text'}, {'name': ''}, {'id': ''}], +\ 'input:t': [{'type': 'text'}, {'name': ''}, {'id': ''}], +\ 'input:search': [{'type': 'search'}, {'name': ''}, {'id': ''}], +\ 'input:email': [{'type': 'email'}, {'name': ''}, {'id': ''}], +\ 'input:url': [{'type': 'url'}, {'name': ''}, {'id': ''}], +\ 'input:password': [{'type': 'password'}, {'name': ''}, {'id': ''}], +\ 'input:p': [{'type': 'password'}, {'name': ''}, {'id': ''}], +\ 'input:datetime': [{'type': 'datetime'}, {'name': ''}, {'id': ''}], +\ 'input:date': [{'type': 'date'}, {'name': ''}, {'id': ''}], +\ 'input:datetime-local': [{'type': 'datetime-local'}, {'name': ''}, {'id': ''}], +\ 'input:month': [{'type': 'month'}, {'name': ''}, {'id': ''}], +\ 'input:week': [{'type': 'week'}, {'name': ''}, {'id': ''}], +\ 'input:time': [{'type': 'time'}, {'name': ''}, {'id': ''}], +\ 'input:number': [{'type': 'number'}, {'name': ''}, {'id': ''}], +\ 'input:color': [{'type': 'color'}, {'name': ''}, {'id': ''}], +\ 'input:checkbox': [{'type': 'checkbox'}, {'name': ''}, {'id': ''}], +\ 'input:c': [{'type': 'checkbox'}, {'name': ''}, {'id': ''}], +\ 'input:radio': [{'type': 'radio'}, {'name': ''}, {'id': ''}], +\ 'input:r': [{'type': 'radio'}, {'name': ''}, {'id': ''}], +\ 'input:range': [{'type': 'range'}, {'name': ''}, {'id': ''}], +\ 'input:file': [{'type': 'file'}, {'name': ''}, {'id': ''}], +\ 'input:f': [{'type': 'file'}, {'name': ''}, {'id': ''}], +\ 'input:submit': [{'type': 'submit'}, {'value': ''}], +\ 'input:s': [{'type': 'submit'}, {'value': ''}], +\ 'input:image': [{'type': 'image'}, {'src': ''}, {'alt': ''}], +\ 'input:i': [{'type': 'image'}, {'src': ''}, {'alt': ''}], +\ 'input:reset': [{'type': 'reset'}, {'value': ''}], +\ 'input:button': [{'type': 'button'}, {'value': ''}], +\ 'input:b': [{'type': 'button'}, {'value': ''}], +\ 'select': [{'name': ''}, {'id': ''}], +\ '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': ''}], +\ 'html:xml': [{'xmlns': 'http://www.w3.org/1999/xhtml'}, {'xml:lang': '${lang}'}], +\ }, +\ 'aliases': { +\ 'link:*': 'link', +\ 'meta:*': 'meta', +\ 'area:*': 'area', +\ 'bdo:*': 'bdo', +\ 'form:*': 'form', +\ 'input:*': 'input', +\ 'script:*': 'script', +\ 'html:*': 'html', +\ 'a:*': 'a', +\ 'menu:*': 'menu', +\ 'bq': 'blockquote', +\ 'acr': 'acronym', +\ 'fig': 'figure', +\ 'ifr': 'iframe', +\ 'emb': 'embed', +\ 'obj': 'object', +\ 'src': 'source', +\ 'cap': 'caption', +\ 'colg': 'colgroup', +\ 'fst': 'fieldset', +\ 'btn': 'button', +\ 'optg': 'optgroup', +\ 'opt': 'option', +\ 'tarea': 'textarea', +\ 'leg': 'legend', +\ 'sect': 'section', +\ 'art': 'article', +\ 'hdr': 'header', +\ 'ftr': 'footer', +\ 'adr': 'address', +\ 'dlg': 'dialog', +\ 'str': 'strong', +\ 'sty': 'style', +\ 'prog': 'progress', +\ 'fset': 'fieldset', +\ 'datag': 'datagrid', +\ 'datal': 'datalist', +\ 'kg': 'keygen', +\ 'out': 'output', +\ 'det': 'details', +\ 'cmd': 'command', +\ }, +\ 'expandos': { +\ 'ol': 'ol>li', +\ 'ul': 'ul>li', +\ 'dl': 'dl>dt+dd', +\ 'map': 'map>area', +\ 'table': 'table>tr>td', +\ 'colgroup': 'colgroup>col', +\ 'colg': 'colgroup>col', +\ 'tr': 'tr>td', +\ 'select': 'select>option', +\ 'optgroup': 'optgroup>option', +\ 'optg': 'optgroup>option', +\ }, +\ 'empty_elements': 'area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed,keygen,command', +\ 'block_elements': 'address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,link,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul,h1,h2,h3,h4,h5,h6', +\ '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,small,span,strike,strong,sub,sup,textarea,tt,u,var', +\ 'empty_element_suffix': g:emmet_html5 ? '>' : ' />', +\ 'indent_blockelement': 0, +\ }, +\ 'htmldjango': { +\ 'extends': 'html', +\ }, +\ 'html.django_template': { +\ 'extends': 'html', +\ }, +\ '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}|", +\ }, +\ }, +\ 'pug': { +\ 'extends': 'jade', +\ }, +\ 'xsl': { +\ 'extends': 'html', +\ 'default_attributes': { +\ 'tmatch': [{'match': ''}, {'mode': ''}], +\ 'tname': [{'name': ''}], +\ 'xsl:when': {'test': ''}, +\ 'var': [{'name': ''}, {'select': ''}], +\ 'vari': {'name': ''}, +\ 'if': {'test': ''}, +\ 'call': {'name': ''}, +\ 'attr': {'name': ''}, +\ 'wp': [{'name': ''}, {'select': ''}], +\ 'par': [{'name': ''}, {'select': ''}], +\ 'val': {'select': ''}, +\ 'co': {'select': ''}, +\ 'each': {'select': ''}, +\ 'ap': [{'select': ''}, {'mode': ''}] +\ }, +\ 'aliases': { +\ 'tmatch': 'xsl:template', +\ 'tname': 'xsl:template', +\ 'var': 'xsl:variable', +\ 'vari': 'xsl:variable', +\ 'if': 'xsl:if', +\ 'choose': 'xsl:choose', +\ 'call': 'xsl:call-template', +\ 'wp': 'xsl:with-param', +\ 'par': 'xsl:param', +\ 'val': 'xsl:value-of', +\ 'attr': 'xsl:attribute', +\ 'co' : 'xsl:copy-of', +\ 'each' : 'xsl:for-each', +\ 'ap' : 'xsl:apply-templates', +\ }, +\ 'expandos': { +\ 'choose': 'xsl:choose>xsl:when+xsl:otherwise', +\ } +\ }, +\ 'jsx': { +\ 'extends': 'html', +\ 'attribute_name': {'class': 'className', 'for': 'htmlFor'}, +\ }, +\ 'xslt': { +\ 'extends': 'xsl', +\ }, +\ '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", +\ }, +\ '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", +\ }, +\ }, +\ 'xhtml': { +\ 'extends': 'html' +\ }, +\ 'mustache': { +\ 'extends': 'html' +\ }, +\ 'xsd': { +\ 'extends': 'html', +\ 'snippets': { +\ 'xsd:w3c': "\n" +\ ."\n" +\ ."\t\n" +\ ."\n" +\ } +\ }, +\} + +if exists('g:user_emmet_settings') + call emmet#mergeConfig(s:emmet_settings, g:user_emmet_settings) +endif + +let &cpoptions = s:save_cpo +unlet s:save_cpo + +" vim:set et: diff --git a/sources_forked/emmet-vim/autoload/emmet/lang.vim b/sources_forked/emmet-vim/autoload/emmet/lang.vim new file mode 100755 index 00000000..c839fea4 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang.vim @@ -0,0 +1,11 @@ +let s:exists = {} +function! emmet#lang#exists(type) abort + if len(a:type) == 0 + return 0 + elseif has_key(s:exists, a:type) + return s:exists[a:type] + endif + let s:exists[a:type] = len(globpath(&rtp, 'autoload/emmet/lang/'.a:type.'.vim')) > 0 + return s:exists[a:type] +endfunction + diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/css.vim b/sources_forked/emmet-vim/autoload/emmet/lang/css.vim new file mode 100755 index 00000000..37961069 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/css.vim @@ -0,0 +1,350 @@ +function! emmet#lang#css#findTokens(str) abort + let tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '') + if tmp =~ '/' && tmp =~ '^[a-zA-Z0-9/_.]\+$' + " maybe path or something + return '' + endif + return substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '') +endfunction + +function! emmet#lang#css#parseIntoTree(abbr, type) abort + let abbr = a:abbr + let type = a:type + let prefix = 0 + let value = '' + + let indent = emmet#getIndentation(type) + let aliases = emmet#getResource(type, 'aliases', {}) + let snippets = emmet#getResource(type, 'snippets', {}) + let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1) + + let root = emmet#newNode() + + " emmet + let tokens = split(abbr, '+\ze[^+)!]') + let block = emmet#util#searchRegion('{', '}') + if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && block[0] ==# [0,0] && block[1] ==# [0,0] + let current = emmet#newNode() + let current.snippet = substitute(abbr, '\s\+$', '', '') . " {\n" . indent . "${cursor}\n}" + let current.name = '' + call add(root.child, deepcopy(current)) + else + for n in range(len(tokens)) + let token = tokens[n] + let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+\%(p\|e\|em\|re\|rem\|%\)\{0,1}-\{0,1}\|-auto\)*\)$') + if len(prop) + let token = substitute(prop[1], '^(\(.*\))', '\1', '') + if token =~# '^-' + let prefix = 1 + let token = token[1:] + endif + let value = '' + for v in split(prop[2], '\d\zs-') + if len(value) > 0 + let value .= ' ' + endif + if token =~# '^[z]' + " TODO + let value .= substitute(v, '[^0-9.]*$', '', '') + elseif v =~# 'p$' + let value .= substitute(v, 'p$', '%', '') + elseif v =~# '%$' + let value .= v + elseif v =~# 'e$' + let value .= substitute(v, 'e$', 'em', '') + elseif v =~# 'em$' + let value .= v + elseif v =~# 're$' + let value .= substitute(v, 're$', 'rem', '') + elseif v =~# 'rem$' + let value .= v + elseif v =~# '\.' + let value .= v . 'em' + elseif v ==# 'auto' + let value .= v + elseif v ==# '0' + let value .= '0' + else + let value .= v . 'px' + endif + endfor + endif + + let tag_name = token + if tag_name =~# '.!$' + let tag_name = tag_name[:-2] + let important = 1 + else + let important = 0 + endif + " make default node + let current = emmet#newNode() + let current.important = important + let current.name = tag_name + + " aliases + if has_key(aliases, tag_name) + let current.name = aliases[tag_name] + endif + + " snippets + if !empty(snippets) + let snippet_name = tag_name + if !has_key(snippets, snippet_name) + let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-\)') + let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') + if len(vv) > 0 + let snippet_name = vv[0] + else + let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-*\)') + let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') + if len(vv) == 0 + let pat = '^' . join(split(tag_name, '\zs'), '[^:]\{-}') + let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') + if len(vv) == 0 + let pat = '^' . join(split(tag_name, '\zs'), '.\{-}') + let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') + endif + endif + let minl = -1 + for vk in vv + let vvs = snippets[vk] + if minl == -1 || len(vvs) < minl + let snippet_name = vk + let minl = len(vvs) + endif + endfor + endif + endif + if has_key(snippets, snippet_name) + let snippet = snippets[snippet_name] + if use_pipe_for_cursor + let snippet = substitute(snippet, '|', '${cursor}', 'g') + endif + let lines = split(snippet, "\n") + call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")') + let current.snippet = join(lines, "\n") + let current.name = '' + let current.snippet = substitute(current.snippet, ';', value . ';', '') + if use_pipe_for_cursor && len(value) > 0 + let current.snippet = substitute(current.snippet, '\${cursor}', '', 'g') + endif + if n < len(tokens) - 1 + let current.snippet .= "\n" + endif + endif + endif + + let current.pos = 0 + let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$') + if len(lg) == 0 + let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*)$') + if len(lg) + let [lg[1], lg[2], lg[3]] = ['linear', lg[1], lg[2]] + endif + endif + if len(lg) + let current.name = '' + let current.snippet = printf("background-image:-webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3]) + call add(root.child, deepcopy(current)) + let current.snippet = printf("background-image:-webkit-linear-gradient(%s, %s);\n", lg[2], lg[3]) + call add(root.child, deepcopy(current)) + let current.snippet = printf("background-image:-moz-linear-gradient(%s, %s);\n", lg[2], lg[3]) + call add(root.child, deepcopy(current)) + let current.snippet = printf("background-image:-o-linear-gradient(%s, %s);\n", lg[2], lg[3]) + call add(root.child, deepcopy(current)) + let current.snippet = printf("background-image:linear-gradient(%s, %s);\n", lg[2], lg[3]) + call add(root.child, deepcopy(current)) + elseif prefix + let snippet = current.snippet + let current.snippet = '-webkit-' . snippet . "\n" + call add(root.child, deepcopy(current)) + let current.snippet = '-moz-' . snippet . "\n" + call add(root.child, deepcopy(current)) + let current.snippet = '-o-' . snippet . "\n" + call add(root.child, deepcopy(current)) + let current.snippet = '-ms-' . snippet . "\n" + call add(root.child, deepcopy(current)) + let current.snippet = snippet + call add(root.child, current) + elseif token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?' + let cs = split(token, '\.') + let current.name = '' + let [r,g,b] = [0,0,0] + if len(cs[0]) == 5 + let rgb = matchlist(cs[0], 'c#\(.\)\(.\)\(.\)') + let r = eval('0x'.rgb[1].rgb[1]) + let g = eval('0x'.rgb[2].rgb[2]) + let b = eval('0x'.rgb[3].rgb[3]) + elseif len(cs[0]) == 8 + let rgb = matchlist(cs[0], 'c#\(..\)\(..\)\(..\)') + let r = eval('0x'.rgb[1]) + let g = eval('0x'.rgb[2]) + let b = eval('0x'.rgb[3]) + endif + if len(cs) == 1 + let current.snippet = printf('color:rgb(%d, %d, %d);', r, g, b) + else + let current.snippet = printf('color:rgb(%d, %d, %d, %s);', r, g, b, string(str2float('0.'.cs[1]))) + endif + call add(root.child, current) + elseif token =~# '^c#' + let current.name = '' + let current.snippet = 'color:\${cursor};' + call add(root.child, current) + else + call add(root.child, current) + endif + endfor + endif + return root +endfunction + +function! emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) abort + let current = a:current + let value = current.value[1:-2] + let tmp = substitute(value, '\${cursor}', '', 'g') + if tmp !~ '.*{[ \t\r\n]*}$' + if emmet#useFilter(a:filters, 'fc') + let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g') + else + let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g') + endif + if current.important + let value = substitute(value, ';', ' !important;', '') + endif + endif + return value +endfunction + +function! emmet#lang#css#imageSize() abort + let img_region = emmet#util#searchRegion('{', '}') + if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region) + return + endif + let content = emmet#util#getContent(img_region) + let fn = matchstr(content, '\') + if len(node) + exe "normal ciw\='/* '.node.' */'\" + endif + endif + else + if line =~# mx + let space = substitute(matchstr(line, mx), mx, '\1', '') + let line = substitute(matchstr(line, mx), mx, '\2', '') + let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g') + else + let mx = '^\(\s*\)\(.*\)\s*$' + let line = substitute(line, mx, '\1/* \2 */', '') + endif + call setline('.', line) + endif +endfunction + +function! emmet#lang#css#balanceTag(flag) range abort + if a:flag == -2 || a:flag == 2 + let curpos = [0, line("'<"), col("'<"), 0] + else + let curpos = emmet#util#getcurpos() + endif + let block = emmet#util#getVisualBlock() + if !emmet#util#regionIsValid(block) + if a:flag > 0 + let block = emmet#util#searchRegion('^', ';') + if emmet#util#regionIsValid(block) + call emmet#util#selectRegion(block) + return + endif + endif + else + if a:flag > 0 + let content = emmet#util#getContent(block) + if content !~# '^{.*}$' + let block = emmet#util#searchRegion('{', '}') + if emmet#util#regionIsValid(block) + call emmet#util#selectRegion(block) + return + endif + endif + else + let pos = searchpos('.*;', 'nW') + if pos[0] != 0 + call setpos('.', [0, pos[0], pos[1], 0]) + let block = emmet#util#searchRegion('^', ';') + if emmet#util#regionIsValid(block) + call emmet#util#selectRegion(block) + return + endif + endif + endif + endif + if a:flag == -2 || a:flag == 2 + silent! exe 'normal! gv' + else + call setpos('.', curpos) + endif +endfunction + +function! emmet#lang#css#moveNextPrevItem(flag) abort + return emmet#lang#css#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#css#moveNextPrev(flag) abort + let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp') + if pos == 2 + startinsert! + else + silent! normal! l + startinsert + endif +endfunction + +function! emmet#lang#css#splitJoinTag() abort + " nothing to do +endfunction + +function! emmet#lang#css#removeTag() abort + " nothing to do +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/haml.vim b/sources_forked/emmet-vim/autoload/emmet/lang/haml.vim new file mode 100755 index 00000000..a3585c99 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/haml.vim @@ -0,0 +1,334 @@ +function! emmet#lang#haml#findTokens(str) abort + return emmet#lang#html#findTokens(a:str) +endfunction + +function! emmet#lang#haml#parseIntoTree(abbr, type) abort + return emmet#lang#html#parseIntoTree(a:abbr, a:type) +endfunction + +function! emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) abort + let settings = a:settings + let current = a:current + let type = a:type + let inline = a:inline + let filters = a:filters + let itemno = a:itemno + let indent = emmet#getIndentation(type) + let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) + let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash') + let str = '' + + let current_name = current.name + if dollar_expr + let current_name = substitute(current.name, '\$$', itemno+1, '') + endif + if len(current.name) > 0 + let str .= '%' . current_name + let tmp = '' + for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) + if !has_key(current.attr, attr) + continue + endif + let Val = current.attr[attr] + if type(Val) == 2 && Val == function('emmet#types#true') + if attribute_style ==# 'hash' + let tmp .= ' :' . attr . ' => true' + elseif attribute_style ==# 'html' + let tmp .= attr . '=true' + end + else + if dollar_expr + while Val =~# '\$\([^#{]\|$\)' + let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') + endwhile + let attr = substitute(attr, '\$$', itemno+1, '') + endif + let valtmp = substitute(Val, '\${cursor}', '', '') + if attr ==# 'id' && len(valtmp) > 0 + let str .= '#' . Val + elseif attr ==# 'class' && len(valtmp) > 0 + let str .= '.' . substitute(Val, ' ', '.', 'g') + else + if len(tmp) > 0 + if attribute_style ==# 'hash' + let tmp .= ',' + elseif attribute_style ==# 'html' + let tmp .= ' ' + endif + endif + if attribute_style ==# 'hash' + let tmp .= ' :' . attr . ' => "' . Val . '"' + elseif attribute_style ==# 'html' + let tmp .= attr . '="' . Val . '"' + end + endif + endif + endfor + if len(tmp) + if attribute_style ==# 'hash' + let str .= '{' . tmp . ' }' + elseif attribute_style ==# 'html' + let str .= '(' . tmp . ')' + end + endif + if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0 + let str .= '/' + endif + + let inner = '' + if len(current.value) > 0 + let text = current.value[1:-2] + if dollar_expr + let text = substitute(text, '\%(\\\)\@\ 0 + for child in current.child + let inner .= emmet#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') + let str .= "\n" . indent . inner + endif + else + let str = current.value[1:-2] + if dollar_expr + let str = substitute(str, '\%(\\\)\@\\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)' + while len(attrs) > 0 + let match = matchstr(attrs, mx) + if len(match) ==# 0 + break + endif + let attr_match = matchlist(match, mx) + let name = attr_match[1] + let value = len(attr_match[2]) ? attr_match[2] : attr_match[3] + let current.attr[name] = value + let current.attrs_order += [name] + let attrs = attrs[stridx(attrs, match) + len(match):] + endwhile + return current +endfunction + +function! emmet#lang#haml#toggleComment() abort + let line = getline('.') + let space = matchstr(line, '^\s*') + if line =~# '^\s*-#' + call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*')) + elseif line =~# '^\s*%[a-z]' + call setline('.', space . '-# ' . line[len(space):]) + endif +endfunction + +function! emmet#lang#haml#balanceTag(flag) range abort + let block = emmet#util#getVisualBlock() + if a:flag == -2 || a:flag == 2 + let curpos = [0, line("'<"), col("'<"), 0] + else + let curpos = emmet#util#getcurpos() + endif + let n = curpos[1] + let ml = len(matchstr(getline(n), '^\s*')) + + if a:flag > 0 + if a:flag == 1 || !emmet#util#regionIsValid(block) + let n = line('.') + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze%[a-z]')) + if l > 0 && l < ml + let ml = l + break + endif + let n -= 1 + endwhile + endif + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*%[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) + if l > 0 && l > ml + let ml = l + break + endif + let n += 1 + endwhile + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*%[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + endif +endfunction + +function! emmet#lang#haml#moveNextPrevItem(flag) abort + return emmet#lang#haml#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#haml#moveNextPrev(flag) abort + let pos = search('""', a:flag ? 'Wb' : 'W') + if pos != 0 + silent! normal! l + startinsert + endif +endfunction + +function! emmet#lang#haml#splitJoinTag() abort + let n = line('.') + let sml = len(matchstr(getline(n), '^\s*%[a-z]')) + while n > 0 + if getline(n) =~# '^\s*\ze%[a-z]' + if len(matchstr(getline(n), '^\s*%[a-z]')) < sml + break + endif + let line = getline(n) + call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', '')) + let sn = n + let n += 1 + let ml = len(matchstr(getline(n), '^\s*%[a-z]')) + if len(matchstr(getline(n), '^\s*')) > ml + while n <= line('$') + let l = len(matchstr(getline(n), '^\s*')) + if l <= ml + break + endif + exe n 'delete' + endwhile + call setpos('.', [0, sn, 1, 0]) + else + let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)') + let spaces = matchstr(getline(sn), '^\s*') + let settings = emmet#getSettings() + if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1 + call append(sn, spaces . ' ') + call setpos('.', [0, sn+1, 1, 0]) + else + call setpos('.', [0, sn, 1, 0]) + endif + startinsert! + endif + break + endif + let n -= 1 + endwhile +endfunction + +function! emmet#lang#haml#removeTag() abort + let n = line('.') + let ml = 0 + while n > 0 + if getline(n) =~# '^\s*\ze[a-z]' + let ml = len(matchstr(getline(n), '^\s*%[a-z]')) + break + endif + let n -= 1 + endwhile + let sn = n + while n < line('$') + let l = len(matchstr(getline(n), '^\s*%[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + if sn == n + exe 'delete' + else + exe sn ',' (n-1) 'delete' + endif +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/html.vim b/sources_forked/emmet-vim/autoload/emmet/lang/html.vim new file mode 100755 index 00000000..4ecb584e --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/html.vim @@ -0,0 +1,947 @@ +let s:bx = '{\%("[^"]*"\|''[^'']*''\|\$#\|\${\w\+}\|\$\+\|{[^{]\+\|[^{}]\)\{-}}' +let s:mx = '\([+>]\|[<^]\+\)\{-}\s*' +\ .'\((*\)\{-}\s*' +\ .'\([@#.]\{-}[a-zA-Z_\!][a-zA-Z0-9:_\!\-$]*\|' . s:bx . '\|\[[^\]]\+\]\)' +\ .'\(' +\ .'\%(' +\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)' +\ .'\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)' +\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)' +\ .'\)*' +\ .'\)' +\ .'\%(\(' . s:bx . '\+\)\)\{0,1}' +\ .'\%(\(@-\{0,1}[0-9]*\)\{0,1}\*\([0-9]\+\)\)\{0,1}' +\ .'\(\%()\%(\(@-\{0,1}[0-9]*\)\{0,1}\*[0-9]\+\)\{0,1}\)*\)' + +function! emmet#lang#html#findTokens(str) abort + let str = a:str + let [pos, last_pos] = [0, 0] + while 1 + let tag = matchstr(str, '<[a-zA-Z].\{-}>', pos) + if len(tag) == 0 + break + 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) + if token ==# '' + break + endif + if token =~# '^\s' + let token = matchstr(token, '^\s*\zs.*') + let last_pos = stridx(str, token, pos) + endif + let pos = stridx(str, token, pos) + len(token) + endwhile + let str = a:str[last_pos :-1] + if str =~# '^\w\+="[^"]*$' + return '' + endif + return str +endfunction + +function! emmet#lang#html#parseIntoTree(abbr, type) abort + let abbr = a:abbr + let type = a:type + + let settings = emmet#getSettings() + if !has_key(settings, type) + let type = 'html' + endif + if len(type) == 0 | let type = 'html' | endif + + let indent = emmet#getIndentation(type) + let pmap = { + \'p': 'span', + \'ul': 'li', + \'ol': 'li', + \'table': 'tr', + \'tr': 'td', + \'tbody': 'tr', + \'thead': 'tr', + \'tfoot': 'tr', + \'colgroup': 'col', + \'select': 'option', + \'optgroup': 'option', + \'audio': 'source', + \'video': 'source', + \'object': 'param', + \'map': 'area' + \} + + let inlineLevel = split('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,select,small,span,strike,strong,sub,sup,textarea,tt,u,var',',') + + let custom_expands = emmet#getResource(type, 'custom_expands', {}) + if empty(custom_expands) && has_key(settings, 'custom_expands') + let custom_expands = settings['custom_expands'] + endif + + " try 'foo' to (foo-x) + let rabbr = emmet#getExpandos(type, abbr) + if rabbr == abbr + " try 'foo+(' to (foo-x) + let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".emmet#getExpandos(type, submatch(1)).")".submatch(2)', 'i') + endif + let abbr = rabbr + + let root = emmet#newNode() + let parent = root + let last = root + let pos = [] + while len(abbr) + " parse line + let match = matchstr(abbr, s:mx) + let str = substitute(match, s:mx, '\0', 'ig') + let operator = substitute(match, s:mx, '\1', 'ig') + let block_start = substitute(match, s:mx, '\2', 'ig') + let tag_name = substitute(match, s:mx, '\3', 'ig') + let attributes = substitute(match, s:mx, '\4', 'ig') + let value = substitute(match, s:mx, '\5', 'ig') + let basevalue = substitute(match, s:mx, '\6', 'ig') + let multiplier = 0 + substitute(match, s:mx, '\7', 'ig') + let block_end = substitute(match, s:mx, '\8', 'ig') + let custom = '' + let important = 0 + if len(str) == 0 + break + endif + if tag_name =~# '^#' + let attributes = tag_name . attributes + let tag_name = '' + endif + if tag_name =~# '[^!]!$' + let tag_name = tag_name[:-2] + let important = 1 + endif + if tag_name =~# '^\.' + let attributes = tag_name . attributes + let tag_name = '' + endif + if tag_name =~# '^\[.*\]$' + let attributes = tag_name . attributes + let tag_name = '' + endif + + for k in keys(custom_expands) + if tag_name =~ k + let custom = tag_name + let tag_name = '' + break + endif + endfor + + if empty(tag_name) + let pname = len(parent.child) > 0 ? parent.child[0].name : '' + if !empty(pname) && has_key(pmap, pname) + let tag_name = pmap[pname] + elseif !empty(pname) && index(inlineLevel, pname) > -1 + let tag_name = 'span' + elseif len(parent.child) == 0 || len(custom) == 0 + let tag_name = 'div' + else + let tag_name = custom + endif + endif + + let basedirect = basevalue[1] ==# '-' ? -1 : 1 + let basevalue = 0 + abs(basevalue[1:]) + if multiplier <= 0 | let multiplier = 1 | endif + + " make default node + let current = emmet#newNode() + + let current.name = tag_name + let current.important = important + + " aliases + let aliases = emmet#getResource(type, 'aliases', {}) + if has_key(aliases, tag_name) + let current.name = aliases[tag_name] + endif + + 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] + endwhile + if use_pipe_for_cursor + let snippet = substitute(snippet, '|', '${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) + call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")') + let current.snippet = join(lines, "\n") + let current.name = '' + endif + endif + + for k in keys(custom_expands) + if tag_name =~# k + let current.snippet = '${' . (empty(custom) ? tag_name : custom) . '}' + let current.name = '' + break + elseif custom =~# k + let current.snippet = '${' . custom . '}' + let current.name = '' + break + endif + endfor + + " default_attributes + let default_attributes = emmet#getResource(type, 'default_attributes', {}) + if !empty(default_attributes) + for pat in [current.name, tag_name] + if has_key(default_attributes, pat) + if type(default_attributes[pat]) == 4 + let a = default_attributes[pat] + let current.attrs_order += keys(a) + if use_pipe_for_cursor + for k in keys(a) + let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}' + endfor + else + for k in keys(a) + let current.attr[k] = a[k] + endfor + endif + else + for a in default_attributes[pat] + let current.attrs_order += keys(a) + if use_pipe_for_cursor + for k in keys(a) + let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}' + endfor + else + for k in keys(a) + let current.attr[k] = a[k] + endfor + endif + endfor + endif + if has_key(settings.html.default_attributes, current.name) + let current.name = substitute(current.name, ':.*$', '', '') + endif + break + endif + endfor + endif + + " parse attributes + if len(attributes) + let attr = attributes + while len(attr) + let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)') + if g:emmet_debug > 1 + echomsg 'attr=' . item + endif + if len(item) == 0 + break + endif + if item[0] ==# '#' + let current.attr.id = item[1:] + endif + if item[0] ==# '.' + let current.attr.class = substitute(item[1:], '\.', ' ', 'g') + endif + if item[0] ==# '[' + let atts = item[1:-2] + if matchstr(atts, '^\s*\zs[0-9a-zA-Z_\-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') ==# '' + let ks = [] + if has_key(default_attributes, current.name) + let dfa = default_attributes[current.name] + let ks = type(dfa) == 3 ? keys(dfa[0]) : keys(dfa) + endif + if len(ks) == 0 && has_key(default_attributes, current.name . ':src') + let ks = keys(default_attributes[current.name . ':src']) + endif + if len(ks) > 0 + let current.attr[ks[0]] = atts + else + let current.attr[atts] = '' + endif + else + while len(atts) + let amat = matchstr(atts, '^\s*\zs\([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\|[^ ''"\]]*\)\{0,1}\)') + if len(amat) == 0 + break + endif + let key = split(amat, '=')[0] + let Val = amat[len(key)+1:] + if key =~# '\.$' && Val ==# '' + let key = key[:-2] + unlet Val + let Val = function('emmet#types#true') + elseif Val =~# '^["'']' + let Val = Val[1:-2] + endif + let current.attr[key] = Val + if index(current.attrs_order, key) == -1 + let current.attrs_order += [key] + endif + let atts = atts[stridx(atts, amat) + len(amat):] + unlet Val + endwhile + endif + endif + let attr = substitute(strpart(attr, len(item)), '^\s*', '', '') + endwhile + endif + + " parse text + if tag_name =~# '^{.*}$' + let current.name = '' + let current.value = tag_name + else + let current.value = value + endif + let current.basedirect = basedirect + let current.basevalue = basevalue + let current.multiplier = multiplier + + " parse step inside/outside + if !empty(last) + if operator =~# '>' + unlet! parent + let parent = last + let current.parent = last + let current.pos = last.pos + 1 + else + let current.parent = parent + let current.pos = last.pos + endif + else + let current.parent = parent + let current.pos = 1 + endif + if operator =~# '[<^]' + for c in range(len(operator)) + let tmp = parent.parent + if empty(tmp) + break + endif + let parent = tmp + let current.parent = tmp + endfor + endif + + call add(parent.child, current) + let last = current + + " parse block + if block_start =~# '(' + if operator =~# '>' + let last.pos += 1 + endif + let last.block = 1 + for n in range(len(block_start)) + let pos += [last.pos] + endfor + endif + if block_end =~# ')' + for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',') + if n ==# ')' + if len(pos) > 0 && last.pos >= pos[-1] + for c in range(last.pos - pos[-1]) + let tmp = parent.parent + if !has_key(tmp, 'parent') + break + endif + let parent = tmp + endfor + if len(pos) > 0 + call remove(pos, -1) + endif + let last = parent + let last.pos += 1 + endif + elseif len(n) + let st = 0 + for nc in range(len(last.child)) + if last.child[nc].block + let st = nc + break + endif + endfor + let cl = last.child[st :] + let cls = [] + for c in range(n[1:]) + for cc in cl + if cc.multiplier > 1 + let cc.basedirect = c + 1 + else + let cc.basevalue = c + 1 + endif + endfor + let cls += deepcopy(cl) + endfor + if st > 0 + let last.child = last.child[:st-1] + cls + else + let last.child = cls + endif + endif + endfor + endif + let abbr = abbr[stridx(abbr, match) + len(match):] + + if g:emmet_debug > 1 + echomsg 'str='.str + echomsg 'block_start='.block_start + echomsg 'tag_name='.tag_name + echomsg 'operator='.operator + echomsg 'attributes='.attributes + echomsg 'value='.value + echomsg 'basevalue='.basevalue + echomsg 'multiplier='.multiplier + echomsg 'block_end='.block_end + echomsg 'abbr='.abbr + echomsg 'pos='.string(pos) + echomsg '---' + endif + endwhile + return root +endfunction + +function! s:dollar_add(base,no) abort + if a:base > 0 + return a:base + a:no - 1 + elseif a:base < 0 + return a:base - a:no + 1 + else + return a:no + endif +endfunction + +function! emmet#lang#html#toString(settings, current, type, inline, filters, itemno, indent) abort + let settings = a:settings + let current = a:current + let type = a:type + let inline = a:inline + let filters = a:filters + let itemno = a:itemno + let indent = a:indent + let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) + let q = emmet#getResource(type, 'quote_char', '"') + let ct = emmet#getResource(type, 'comment_type', 'both') + let an = emmet#getResource(type, 'attribute_name', {}) + + if emmet#useFilter(filters, 'haml') + return emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) + endif + if emmet#useFilter(filters, 'slim') + return emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) + endif + + let comment = '' + let current_name = current.name + if dollar_expr + let current_name = substitute(current_name, '\$$', itemno+1, '') + endif + + let str = '' + if len(current_name) == 0 + let text = current.value[1:-2] + if dollar_expr + " TODO: regexp engine specified + let nr = itemno + 1 + if exists('®expengine') + let text = substitute(text, '\%#=1\%(\\\)\@\ 0 + let str .= '<' . current_name + endif + for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) + if !has_key(current.attr, attr) + continue + endif + let Val = current.attr[attr] + if type(Val) == 2 && Val == function('emmet#types#true') + unlet Val + let Val = 'true' + if g:emmet_html5 + let str .= ' ' . attr + else + let str .= ' ' . attr . '=' . q . attr . q + endif + if emmet#useFilter(filters, 'c') + if attr ==# 'id' | let comment .= '#' . Val | endif + if attr ==# 'class' | let comment .= '.' . Val | endif + endif + else + if dollar_expr + while Val =~# '\$\([^#{]\|$\)' + " TODO: regexp engine specified + if exists('®expengine') + let Val = substitute(Val, '\%#=1\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') + else + let Val = substitute(Val, '\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') + endif + endwhile + let attr = substitute(attr, '\$$', itemno+1, '') + endif + if attr ==# 'class' && emmet#useFilter(filters, 'bem') + let vals = split(Val, '\s\+') + let Val = '' + let lead = '' + for _val in vals + if len(Val) > 0 + let Val .= ' ' + endif + if _val =~# '^_' + if has_key(current.parent.attr, 'class') + let lead = current.parent.attr["class"] + if _val =~# '^__' + let Val .= lead . _val + else + let Val .= lead . ' ' . lead . _val + endif + else + let lead = split(vals[0], '_')[0] + let Val .= lead . _val + endif + elseif _val =~# '^-' + for l in split(_val, '_') + if len(Val) > 0 + let Val .= ' ' + endif + let l = substitute(l, '^-', '__', '') + if len(lead) == 0 + let pattr = current.parent.attr + if has_key(pattr, 'class') + let lead = split(pattr['class'], '\s\+')[0] + endif + endif + let Val .= lead . l + let lead .= l . '_' + endfor + else + let Val .= _val + endif + endfor + endif + if has_key(an, attr) + let attr = an[attr] + endif + if emmet#isExtends(type, 'jsx') && Val =~ '^{.*}$' + let str .= ' ' . attr . '=' . Val + else + let str .= ' ' . attr . '=' . q . Val . q + endif + if emmet#useFilter(filters, 'c') + if attr ==# 'id' | let comment .= '#' . Val | endif + if attr ==# 'class' | let comment .= '.' . Val | endif + endif + endif + unlet Val + endfor + if len(comment) > 0 && ct ==# 'both' + let str = '\n" . str + endif + if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 + let str .= settings.html.empty_element_suffix + else + let str .= '>' + let text = current.value[1:-2] + if dollar_expr + " TODO: regexp engine specified + let nr = itemno + 1 + if exists('®expengine') + let text = substitute(text, '\%#=1\%(\\\)\@\ 0 + for n in range(nc) + let child = current.child[n] + if child.multiplier > 1 + let str .= "\n" . indent + let dr = 1 + elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1 + if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1) + let str .= "\n" . indent + let dr = 1 + elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0 + let str .= "\n" . indent + let dr = 1 + endif + endif + let inner = emmet#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') + let str .= inner + endfor + else + if settings.html.indent_blockelement && len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1 + let str .= "\n" . indent . '${cursor}' . "\n" + else + let str .= '${cursor}' + endif + endif + if dr + let str .= "\n" + endif + let str .= '' + endif + if len(comment) > 0 + if ct ==# 'lastonly' + let str .= '' + else + let str .= "\n' + endif + endif + if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1 + let str .= "\n" + endif + return str +endfunction + +function! emmet#lang#html#imageSize() abort + let img_region = emmet#util#searchRegion('') + if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region) + return + endif + let content = emmet#util#getContent(img_region) + if content !~# '^<]\+>$' + return + endif + let current = emmet#lang#html#parseTag(content) + if empty(current) || !has_key(current.attr, 'src') + return + endif + let fn = current.attr.src + if fn =~# '^\s*$' + return + elseif fn !~# '^\(/\|http\)' + let fn = simplify(expand('%:h') . '/' . fn) + endif + + let [width, height] = emmet#util#getImageSize(fn) + if width == -1 && height == -1 + return + endif + let current.attr.width = width + let current.attr.height = height + let current.attrs_order += ['width', 'height'] + let html = substitute(emmet#toString(current, 'html', 1), '\n', '', '') + let html = substitute(html, '\${cursor}', '', '') + call emmet#util#setContent(img_region, html) +endfunction + +function! emmet#lang#html#encodeImage() abort + let img_region = emmet#util#searchRegion('') + if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region) + return + endif + let content = emmet#util#getContent(img_region) + if content !~# '^<]\+>$' + return + endif + let current = emmet#lang#html#parseTag(content) + if empty(current) || !has_key(current.attr, 'src') + return + endif + let fn = current.attr.src + if fn !~# '^\(/\|http\)' + let fn = simplify(expand('%:h') . '/' . fn) + endif + + let [width, height] = emmet#util#getImageSize(fn) + if width == -1 && height == -1 + return + endif + let current.attr.width = width + let current.attr.height = height + let html = emmet#toString(current, 'html', 1) + call emmet#util#setContent(img_region, html) +endfunction + +function! emmet#lang#html#parseTag(tag) abort + let current = emmet#newNode() + let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>' + let match = matchstr(a:tag, mx) + let current.name = substitute(match, mx, '\1', 'i') + let attrs = substitute(match, mx, '\2', 'i') + let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)' + while len(attrs) > 0 + let match = matchstr(attrs, mx) + if len(match) == 0 + break + endif + let attr_match = matchlist(match, mx) + let name = attr_match[1] + let value = len(attr_match[2]) ? attr_match[2] : attr_match[3] + let current.attr[name] = value + let current.attrs_order += [name] + let attrs = attrs[stridx(attrs, match) + len(match):] + endwhile + return current +endfunction + +function! emmet#lang#html#toggleComment() abort + let orgpos = getpos('.') + let curpos = getpos('.') + let mx = '<\%#[^>]*>' + while 1 + let block = emmet#util#searchRegion('') + if emmet#util#regionIsValid(block) + let block[1][1] += 2 + let content = emmet#util#getContent(block) + let content = substitute(content, '^$', '\1', '') + call emmet#util#setContent(block, content) + silent! call setpos('.', orgpos) + return + endif + let block = emmet#util#searchRegion('<[^>]', '>') + if !emmet#util#regionIsValid(block) + let pos1 = searchpos('<', 'bcW') + if pos1[0] == 0 && pos1[1] == 0 + return + endif + let curpos = getpos('.') + continue + endif + let pos1 = block[0] + let pos2 = block[1] + let content = emmet#util#getContent(block) + let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+') + if tag_name[0] ==# '/' + call setpos('.', [0, pos1[0], pos1[1], 0]) + let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^>]*>', '', '', 'bnW') + let pos1 = searchpos('>', 'cneW') + let block = [pos2, pos1] + elseif tag_name =~# '/$' + if !emmet#util#pointInRegion(orgpos[1:2], block) + " it's broken tree + call setpos('.', orgpos) + let block = emmet#util#searchRegion('>', '<') + let content = '><' + call emmet#util#setContent(block, content) + silent! call setpos('.', orgpos) + return + endif + else + call setpos('.', [0, pos2[0], pos2[1], 0]) + let pos3 = searchpairpos('<'. tag_name . '\>[^>]*>', '', '', 'nW') + if pos3 == [0, 0] + let block = [pos1, pos2] + else + call setpos('.', [0, pos3[0], pos3[1], 0]) + let pos2 = searchpos('>', 'neW') + let block = [pos1, pos2] + endif + endif + if !emmet#util#regionIsValid(block) + silent! call setpos('.', orgpos) + return + endif + if emmet#util#pointInRegion(curpos[1:2], block) + let content = '' + call emmet#util#setContent(block, content) + silent! call setpos('.', orgpos) + return + endif + endwhile +endfunction + +function! emmet#lang#html#balanceTag(flag) range abort + let vblock = emmet#util#getVisualBlock() + if a:flag == -2 || a:flag == 2 + let curpos = [0, line("'<"), col("'<"), 0] + else + let curpos = emmet#util#getcurpos() + endif + let settings = emmet#getSettings() + + if a:flag > 0 + let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*' + let last = curpos[1:2] + while 1 + let pos1 = searchpos(mx, 'bW') + let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) + let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze') + if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1 + let pos2 = searchpos('>', 'nW') + else + let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '', 'nW') + endif + let block = [pos1, pos2] + if pos1[0] == 0 && pos1[1] == 0 + break + endif + if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block) + call emmet#util#selectRegion(block) + return + endif + if pos1 == last + break + endif + let last = pos1 + endwhile + else + let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' + while 1 + let pos1 = searchpos(mx, 'W') + if pos1 == curpos[1:2] + let pos1 = searchpos(mx . '\zs', 'W') + let pos2 = searchpos('.\ze<', 'W') + let block = [pos1, pos2] + if emmet#util#regionIsValid(block) + call emmet#util#selectRegion(block) + return + endif + endif + let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) + let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze') + if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1 + let pos2 = searchpos('>', 'nW') + else + let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '', 'nW') + endif + let block = [pos1, pos2] + if pos1[0] == 0 && pos1[1] == 0 + break + endif + if emmet#util#regionIsValid(block) + call emmet#util#selectRegion(block) + return + endif + endwhile + endif + if a:flag == -2 || a:flag == 2 + silent! exe 'normal! gv' + else + call setpos('.', curpos) + endif +endfunction + +function! emmet#lang#html#moveNextPrevItem(flag) abort + silent! exe "normal \" + let mx = '\%([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|[^ ''">\]]*\)\{0,1}\)' + let pos = searchpos('\s'.mx.'\zs', '') + if pos != [0,0] + call feedkeys('v?\s\zs'.mx."\", '') + endif +endfunction + +function! emmet#lang#html#moveNextPrev(flag) abort + let pos = search('\%(<\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp') + if pos == 3 + startinsert! + elseif pos != 0 + silent! normal! l + startinsert + endif +endfunction + +function! emmet#lang#html#splitJoinTag() abort + let curpos = emmet#util#getcurpos() + while 1 + let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' + let pos1 = searchpos(mx, 'bcnW') + let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) + let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '') + let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]] + if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block) + let content = substitute(content[:-3], '\s*$', '', '') . '>' + call emmet#util#setContent(block, content) + call setpos('.', [0, block[0][0], block[0][1], 0]) + return + else + if tag_name[0] ==# '/' + let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW') + call setpos('.', [0, pos1[0], pos1[1], 0]) + let pos2 = searchpos('', 'cneW') + else + let pos2 = searchpos('', 'cneW') + endif + let block = [pos1, pos2] + let content = emmet#util#getContent(block) + if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>' + let content = matchstr(content, mx)[:-2] . ' />' + call emmet#util#setContent(block, content) + call setpos('.', [0, block[0][0], block[0][1], 0]) + return + else + if block[0][0] > 0 + call setpos('.', [0, block[0][0]-1, block[0][1], 0]) + else + call setpos('.', curpos) + return + endif + endif + endif + endwhile +endfunction + +function! emmet#lang#html#removeTag() abort + let curpos = emmet#util#getcurpos() + while 1 + let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*' + let pos1 = searchpos(mx, 'bcnW') + let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) + let tag_name = matchstr(content, '^<\zs/\{0,1}[a-zA-Z0-9:_\-]*') + let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]] + if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block) + call emmet#util#setContent(block, '') + call setpos('.', [0, block[0][0], block[0][1], 0]) + return + else + if tag_name[0] ==# '/' + let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW') + call setpos('.', [0, pos1[0], pos1[1], 0]) + let pos2 = searchpos('', 'cneW') + else + let pos2 = searchpos('', 'cneW') + endif + let block = [pos1, pos2] + let content = emmet#util#getContent(block) + if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '^<' . tag_name . '[^a-zA-Z0-9]' + call emmet#util#setContent(block, '') + call setpos('.', [0, block[0][0], block[0][1], 0]) + return + else + if block[0][0] > 0 + call setpos('.', [0, block[0][0]-1, block[0][1], 0]) + else + call setpos('.', curpos) + return + endif + endif + endif + endwhile +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/jade.vim b/sources_forked/emmet-vim/autoload/emmet/lang/jade.vim new file mode 100755 index 00000000..06454a09 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/jade.vim @@ -0,0 +1,331 @@ +function! emmet#lang#jade#findTokens(str) abort + return emmet#lang#html#findTokens(a:str) +endfunction + +function! emmet#lang#jade#parseIntoTree(abbr, type) abort + return emmet#lang#html#parseIntoTree(a:abbr, a:type) +endfunction + +function! emmet#lang#jade#toString(settings, current, type, inline, filters, itemno, indent) abort + let settings = a:settings + let current = a:current + let type = a:type + let inline = a:inline + let filters = a:filters + let itemno = a:itemno + let indent = emmet#getIndentation(type) + let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) + let attribute_style = emmet#getResource('jade', 'attribute_style', 'hash') + let str = '' + + let current_name = current.name + if dollar_expr + let current_name = substitute(current.name, '\$$', itemno+1, '') + endif + if len(current.name) > 0 + let str .= '' . current_name + let tmp = '' + for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) + if !has_key(current.attr, attr) + continue + endif + let Val = current.attr[attr] + if type(Val) == 2 && Val == function('emmet#types#true') + if attribute_style ==# 'hash' + let tmp .= ' ' . attr . ' = true' + elseif attribute_style ==# 'html' + let tmp .= attr . '=true' + end + else + if dollar_expr + while Val =~# '\$\([^#{]\|$\)' + let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') + endwhile + let attr = substitute(attr, '\$$', itemno+1, '') + endif + let valtmp = substitute(Val, '\${cursor}', '', '') + if attr ==# 'id' && len(valtmp) > 0 + let str .= '#' . Val + elseif attr ==# 'class' && len(valtmp) > 0 + let str .= '.' . substitute(Val, ' ', '.', 'g') + else + if len(tmp) > 0 + if attribute_style ==# 'hash' + let tmp .= ', ' + elseif attribute_style ==# 'html' + let tmp .= ' ' + endif + endif + if attribute_style ==# 'hash' + let tmp .= '' . attr . '="' . Val . '"' + elseif attribute_style ==# 'html' + let tmp .= attr . '="' . Val . '"' + end + endif + endif + endfor + if len(tmp) + if attribute_style ==# 'hash' + let str .= '(' . tmp . ')' + elseif attribute_style ==# 'html' + let str .= '(' . tmp . ')' + end + endif + + let inner = '' + if len(current.value) > 0 + let text = current.value[1:-2] + if dollar_expr + let text = substitute(text, '\%(\\\)\@\ 0 + for child in current.child + let inner .= emmet#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') + let str .= "\n" . indent . inner + endif + else + let str = current.value[1:-2] + if dollar_expr + let str = substitute(str, '\%(\\\)\@\\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)' + while len(attrs) > 0 + let match = matchstr(attrs, mx) + if len(match) ==# 0 + break + endif + let attr_match = matchlist(match, mx) + let name = attr_match[1] + let value = len(attr_match[2]) ? attr_match[2] : attr_match[3] + let current.attr[name] = value + let current.attrs_order += [name] + let attrs = attrs[stridx(attrs, match) + len(match):] + endwhile + return current +endfunction + +function! emmet#lang#jade#toggleComment() abort + let line = getline('.') + let space = matchstr(line, '^\s*') + if line =~# '^\s*-#' + call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*')) + elseif line =~# '^\s*%[a-z]' + call setline('.', space . '-# ' . line[len(space):]) + endif +endfunction + +function! emmet#lang#jade#balanceTag(flag) range abort + let block = emmet#util#getVisualBlock() + if a:flag == -2 || a:flag == 2 + let curpos = [0, line("'<"), col("'<"), 0] + else + let curpos = emmet#util#getcurpos() + endif + let n = curpos[1] + let ml = len(matchstr(getline(n), '^\s*')) + + if a:flag > 0 + if a:flag == 1 || !emmet#util#regionIsValid(block) + let n = line('.') + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze%[a-z]')) + if l > 0 && l < ml + let ml = l + break + endif + let n -= 1 + endwhile + endif + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*%[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) + if l > 0 && l > ml + let ml = l + break + endif + let n += 1 + endwhile + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*%[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + endif +endfunction + +function! emmet#lang#jade#moveNextPrevItem(flag) abort + return emmet#lang#jade#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#jade#moveNextPrev(flag) abort + let pos = search('""', a:flag ? 'Wb' : 'W') + if pos != 0 + silent! normal! l + startinsert + endif +endfunction + +function! emmet#lang#jade#splitJoinTag() abort + let n = line('.') + let sml = len(matchstr(getline(n), '^\s*%[a-z]')) + while n > 0 + if getline(n) =~# '^\s*\ze%[a-z]' + if len(matchstr(getline(n), '^\s*%[a-z]')) < sml + break + endif + let line = getline(n) + call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', '')) + let sn = n + let n += 1 + let ml = len(matchstr(getline(n), '^\s*%[a-z]')) + if len(matchstr(getline(n), '^\s*')) > ml + while n <= line('$') + let l = len(matchstr(getline(n), '^\s*')) + if l <= ml + break + endif + exe n 'delete' + endwhile + call setpos('.', [0, sn, 1, 0]) + else + let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)') + let spaces = matchstr(getline(sn), '^\s*') + let settings = emmet#getSettings() + if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1 + call append(sn, spaces . ' ') + call setpos('.', [0, sn+1, 1, 0]) + else + call setpos('.', [0, sn, 1, 0]) + endif + startinsert! + endif + break + endif + let n -= 1 + endwhile +endfunction + +function! emmet#lang#jade#removeTag() abort + let n = line('.') + let ml = 0 + while n > 0 + if getline(n) =~# '^\s*\ze[a-z]' + let ml = len(matchstr(getline(n), '^\s*%[a-z]')) + break + endif + let n -= 1 + endwhile + let sn = n + while n < line('$') + let l = len(matchstr(getline(n), '^\s*%[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + if sn == n + exe 'delete' + else + exe sn ',' (n-1) 'delete' + endif +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/less.vim b/sources_forked/emmet-vim/autoload/emmet/lang/less.vim new file mode 100755 index 00000000..25308a09 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/less.vim @@ -0,0 +1,47 @@ +function! emmet#lang#less#findTokens(str) abort + return emmet#lang#html#findTokens(a:str) +endfunction + +function! emmet#lang#less#parseIntoTree(abbr, type) abort + return emmet#lang#scss#parseIntoTree(a:abbr, a:type) +endfunction + +function! emmet#lang#less#toString(settings, current, type, inline, filters, itemno, indent) abort + return emmet#lang#scss#toString(a:settings, a:current, a:type, a:inline, a:filters, a:itemno, a:indent) +endfunction + +function! emmet#lang#less#imageSize() abort + call emmet#lang#css#imageSize() +endfunction + +function! emmet#lang#less#encodeImage() abort + return emmet#lang#css#encodeImage() +endfunction + +function! emmet#lang#less#parseTag(tag) abort + return emmet#lang#css#parseTag(a:tag) +endfunction + +function! emmet#lang#less#toggleComment() abort + call emmet#lang#css#toggleComment() +endfunction + +function! emmet#lang#less#balanceTag(flag) range abort + call emmet#lang#scss#balanceTag(a:flag) +endfunction + +function! emmet#lang#less#moveNextPrevItem(flag) abort + return emmet#lang#less#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#less#moveNextPrev(flag) abort + call emmet#lang#scss#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#less#splitJoinTag() abort + call emmet#lang#css#splitJoinTag() +endfunction + +function! emmet#lang#less#removeTag() abort + call emmet#lang#css#removeTag() +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/sass.vim b/sources_forked/emmet-vim/autoload/emmet/lang/sass.vim new file mode 100755 index 00000000..10531d19 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/sass.vim @@ -0,0 +1,160 @@ +function! emmet#lang#sass#findTokens(str) abort + return emmet#lang#css#findTokens(a:str) +endfunction + +function! emmet#lang#sass#parseIntoTree(abbr, type) abort + return emmet#lang#html#parseIntoTree(a:abbr, a:type) +endfunction + +function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort + let settings = a:settings + let current = a:current + let type = a:type + let inline = a:inline + let filters = a:filters + let itemno = a:itemno + let indent = a:indent + let str = '' + + let current_name = current.name + let current_name = substitute(current.name, '\$$', itemno+1, '') + if len(current.name) > 0 + let str .= current_name + let tmp = '' + for attr in keys(current.attr) + let val = current.attr[attr] + while val =~# '\$\([^#{]\|$\)' + let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') + endwhile + let attr = substitute(attr, '\$$', itemno+1, '') + if attr ==# 'id' + let str .= '#' . val + elseif attr ==# 'class' + let str .= '.' . val + else + let tmp .= attr . ': ' . val + endif + endfor + if len(tmp) > 0 + let str .= "\n" + for line in split(tmp, "\n") + let str .= indent . line . "\n" + endfor + else + let str .= "\n" + endif + + let inner = '' + for child in current.child + let tmp = emmet#toString(child, type, inline, filters, itemno, indent) + let tmp = substitute(tmp, "\n", "\n" . escape(indent, '\'), 'g') + let tmp = substitute(tmp, "\n" . escape(indent, '\') . '$', '${cursor}\n', 'g') + let inner .= tmp + endfor + if len(inner) > 0 + let str .= indent . inner + endif + else + let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) + let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g') + return text + endif + return str +endfunction + +function! emmet#lang#sass#imageSize() abort +endfunction + +function! emmet#lang#sass#encodeImage() abort +endfunction + +function! emmet#lang#sass#parseTag(tag) abort +endfunction + +function! emmet#lang#sass#toggleComment() abort +endfunction + +function! emmet#lang#sass#balanceTag(flag) range abort + let block = emmet#util#getVisualBlock() + if a:flag == -2 || a:flag == 2 + let curpos = [0, line("'<"), col("'<"), 0] + else + let curpos = emmet#util#getcurpos() + endif + let n = curpos[1] + let ml = len(matchstr(getline(n), '^\s*')) + + if a:flag > 0 + if a:flag == 1 || !emmet#util#regionIsValid(block) + let n = line('.') + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) + if l > 0 && l < ml + let ml = l + break + endif + let n -= 1 + endwhile + endif + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) + if l > 0 && l > ml + let ml = l + break + endif + let n += 1 + endwhile + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + endif +endfunction + +function! emmet#lang#sass#moveNextPrevItem(flag) abort + return emmet#lang#sass#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#sass#moveNextPrev(flag) abort + let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp') + if pos == 2 + startinsert! + elseif pos != 0 + silent! normal! l + startinsert + endif +endfunction + +function! emmet#lang#sass#splitJoinTag() abort +endfunction + +function! emmet#lang#sass#removeTag() abort +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/scss.vim b/sources_forked/emmet-vim/autoload/emmet/lang/scss.vim new file mode 100755 index 00000000..12a8aeb1 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/scss.vim @@ -0,0 +1,125 @@ +function! emmet#lang#scss#findTokens(str) abort + return emmet#lang#css#findTokens(a:str) +endfunction + +function! emmet#lang#scss#parseIntoTree(abbr, type) abort + if a:abbr =~# '>' + return emmet#lang#html#parseIntoTree(a:abbr, a:type) + else + return emmet#lang#css#parseIntoTree(a:abbr, a:type) + endif +endfunction + +function! emmet#lang#scss#toString(settings, current, type, inline, filters, itemno, indent) abort + let settings = a:settings + let current = a:current + let type = a:type + let inline = a:inline + let filters = a:filters + let itemno = a:itemno + let indent = a:indent + let str = '' + + let current_name = substitute(current.name, '\$$', itemno+1, '') + if len(current.name) > 0 + let str .= current_name + let tmp = '' + for attr in keys(current.attr) + let val = current.attr[attr] + while val =~# '\$\([^#{]\|$\)' + let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') + endwhile + let attr = substitute(attr, '\$$', itemno+1, '') + if attr ==# 'id' + let str .= '#' . val + elseif attr ==# 'class' + let str .= '.' . val + else + let tmp .= attr . ': ' . val . ';' + endif + endfor + if len(tmp) > 0 + let str .= " {\n" + for line in split(tmp, "\n") + let str .= indent . line . "\n" + endfor + else + let str .= " {\n" + endif + + let inner = '' + for child in current.child + let inner .= emmet#toString(child, type, inline, filters, itemno) + endfor + let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') + let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') + let str .= indent . inner . "${cursor}\n}\n" + else + return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) + endif + return str +endfunction + +function! emmet#lang#scss#imageSize() abort + call emmet#lang#css#imageSize() +endfunction + +function! emmet#lang#scss#encodeImage() abort + return emmet#lang#css#encodeImage() +endfunction + +function! emmet#lang#scss#parseTag(tag) abort + return emmet#lang#css#parseTag(a:tag) +endfunction + +function! emmet#lang#scss#toggleComment() abort + call emmet#lang#css#toggleComment() +endfunction + +function! emmet#lang#scss#balanceTag(flag) range abort + if a:flag == -2 || a:flag == 2 + let curpos = [0, line("'<"), col("'<"), 0] + call setpos('.', curpos) + else + let curpos = emmet#util#getcurpos() + endif + if a:flag < 0 + let ret = searchpair('}', '', '.\zs{') + else + let ret = searchpair('{', '', '}', 'bW') + endif + if ret > 0 + let pos1 = emmet#util#getcurpos()[1:2] + if a:flag < 0 + let pos2 = searchpairpos('{', '', '}') + else + let pos2 = searchpairpos('{', '', '}') + endif + let block = [pos1, pos2] + if emmet#util#regionIsValid(block) + call emmet#util#selectRegion(block) + return + endif + endif + if a:flag == -2 || a:flag == 2 + silent! exe 'normal! gv' + else + call setpos('.', curpos) + endif +endfunction + +function! emmet#lang#scss#moveNextPrevItem(flag) abort + return emmet#lang#scss#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#scss#moveNextPrev(flag) abort + call emmet#lang#css#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#scss#splitJoinTag() abort + call emmet#lang#css#splitJoinTag() +endfunction + +function! emmet#lang#scss#removeTag() abort + call emmet#lang#css#removeTag() +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lang/slim.vim b/sources_forked/emmet-vim/autoload/emmet/lang/slim.vim new file mode 100755 index 00000000..d57bf1fc --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lang/slim.vim @@ -0,0 +1,281 @@ +function! emmet#lang#slim#findTokens(str) abort + return emmet#lang#html#findTokens(a:str) +endfunction + +function! emmet#lang#slim#parseIntoTree(abbr, type) abort + return emmet#lang#html#parseIntoTree(a:abbr, a:type) +endfunction + +function! emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) abort + let current = a:current + let type = a:type + let inline = a:inline + let filters = a:filters + let itemno = a:itemno + let indent = emmet#getIndentation(type) + let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) + let str = '' + + let current_name = current.name + if dollar_expr + let current_name = substitute(current.name, '\$$', itemno+1, '') + endif + if len(current.name) > 0 + let str .= current_name + for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) + if !has_key(current.attr, attr) + continue + endif + let Val = current.attr[attr] + if type(Val) == 2 && Val == function('emmet#types#true') + let str .= ' ' . attr . '=true' + else + if dollar_expr + while Val =~# '\$\([^#{]\|$\)' + let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') + endwhile + endif + let attr = substitute(attr, '\$$', itemno+1, '') + let str .= ' ' . attr . '="' . Val . '"' + endif + endfor + + let inner = '' + if len(current.value) > 0 + let str .= "\n" + let text = current.value[1:-2] + if dollar_expr + let text = substitute(text, '\%(\\\)\@\ 0 + for child in current.child + let inner .= emmet#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') + let str .= "\n" . indent . inner + endif + else + let str = current.value[1:-2] + if dollar_expr + let str = substitute(str, '\%(\\\)\@\ 0 + let match = matchstr(attrs, mx) + if len(match) == 0 + break + endif + let attr_match = matchlist(match, mx) + let name = attr_match[1] + let value = len(attr_match[2]) ? attr_match[2] : attr_match[3] + let current.attr[name] = value + let current.attrs_order += [name] + let attrs = attrs[stridx(attrs, match) + len(match):] + endwhile + return current +endfunction + +function! emmet#lang#slim#toggleComment() abort + let line = getline('.') + let space = matchstr(line, '^\s*') + if line =~# '^\s*/' + call setline('.', space . line[len(space)+1:]) + elseif line =~# '^\s*[a-z]' + call setline('.', space . '/' . line[len(space):]) + endif +endfunction + +function! emmet#lang#slim#balanceTag(flag) range abort + let block = emmet#util#getVisualBlock() + if a:flag == -2 || a:flag == 2 + let curpos = [0, line("'<"), col("'<"), 0] + else + let curpos = emmet#util#getcurpos() + endif + let n = curpos[1] + let ml = len(matchstr(getline(n), '^\s*')) + + if a:flag > 0 + if a:flag == 1 || !emmet#util#regionIsValid(block) + let n = line('.') + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) + if l > 0 && l < ml + let ml = l + break + endif + let n -= 1 + endwhile + endif + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + else + while n > 0 + let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) + if l > 0 && l > ml + let ml = l + break + endif + let n += 1 + endwhile + let sn = n + if n == 0 + let ml = 0 + endif + while n < line('$') + let l = len(matchstr(getline(n), '^\s*[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + call setpos('.', [0, n, 1, 0]) + normal! V + call setpos('.', [0, sn, 1, 0]) + endif +endfunction + +function! emmet#lang#slim#moveNextPrevItem(flag) abort + return emmet#lang#slim#moveNextPrev(a:flag) +endfunction + +function! emmet#lang#slim#moveNextPrev(flag) abort + let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp') + if pos == 2 + startinsert! + elseif pos != 0 + silent! normal! l + startinsert + endif +endfunction + +function! emmet#lang#slim#splitJoinTag() abort + let n = line('.') + while n > 0 + if getline(n) =~# '^\s*\ze[a-z]' + let sn = n + let n += 1 + if getline(n) =~# '^\s*|' + while n <= line('$') + if getline(n) !~# '^\s*|' + break + endif + exe n 'delete' + endwhile + call setpos('.', [0, sn, 1, 0]) + else + let spaces = matchstr(getline(sn), '^\s*') + call append(sn, spaces . ' | ') + call setpos('.', [0, sn+1, 1, 0]) + startinsert! + endif + break + endif + let n -= 1 + endwhile +endfunction + +function! emmet#lang#slim#removeTag() abort + let n = line('.') + let ml = 0 + while n > 0 + if getline(n) =~# '^\s*\ze[a-z]' + let ml = len(matchstr(getline(n), '^\s*[a-z]')) + break + endif + let n -= 1 + endwhile + let sn = n + while n < line('$') + let l = len(matchstr(getline(n), '^\s*[a-z]')) + if l > 0 && l <= ml + let n -= 1 + break + endif + let n += 1 + endwhile + if sn == n + exe 'delete' + else + exe sn ',' (n-1) 'delete' + endif +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lorem/en.vim b/sources_forked/emmet-vim/autoload/emmet/lorem/en.vim new file mode 100755 index 00000000..30713e4e --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lorem/en.vim @@ -0,0 +1,65 @@ +function! emmet#lorem#en#expand(command) abort + let wcount = matchstr(a:command, '\(\d*\)$') + let wcount = wcount > 0 ? wcount : 30 + + let common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit'] + let words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet', + \ 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi', + \ 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi', + \ 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos', + \ 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum', + \ 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus', + \ 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus', + \ 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum', + \ 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem', + \ 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus', + \ 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente', + \ 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet', + \ 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta', + \ 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima', + \ 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim', + \ 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores', + \ 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias', + \ 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea', + \ 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt', + \ 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate', + \ 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius', + \ 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos', + \ 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore', + \ 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo', + \ 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi', + \ 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam', + \ 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique', + \ 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere', + \ 'maxime', 'corrupti'] + let ret = [] + let sentence = 0 + for i in range(wcount) + let arr = common + if sentence > 0 + let arr += words + endif + let r = emmet#util#rand() + let word = arr[r % len(arr)] + if sentence == 0 + let word = substitute(word, '^.', '\U&', '') + endif + let sentence += 1 + call add(ret, word) + if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1 + if i == wcount - 1 + let endc = '?!...'[emmet#util#rand() % 5] + call add(ret, endc) + else + let endc = '?!,...'[emmet#util#rand() % 6] + call add(ret, endc . ' ') + endif + if endc !=# ',' + let sentence = 0 + endif + else + call add(ret, ' ') + endif + endfor + return join(ret, '') +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/lorem/ja.vim b/sources_forked/emmet-vim/autoload/emmet/lorem/ja.vim new file mode 100755 index 00000000..f99d8fa1 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/lorem/ja.vim @@ -0,0 +1,27 @@ +scriptencoding utf-8 + +function! emmet#lorem#ja#expand(command) abort + let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '') + let wcount = wcount > 0 ? wcount : 30 + + let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html" + let content = emmet#util#cache(url) + if len(content) == 0 + let content = emmet#util#getContentFromURL(url) + let content = matchstr(content, ']*>\zs.\{-}

    ') + let content = substitute(content, '[ \r]', '', 'g') + let content = substitute(content, ']*>', "\n", 'g') + let content = substitute(content, '<[^>]\+>', '', 'g') + let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n") + call emmet#util#cache(url, content) + endif + + let content = substitute(content, "、\n", "、", "g") + let clines = split(content, '\n') + let lines = filter(clines, 'len(substitute(v:val,".",".","g"))<=wcount') + if len(lines) == 0 + let lines = clines + endif + let r = emmet#util#rand() + return lines[r % len(lines)] +endfunction diff --git a/sources_forked/emmet-vim/autoload/emmet/util.vim b/sources_forked/emmet-vim/autoload/emmet/util.vim new file mode 100755 index 00000000..9a5b8d38 --- /dev/null +++ b/sources_forked/emmet-vim/autoload/emmet/util.vim @@ -0,0 +1,349 @@ +"============================================================================== +" region utils +"============================================================================== +" deleteContent : delete content in region +" if region make from between '' and '' +" -------------------- +" begin: +" :end +" -------------------- +" this function make the content as following +" -------------------- +" begin::end +" -------------------- +function! emmet#util#deleteContent(region) abort + let lines = getline(a:region[0][0], a:region[1][0]) + call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) + silent! exe 'delete '.(a:region[1][0] - a:region[0][0]) + call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]]) +endfunction + +" change_content : change content in region +" if region make from between '' and '' +" -------------------- +" begin: +" :end +" -------------------- +" and content is +" -------------------- +" foo +" bar +" baz +" -------------------- +" this function make the content as following +" -------------------- +" begin:foo +" bar +" baz:end +" -------------------- +function! emmet#util#setContent(region, content) abort + let newlines = split(a:content, '\n', 1) + let oldlines = getline(a:region[0][0], a:region[1][0]) + call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) + silent! exe 'delete '.(a:region[1][0] - a:region[0][0]) + if len(newlines) == 0 + let tmp = '' + if a:region[0][1] > 1 + let tmp = oldlines[0][:a:region[0][1]-2] + endif + if a:region[1][1] >= 1 + let tmp .= oldlines[-1][a:region[1][1]:] + endif + call setline(line('.'), tmp) + elseif len(newlines) == 1 + if a:region[0][1] > 1 + let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0] + endif + if a:region[1][1] >= 1 + let newlines[0] .= oldlines[-1][a:region[1][1]:] + endif + call setline(line('.'), newlines[0]) + else + if a:region[0][1] > 1 + let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0] + endif + if a:region[1][1] >= 1 + let newlines[-1] .= oldlines[-1][a:region[1][1]:] + endif + call setline(line('.'), newlines[0]) + call append(line('.'), newlines[1:]) + endif +endfunction + +" select_region : select region +" this function make a selection of region +function! emmet#util#selectRegion(region) abort + call setpos('.', [0, a:region[1][0], a:region[1][1], 0]) + normal! v + call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) +endfunction + +" point_in_region : check point is in the region +" this function return 0 or 1 +function! emmet#util#pointInRegion(point, region) abort + if !emmet#util#regionIsValid(a:region) | return 0 | endif + if a:region[0][0] > a:point[0] | return 0 | endif + if a:region[1][0] < a:point[0] | return 0 | endif + if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif + if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif + return 1 +endfunction + +" cursor_in_region : check cursor is in the region +" this function return 0 or 1 +function! emmet#util#cursorInRegion(region) abort + if !emmet#util#regionIsValid(a:region) | return 0 | endif + let cur = emmet#util#getcurpos()[1:2] + return emmet#util#pointInRegion(cur, a:region) +endfunction + +" region_is_valid : check region is valid +" this function return 0 or 1 +function! emmet#util#regionIsValid(region) abort + if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif + return 1 +endfunction + +" search_region : make region from pattern which is composing start/end +" this function return array of position +function! emmet#util#searchRegion(start, end) abort + let b = searchpairpos(a:start, '', a:end, 'bcnW') + if b == [0, 0] + return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')] + else + return [b, searchpairpos(a:start, '', a:end. '', 'nW')] + endif +endfunction + +" get_content : get content in region +" this function return string in region +function! emmet#util#getContent(region) abort + if !emmet#util#regionIsValid(a:region) + return '' + endif + let lines = getline(a:region[0][0], a:region[1][0]) + if a:region[0][0] == a:region[1][0] + let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1] + else + let lines[0] = lines[0][a:region[0][1]-1:] + let lines[-1] = lines[-1][:a:region[1][1]-1] + endif + return join(lines, "\n") +endfunction + +" region_in_region : check region is in the region +" this function return 0 or 1 +function! emmet#util#regionInRegion(outer, inner) abort + if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer) + return 0 + endif + return emmet#util#pointInRegion(a:inner[0], a:outer) && emmet#util#pointInRegion(a:inner[1], a:outer) +endfunction + +" get_visualblock : get region of visual block +" this function return region of visual block +function! emmet#util#getVisualBlock() abort + return [[line("'<"), col("'<")], [line("'>"), col("'>")]] +endfunction + +"============================================================================== +" html utils +"============================================================================== +function! emmet#util#getContentFromURL(url) abort + let res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', '')))) + while res =~# '^HTTP/1.\d 3' || res =~# '^HTTP/1\.\d 200 Connection established' || res =~# '^HTTP/1\.\d 100 Continue' + let pos = stridx(res, "\r\n\r\n") + if pos != -1 + let res = strpart(res, pos+4) + else + let pos = stridx(res, "\n\n") + let res = strpart(res, pos+2) + endif + endwhile + let pos = stridx(res, "\r\n\r\n") + if pos != -1 + let content = strpart(res, pos+4) + else + let pos = stridx(res, "\n\n") + let content = strpart(res, pos+2) + endif + let header = res[:pos-1] + let charset = matchstr(content, ']\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>') + if len(charset) == 0 + let charset = matchstr(content, ']*>') + endif + if len(charset) == 0 + let charset = matchstr(header, '\nContent-Type:.* charset=[''"]\?\zs[^''";\n]\+\ze') + endif + if len(charset) == 0 + let s1 = len(split(content, '?')) + let utf8 = iconv(content, 'utf-8', &encoding) + let s2 = len(split(utf8, '?')) + return (s2 == s1 || s2 >= s1 * 2) ? utf8 : content + endif + return iconv(content, charset, &encoding) +endfunction + +function! emmet#util#getTextFromHTML(buf) abort + let threshold_len = 100 + let threshold_per = 0.1 + let buf = a:buf + + let buf = strpart(buf, stridx(buf, '')) + let buf = substitute(buf, ']*>.\{-}', '', 'g') + let buf = substitute(buf, ']*>.\{-}', '', 'g') + let res = '' + let max = 0 + let mx = '\(]\{-}>\)\|\(<\/td>\)\|\(]\{-}>\)\|\(<\/div>\)' + let m = split(buf, mx) + for str in m + let c = split(str, '<[^>]*?>') + let str = substitute(str, '<[^>]\{-}>', ' ', 'g') + let str = substitute(str, '>', '>', 'g') + let str = substitute(str, '<', '<', 'g') + let str = substitute(str, '"', '"', 'g') + let str = substitute(str, ''', '''', 'g') + let str = substitute(str, ' ', ' ', 'g') + let str = substitute(str, '¥', '\¥', 'g') + let str = substitute(str, '&', '\&', 'g') + let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '') + let str = substitute(str, '\s\+', ' ', 'g') + let l = len(str) + if l > threshold_len + let per = (l+0.0) / len(c) + if max < l && per > threshold_per + let max = l + let res = str + endif + endif + endfor + let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g') + return res +endfunction + +function! emmet#util#getImageSize(fn) abort + let fn = a:fn + + if emmet#util#isImageMagickInstalled() + return emmet#util#imageSizeWithImageMagick(fn) + endif + + if filereadable(fn) + let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g') + else + if fn !~# '^\w\+://' + let path = fnamemodify(expand('%'), ':p:gs?\\?/?') + if has('win32') || has('win64') | + let path = tolower(path) + endif + for k in keys(g:emmet_docroot) + let root = fnamemodify(k, ':p:gs?\\?/?') + if has('win32') || has('win64') | + let root = tolower(root) + endif + if stridx(path, root) == 0 + let v = g:emmet_docroot[k] + let fn = (len(v) == 0 ? k : v) . fn + break + endif + endfor + endif + let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g') + endif + + let [width, height] = [-1, -1] + if hex =~# '^89504e470d0a1a0a' + let width = eval('0x'.hex[32:39]) + let height = eval('0x'.hex[40:47]) + endif + if hex =~# '^ffd8' + let pos = 4 + while pos < len(hex) + let bs = hex[pos+0:pos+3] + let pos += 4 + if bs ==# 'ffc0' || bs ==# 'ffc2' + let pos += 6 + let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3]) + let pos += 4 + let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3]) + break + elseif bs =~# 'ffd[9a]' + break + elseif bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)' + let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2 + endif + endwhile + endif + if hex =~# '^47494638' + let width = eval('0x'.hex[14:15].hex[12:13]) + let height = eval('0x'.hex[18:19].hex[16:17]) + endif + + return [width, height] +endfunction + +function! emmet#util#imageSizeWithImageMagick(fn) abort + let img_info = system('identify -format "%wx%h" "'.a:fn.'"') + let img_size = split(substitute(img_info, '\n', '', ''), 'x') + if len(img_size) != 2 + return [-1, -1] + endif + return img_size +endfunction + +function! emmet#util#isImageMagickInstalled() abort + if !get(g:, 'emmet_use_identify', 1) + return 0 + endif + return executable('identify') +endfunction + +function! emmet#util#unique(arr) abort + let m = {} + let r = [] + for i in a:arr + if !has_key(m, i) + let m[i] = 1 + call add(r, i) + endif + endfor + return r +endfunction + +let s:seed = localtime() +function! emmet#util#srand(seed) abort + let s:seed = a:seed +endfunction + +function! emmet#util#rand() abort + let s:seed = s:seed * 214013 + 2531011 + return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000 +endfunction + +function! emmet#util#cache(name, ...) abort + let content = get(a:000, 0, '') + let dir = expand('~/.emmet/cache') + if !isdirectory(dir) + call mkdir(dir, 'p', 0700) + endif + let file = dir . '/' . substitute(a:name, '\W', '_', 'g') + if len(content) == 0 + if !filereadable(file) + return '' + endif + return join(readfile(file), "\n") + endif + call writefile(split(content, "\n"), file) +endfunction + +function! emmet#util#getcurpos() abort + let pos = getpos('.') + if mode(0) ==# 'i' && pos[2] > 0 + let pos[2] -=1 + endif + return pos +endfunction + +function! emmet#util#closePopup() abort + return pumvisible() ? "\" : '' +endfunction diff --git a/sources_forked/emmet-vim/doc/emmet.txt b/sources_forked/emmet-vim/doc/emmet.txt new file mode 100755 index 00000000..ffa5e0a9 --- /dev/null +++ b/sources_forked/emmet-vim/doc/emmet.txt @@ -0,0 +1,1773 @@ +*emmet.txt* *Emmet* for Vim + + ------------------------------------------------------- + Emmet: vim plugins for HTML and CSS hi-speed coding + ------------------------------------------------------- + +Author: Yasuhiro Matsumoto +WebSite: http://mattn.kaoriya.net/ +Repository: https://github.com/mattn/emmet-vim +Site: https://mattn.github.com/emmet-vim +License: BSD style license + +============================================================================== +CONTENTS *emmet-contents* + +Introduction |emmet-introduction| +Install |emmet-install| +Tutorial |emmet-tutorial| + 1. Expand abbreviation |emmet-expand-abbr| |,| + 2. Expand word |emmet-expand-word| |;| + 3. Update tag |emmet-update-tag| |u| + 4. Wrap with abbreviation |emmet-wrap-with-abbreviation| |v_,| + 5. Balance tag inward |emmet-balance-tag-inward| |d| + 6. Balance tag outward |emmet-balance-tag-outward| |D| + 7. Go to next edit point |emmet-goto-next-point| |n| + 8. Go to previous edit point |emmet-goto-previous-point| |N| + 9. Add and update size |emmet-update-image-size| |i| + 10. Merge lines |emmet-merge-lines| |m| + 11. Remove tag |emmet-remove-tag| |k| + 12. Split/join tag |emmet-split-join-tag| |j| + 13. Toggle comment |emmet-toggle-comment| |/| + 14. Make anchor from URL |emmet-make-anchor-url| |a| + 15. Make quoted text from URL |emmet-quoted-text-url| |A| + 16. Code pretty |emmet-code-pretty| |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| + 2.1. Child |emmet->| + 2.2. Sibling |emmet-+| + 2.3. Climb-up |emmet-^| + 2.4. Multiplication |emmet-star| + 2.5. Grouping |emmet-()| + 3. Attribute operators |emmet-html-syntax-attribute-operators| + 3.1. ID and CLASS |emmet-.| |emmet-#| + 3.2. Custom attributes |emmet-[]| + 3.3. Item numbering |emmet-$| + 3.3.1. Changing numbering origin and direction |emmet-@| + 3.4. Quote character |emmet-html-attr-quote-char| + 4. Text |emmet-{}| + 5. Implicit tag names |emmet-html-implicit-tag-names| + 6. Notes on abbreviation formatting |emmet-html-syntax-notes| + 7. Choose position to insert text when wrap abbreviation |emmet-$#| +CSS expression syntax |emmet-css-expression-syntax| + 1. Properties |emmet-css-properties| + 2. Values |emmet-css-values| + 3. Units |emmet-css-units| + 4. Vendor prefixes |emmet-css-vendor-prefixes| +Commands |emmet-commands| + :Emmet |:Emmet| + :EmmetInstall |:EmmetInstall| +Variables |emmet-variables| + g:emmet_html5 |g:emmet_html5| + g:emmet_docroot |g:emmet_docroot| + g:emmet_curl_command |g:emmet_curl_command| + g:user_emmet_complete_tag |g:user_emmet_complete_tag| + g:user_emmet_leader_key |g:user_emmet_leader_key| + g:user_emmet_install_global |g:user_emmet_install_global| + g:user_emmet_install_command |g:user_emmet_install_command| + g:user_emmet_settings |g:user_emmet_settings| + g:user_emmet_mode |g:user_emmet_mode| +Customize |emmet-customize| + 1. Key mappings |emmet-customize-key-mappings| + 2. Indent size |emmet-indent-size| + 3. Define tag's behavior |emmet-define-tags-behavior| + 4. Adding custom snippets |emmet-custom-snippets| +Filters |emmet-filters-list| + Escapes XML-unsafe characters |emmet-filter-e| + Add comments around 'important tags' |emmet-filter-c| + Outputs as a single line |emmet-filter-s| + Trim list markers |emmet-filter-t| +Links |emmet-links| +ToDo |emmet-todo| + +============================================================================== +INTRODUCTION *emmet-introduction* *emmet* + +Emmet is an editor plugin for high-speed HTML, XML, XSL (or any other +structured code format) coding and editing. The core of this plugin is a +powerful abbreviation engine which allows you to expand expressions, +similar to CSS selectors, into HTML code: +> + div#page>div.logo+ul#navigation>li*5>a +< +can be expanded into: +> +
    + + +
    +< +Read more about current Emmet syntax + |emmet-html-expression-syntax| + |emmet-css-expression-syntax| + http://docs.emmet.io/abbreviations/ + +Abbreviation engine has a modular structure which allows you +to expand abbreviations into different languages. +Emmet currently supports CSS, HTML, XML/XSL and HAML, Slim languages +via filters (see |emmet-filter|). + +============================================================================== +INSTALL *emmet-install* + +Install the distributed files into Vim runtime directory which is usually +'~/.vim/', or '$HOME/vimfiles' on Windows. + +If you install pathogen (https://github.com/tpope/vim-pathogen) +that provided by Tim Pope, you should extract the +file into 'bundle' directory. + +============================================================================== +TUTORIAL *emmet-tutorial* + +If you are seeing this file as :help, then you can't edit this file. +You should copy this section and create new buffer, paste and write as +'emmet-tutor.txt'. Formally, open the file to start tutorial. + +1. Expand abbreviation *emmet-expand-abbr* *,* + + Type abbreviation as 'div>p#foo$*3>a' and type ','. +> +
    +

    + +

    +

    + +

    +

    + +

    +
    +< +2. Expand abbreviation *emmet-expand-word* *;* + + When you want to expand word except html tokens like below, use this. +> + foo +< + This will be expanded like: +> + + +3. Update tag *emmet-update-tag* *u* + + The begining of tags '
    ' on below +> +
    foo
    +< + Type 'u' request 'Enter Abbreviation:'. Then type +> + .global +< + This will be expanded like: +> +
    foo
    +< +4. Wrap with abbreviation *emmet-wrap-with-abbreviation* *v_,* + + Write as below. +> + test1 + test2 + test3 +< + Then do visual select (line wise) and type ','. + If you request 'Tag:', then type +> + ul>li* +< + Result: +> +
      +
    • test1
    • +
    • test2
    • +
    • test3
    • +
    +< + If you type tag name, for example +> + blockquote +< + then you'll see as following: +> +
    + test1 + test2 + test3 +
    +< + See also: |emmet-filter-t|, |emmet-$#| + +5. Balance tag inward *emmet-balance-tag-inward* *d* + + To select inward of '
      ' tag, type 'd' in insert mode. +> +
        + *
      • +
      • +
      • +
      +< + If cursor is at '*', 'd' select from begin of '
        ' to end of '
      '. + If cursor is at first of '
    • ', it select '
    • '. + +6. Balance tag outward *emmet-balance-tag-outward* *D* + + To select outward of '
        ' tag type 'D' in insert mode. +> +
          + *
        • +
        • +
        • +
        +< + If cursor is at '*', 'D' select from next letter of '
          ' + to previous letter of '
        '. + If cursor is at first of '
      • ', it select '
      • '. + +7. Go to next edit point *emmet-goto-next-point* *n* + + To jump next point that need to edit, type 'n' in insert mode. +> + *
        foo
        +
        +< + If cursor is at '*', type 'n' to move a cursor + into attribute value of '
        ' specified id as 'foo'. + And type again 'n' to move a cursor + into inner of '
        ' specified id as 'bar'. + +8. Go to previous edit point *emmet-goto-previous-point* *N* + + To jump previous point that need to edit, type 'N' in insert mode. +> +
        foo
        +
        * +< + If cursor is at '*', type 'N' to move a cursor + into '
        ' specified id as 'bar'. + And type again 'N' to move a cursor + into attribute value of 'foo'. + +9. Add and update size *emmet-update-image-size* *i* + + To add or update 'width' and 'height' attributes of image, + type 'i' on '' tag +> + +< + Type 'i' on '' tag +> + +< + If you change image, then type it again. it will be following. +> + +< + Image size retrieved using 'identify' (ImageMagick.org) (if available) + or |xxd|. + +10. Merge lines *emmet-merge-lines* *m* + + To join multi line text like following, type |J|. +> +
          +
        • +
        • +
        • +
        +< + If you select part of line include '
      • ' and type |m|, + it will be following. +> +
          +
        • +
        +< +11. Remove tag *emmet-remove-tag* *k* + + To remove tag in the block, type 'k'. +> + +< + Type 'k' in insert mode, then +> +
        + +
        +< + And type 'k' in there again, then '
        ' will be removed. + +12. Split/join tag *emmet-split-join-tag* *j* + + To join block, type 'j'. +> +
        + cursor is here +
        +< + Type 'j' in insert mode. Then, +> +
        +< + And type 'j' in there again. +> +
        +
        +< +13. Toggle comment *emmet-toggle-comment* */* + + Move cursor to block +> +
        + hello world +
        +< + Type '/' in insert mode. +> + +< + Type '/' in there again. +> +
        + hello world +
        +< +14. Make anchor from URL *emmet-make-anchor-url* *a* + + Move cursor to URL +> + http://www.google.com/ +< + Type 'a' +> + Google +< + Text retrieved using command, specified by |g:emmet_curl_command|. + +15. Make quoted text from URL *emmet-quoted-text-url* *A* + + Move cursor to URL +> + https://github.com/ +< + Type 'A' +> +
        + Secure source code hosting and collaborative development - GitHub
        +

        How does it work? Get up and running in seconds by forking a project, pushing an existing repository...

        + https://github.com/ +
        +< + Text retrieved using command, specified by |g:emmet_curl_command|. + +16. Code pretty *emmet-code-pretty* *c* + + Select code block, for example select following code from 'int main()'. +> +

        Writing in C language

        + + int main() { + puts("hello world"); + } +< + Type 'c' +> + int main() {
        +   puts("hello world");
        + }
        +< + To convert text into html used command |:TOhtml|. + +17. Lorem ipsum *emmet-lorem-ipsum* + + To insert dummy text (30 words by default). +> + div>lorem +< + Type |,| +> +
        Adipisicing asperiores deleniti ipsum fuga deserunt perferendis + molestiae sunt excepturi aut quo nihil! Optio accusantium corporis molestiae + deserunt ab, veritatis commodi. Eius nobis ab deserunt magni iure quo + laboriosam laboriosam.
        +< + For japanese user, put like follow into your |g:user_emmet_settings|: +> + let g:user_emmet_settings = { + ... + + \ 'custom_expands1' : { + \ '^\%(lorem\|lipsum\)\(\d*\)$' : function('emmet#lorem#ja#expand'), + \ }, + + ... +< + You will get japanese dummy text. Text retrieved from url + 'http://www.aozora.gr.jp/cards/000081/files/470_15407.html' + using command, specified by |g:emmet_curl_command|. + + To insert 3 words of dummy text. +> + div>lorem3 +< + Type |,| +> +
        + Elit libero id. +
        +< +============================================================================== +HTML EXPRESSION SYNTAX *emmet-html-expression-syntax* + +Emmet uses syntax similar to CSS selectors for describing elements' positions +inside generated tree and elements' attributes. + +1. Elements *emmet-html-syntax-elements* + + You can use elements' names like 'div' or 'p' to generate HTML tags. +> + p ->

        + div ->
        +< + You can write any word and transform it into a tag: +> + foo -> + bar -> +< + Emmet knowns set of empty elements: +> + br ->
        or
        + meta -> or +< + To choose between HTML '>' and XHTML ' />' use |g:emmet_html5| or + |g:user_emmet_settings|: +> + let g:user_emmet_settings = { + \ ... + \ 'html': { + \ ... + \ 'empty_element_suffix': ' />', + \ ... + \ }, + \ ... + \} +< + Emmet will automatically insert some attributes: +> + a -> + link -> +< + Set of inserted attributes can be changed using |g:user_emmet_settings|: +> + let s:emmet_settings = { + \ ... + \ 'html': { + \ ... + \ 'default_attributes': { + \ ... + \ 'a': {'href': ''}, + \ 'ins': {'datetime': '${datetime}'}, + \ 'iframe': [{'src': ''}, {'frameborder': '0'}], + \ 'textarea': [{'name': ''}, {'id': ''}, {'cols': '30'}, {'rows': '10'}], + \ ... + \ }, + \ ... + \ }, + \ ... + \} +< +2. Nesting operators *emmet-html-syntax-nesting-operators* + + Nesting operators are used to position abbreviation elements + inside generated tree: whether it should be placed + inside or near the context element. + + Operator Description Link ~ + > Child |emmet->| + + Sibling |emmet-+| + ^ Climb-up |emmet-^| + * Multiplication |emmet-star| + () Grouping |emmet-()| + +2.1. Child *emmet->* + + You can use '>' operator to nest elements inside each other: +> + div>ul>li +< + will produce +> +
        +
          +
        • +
        +
        +< +2.2. Sibling *emmet-+* + + Use '+' operator to place elements near each other, on the same level: +> + div+p+bq +< + will output +> +
        +

        +
        +< +2.3. Climb-up *emmet-^* + + With '>' operator you're descending down the generated tree and + positions of all sibling elements will be resolved + against the most deepest element: +> + div+div>p>span+em +< + will be expanded to +> +
        +
        +

        + + +

        +
        +< + With '^' operator, you can climb one level up the tree and change context + where following elements should appear: +> + div+div>p>span+em^bq +< + outputs to +> +
        +
        +

        + + +

        +
        +
        +< + You can use as many '^' operators as you like, + each operator will move one level up: +> + div+div>p>span+em^^^bq +< + will output to +> +
        +
        +

        + + +

        +
        +
        +< +2.4. Multiplication *emmet-star* + + With '*' operator you can define how many times element should be outputted: +> + ul>li*5 +< + outputs to +> +
          +
        • +
        • +
        • +
        • +
        • +
        +< + Expression may contain several '*' operators: +> + tr*2>td*3 +< + become +> + + + + + + + + + + +< +2.5. Grouping *emmet-()* + + Parentheses '()' are used by Emmets' power users for grouping subtrees + in complex abbreviations: +> + div>(header>ul>li*2>a)+footer>p +< + expands to +> +
        +
        +
          +
        • +
        • +
        +
        +
        +

        +
        +
        +< + If you're working with browser's DOM, you may think of groups + as Document Fragments: each group contains abbreviation subtree and + all the following elements are inserted at the same level + as the first element of group. + + You can nest groups inside each other and + combine them with multiplication '*' operator: +> + (div>dl>(dt+dd)*3)+footer>p +< + produces +> +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        +
        +< + With groups, you can literally write full page mark-up + with a single abbreviation, but please don't do that. + +3. Attribute operators *emmet-html-syntax-attribute-operators* + + Attribute operators are used to modify attributes of outputted elements. + For example, in HTML and XML you can quickly add 'class' attribute + to generated element. + + Operator Description Link ~ + . Attribute 'class' |emmet-.| + # Attribute 'id' |emmet-#| + [] Custom attributes |emmet-[]| + $ Number |emmet-$| + @ Number origin and direction |emmet-@| + +3.1. ID and CLASS *emmet-.* *emmet-#* + + In CSS, you use 'elem#id' and 'elem.class' notation to reach the elements + with specified 'id' or 'class' attributes. + In Emmet, you can use the very same syntax to add these attributes + to specified element: +> + span.class1 -> + span.class1.class2 -> + div#wrapper ->
        + div#wrapper.content ->
        +< + More complex expression: +> + div#header+div.page+div#footer.class1.class2.class3 +< + will output +> + +
        + +< +3.2. Custom attributes *emmet-[]* + + You can use '[attr]' notation (as in CSS) + to add custom attributes to your element: +> + td[title="Hello world!" colspan=3] +< + outputs +> + +< + You can place as many attributes as you like inside square brackets. + + Attribute values may be omitted: +> + td[colspan title] +< + will produce +> + +< + You can use single or double quotes for quoting attribute values. +> + div[a='value1' b="value2"] +< + become +> +
        +< + You don't need to quote values if they don't contain spaces: +> + td[title=hello colspan=3] +< + will output +> + +< +3.3. Item numbering *emmet-$* + + With multiplication '*' operator you can repeat elements, + but with '$' you can number them. + Place '$' operator inside element's name, attribute's name or + attribute's value to output current number of repeated element: +> + ul>li.item_$*5 +< + outputs to +> +
          +
        • +
        • +
        • +
        • +
        • +
        +< + You can use multiple '$' in a row to pad number with zeroes: +> + ul>li.item_$$$*5 +< + outputs to +> +
          +
        • +
        • +
        • +
        • +
        • +
        +< + Also '$' can be used in element name and in text (|emmet-{}|): +> + h$[title=item$]{Header $}*3 +< + transformed to +> +

        Header 1

        +

        Header 2

        +

        Header 3

        +< +3.3.1. Changing numbering origin and direction *emmet-@* + + With '@' modifier, you can change + - numbering direction (ascending or descending) and + - origin (i. e. start value). + + For example, to change direction, add '@-' after '$': +> + ul>li.item_$@-*5 +< + outputs to +> +
          +
        • +
        • +
        • +
        • +
        • +
        +< + To change counter origin value, add '@N' modifier to '$': +> + ul>li.item_$@3*5 +< + transforms to +> +
          +
        • +
        • +
        • +
        • +
        • +
        +< + You can use these modifiers together: +> + ul>li.item_$@-3*5 +< + is transformed to +> +
          +
        • +
        • +
        • +
        • +
        • +
        +> +3.4. Quote character *emmet-html-attr-quote-char* + + |g:user_emmet_settings| may be used to change attribute quote character: +> + let g:user_emmet_settings = { + ... + \ 'html' : { + ... + \ 'quote_char': "'", + ... + \ }, + ... + \} +< + Then abbreviation +> + a[target=_blank] +< + will expand to +> + +< + instead of +> + +< + Default quote is '"'. + +4. Text *emmet-{}* + + You can use curly braces to add text to element: +> + a{Click me} +< + will produce +> + Click me +< + Note that '{text}' is used and parsed as a separate element + (like, 'div', 'p' etc), but has a special meaning + when written right after element. For example, +> + a{click} +< + and +> + a>{click} +< + will produce the same output, but +> + a{click}+b{here} +< + and +> + a>{click}+b{here} +< + won't: +> + + clickhere + + + clickhere +< + In second example the '' element is placed inside '' element. + And that's the difference: when '{text}' is written right after element, + it doesn't change parent context. + Here's more complex example showing why it is important: +> + p>{Click }+a{here}+{ to continue} +< + produces +> +

        Click here to continue

        +< + In this example, to write 'Click here to continue' inside '

        ' element + we have explicitly move down the tree with '>' operator after 'p', + but in case of 'a' element we don't have to, since we need '' element + with here word only, without changing parent context. + + For comparison, here's the same abbreviation + written without child '>' operator: +> + p{Click }+a{here}+{ to continue} +< + produces +> +

        Click

        + here to continue +< +5. Implicit tag names *emmet-html-implicit-tag-names* + + Even with such a powerful abbreviation engine, + which can expand large HTML structures from short abbreviation, + writing tag names may be very tedious. + + In many cases you can skip typing tag names and + Emmet will substitute it for you. + For example, instead of > + div.content +< you can simply write > + .content +< and expand it into > +
        +< + Other examples: +> + .wrapper ->
        + #popup -> +< + When you expand abbreviation, Emmet tries to grab parent context, + e. g. the HTML element, inside which you're expanding the abbreviation. + If the context was grabbed successfully, + Emmet uses its name to resolve implicit names. + Emmet looks at the parent tag name every time + you're expanding the abbreviation with an implicit name. + Here's how it resolves the names for some parent elements: + + Inserted element Parent elements ~ + li ul, ol + tr table, tbody, thead, tfoot + td tr + option select, optgroup + span Inline elements + div Block elements + + Take a look at some abbreviations equivalents + with implicit and explicit tag names: +> + .wrap>.content -> div.wrap>div.content + em>.info -> em>span.info + ul>.item*3 -> ul>li.item*3 + table>.row>.col -> table>tr.row>td.col + table>#row$*4>[colspan=2] -> table>tr#row$*4>td[colspan=2] +< +6. Notes on abbreviation formatting *emmet-html-syntax-notes* + + When you get familiar with Emmet's abbreviations syntax, + you may want to use some formatting to make your abbreviations more readable. + For example, use spaces between elements and operators, like this: +> + (header > ul.nav > li*5) + footer +< + But it won't work, because space is a stop symbol + where Emmet stops abbreviation parsing. + + Many users mistakenly think that each abbreviation + should be written in a new line, but they are wrong: + you can type and expand abbreviation anywhere in the text: + + This is why Emmet needs some indicators (like spaces) + where it should stop parsing to not expand anything that you don't need. + If you're still thinking that such formatting is required + for complex abbreviations to make them more readable: + - abbreviations are not a template language, + they don't have to be "readable", + they have to be "quickly expandable and removable"; + - you don't really need to write complex abbreviations. + Stop thinking that "typing" is the slowest process in web-development. + You'll quickly find out that constructing a single complex abbreviation + is much slower and error-prone than constructing and typing + a few short ones. + +7. Choose position to insert text when wrap abbreviation *emmet-$#* + + When wrap abbreviation (|emmet-wrap-with-abbreviation|) you can choose + position to insert text using '$#' operator. + Operator '$#' may be used only inside |emmet-[]| and/or |emmet-{}|. + + For example, do visual select (line wise) following text: +> + First + Second + Third +< + Then press ',' and type +> + ul>li[ title="[$#]" ]* +< + Result: +> +
          +
        • First
        • +
        • Second
        • +
        • Third
        • +
        +< + You may type +> + input[ type=input value=$# ] +< + to get +> + + + +< + Using '$#' you can type text (|emmet-{}|) only once: +> + a[title=$#]{foo} +< + will be expanded to +> + foo +< +============================================================================== +CSS EXPRESSION SYNTAX *emmet-css-expression-syntax* + +1. Properties *emmet-css-properties* + + Emmet has a lot of predefined snippets for CSS properties. +> + +< + become +> + +< + In above example '|' denotes a cursor (caret) position. + + Other examples: +> + t -> top: ; + d -> display: ; + o -> outline: ; + ov -> overflow: ; + cu -> cursor: ; + bdrs -> border-radius: ; +< + '+' operator may be used to insert number of properties: +> + m1+p2 +< + become +> + margin: 1px; + padding: 2px; +< +2. Values *emmet-css-values* + + Some properties have default values: +> + c -> color: #000; + bgc -> background-color: #FFF; + zoo -> zoom: 1; +< + To insert predefined property value after abbreviation + type colon ':' and first character of predefined keyword: +> + d:n -> display: none; + d:b -> display: block; + d:i -> display: inline; +< + Numerical value can be typed directly after abbreviation: +> + m10 -> margin: 10px; + m2e -> margin: 2em; +< + Use a hyphen '-' to separate some numerical values: +> + m10-20 -> margin: 10px 20px; + p1-2-3 -> padding: 1px 2px 3px; +< + To negative values + precede the first value with hyphen and all the rest with double hyphens: +> + m-10 -> margin: -10px; + m-1--2 -> margin: -1px -2px; + p-2--1-0-1 -> padding: -2px -1px 0 1px; +< + To insert '!important' append '!' to property abbreviation: +> + m! -> margin: !important; + bac! -> background: !important; +< + You can use special abbreviation 'lg(...)' + to insert definition of linear gradient. Example: +> + lg(left, #fc0 30%, red) +< + will expand to +> + background-image: -webkit-gradient(left, 0 0, 0 100, from(#fc0 30%), to(red)); + background-image: -webkit-linear-gradient(#fc0 30%, red); + background-image: -moz-linear-gradient(#fc0 30%, red); + background-image: -o-linear-gradient(#fc0 30%, red); + background-image: linear-gradient(#fc0 30%, red); +< +3. Units *emmet-css-units* + + By default, when you expand an abbreviation with integer value, + Emmet outputs it with a 'px' unit: +> + bor2 -> border: 2px; + fs100 -> font-size: 100px; + miw20 -> min-width: 20px; +< + By default, if you're expanding an abbreviation with a float value, + it is outputted with an 'em' unit: +> + fs1.5 -> font-style: 1.5em; +< + But you can explicitly provide the unit name + by putting one of characters right after value: + + Character Unit ~ + p % + e em + + Examples: +> + fs2e -> font-style: 2em; + w100p -> width: 100%; +< +4. Vendor prefixes *emmet-css-vendor-prefixes* + + To automatically create vendor-prefixed copies of property, + precede abbreviation with a hyphen '-'. For example, abbreviation +> + -bdrs +< + will be expanded into +> + -webkit-border-radius: ; + -moz-border-radius: ; + border-radius: ; +< +============================================================================== +COMMANDS *emmet-commands* + +:Emmet {expression} *:Emmet* + Expand {expression} and insert result under cursor. + {expression} is |emmet-html-expression|. + Also see |g:user_emmet_install_command|. + +:EmmetInstall *:EmmetInstall* + Create Emmet mappings to current buffer + (|mapping|, |:map-|) and, + if set |g:user_emmet_complete_tag|, + change |'omnifunc'| option to emmet#completeTag() + +============================================================================== +VARIABLES *emmet-variables* + +g:emmet_html5 *g:emmet_html5* + If set to 1, enable HTML 5 support: + - use ">" instead of "/>": > + + +< - omit some HTML 4 attributes: > +