Rename to Emmet.vim!

This commit is contained in:
mattn
2013-08-06 19:49:59 +09:00
parent 5d54856b49
commit 43d5656dca
19 changed files with 796 additions and 779 deletions

View File

@@ -1,11 +1,11 @@
all : zencoding-vim.zip all : emmet-vim.zip
remove-zip: remove-zip:
-rm doc/tags -rm doc/tags
-rm zencoding-vim.zip -rm emmet-vim.zip
zencoding-vim.zip: remove-zip emmet-vim.zip: remove-zip
zip -r zencoding-vim.zip autoload plugin doc zip -r emmet-vim.zip autoload plugin doc
release: zencoding-vim.zip release: emmet-vim.zip
vimup update-script zencoding.vim vimup update-script emmet.vim

View File

@@ -1,33 +1,33 @@
# ZenCoding-vim # Emmet-vim
[zencoding-vim](http://mattn.github.com/zencoding-vim) is a vim plug-in [emmet-vim](http://mattn.github.com/emmet-vim) is a vim plug-in
which provides support for expanding abbreviations similar to which provides support for expanding abbreviations similar to
[zen-coding](http://code.google.com/p/zen-coding/). [emmet](http://emmet.io/).
## Installation ## Installation
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981): [Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
cd ~/.vim cd ~/.vim
unzip zencoding-vim.zip unzip emmet-vim.zip
To install using pathogen.vim: To install using pathogen.vim:
cd ~/.vim/bundle cd ~/.vim/bundle
unzip /path/to/zencoding-vim.zip unzip /path/to/emmet-vim.zip
To checkout the source from repository: To checkout the source from repository:
cd ~/.vim/bundle cd ~/.vim/bundle
git clone http://github.com/mattn/zencoding-vim.git git clone http://github.com/mattn/emmet-vim.git
or: or:
git clone http://github.com/mattn/zencoding-vim.git git clone http://github.com/mattn/emmet-vim.git
cd zencoding-vim cd emmet-vim
cp plugin/zencoding.vim ~/.vim/plugin/ cp plugin/emmet.vim ~/.vim/plugin/
cp autoload/zencoding.vim ~/.vim/autoload/ cp autoload/emmet.vim ~/.vim/autoload/
cp -a autoload/zencoding ~/.vim/autoload/ cp -a autoload/emmet ~/.vim/autoload/
## Quick Tutorial ## Quick Tutorial
@@ -53,17 +53,17 @@ Then type "\<c-y\>," (Ctrl + y + ','), you should see:
</body> </body>
</html> </html>
[More Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL) [More Tutorials](https://raw.github.com/mattn/emmet-vim/master/TUTORIAL)
## Enable in different mode ## Enable in different mode
If you don't want to enable zencoding in all modes, If you don't want to enable emmet in all modes,
you can use set these options in `vimrc`: you can use set these options in `vimrc`:
let g:user_zen_mode='n' "only enable normal mode functions. let g:user_emmet_mode='n' "only enable normal mode functions.
let g:user_zen_mode='inv' "enable all functions, which is equal to let g:user_emmet_mode='inv' "enable all functions, which is equal to
let g:user_zen_mode='a' "enable all function in all mode. let g:user_emmet_mode='a' "enable all function in all mode.
## Project Authors ## Project Authors
@@ -71,17 +71,21 @@ you can use set these options in `vimrc`:
## Links ## Links
### Emmet official site:
* <http://emmet.io/>
### zen-coding official site: ### zen-coding official site:
* <http://code.google.com/p/zen-coding/> * <http://code.google.com/p/zen-coding/>
### zencoding.vim: ### emmet.vim:
* <http://mattn.github.com/zencoding-vim> * <http://mattn.github.com/emmet-vim>
### development repository: ### development repository:
* <https://github.com/mattn/zencoding-vim> * <https://github.com/mattn/emmet-vim>
### my blog posts about zencoding-vim: ### my blog posts about zencoding-vim:

View File

@@ -1,4 +1,4 @@
Tutorial for zencoding.vim Tutorial for Emmet.vim
mattn <mattn.jp@gmail.com> mattn <mattn.jp@gmail.com>
@@ -176,28 +176,28 @@ Tutorial for zencoding.vim
</blockquote> </blockquote>
--------------------- ---------------------
14. Installing zencoding.vim for the language you are using: 14. Installing emmet.vim for the language you are using:
# cd ~/.vim # cd ~/.vim
# unzip zencoding-vim.zip # unzip emmet-vim.zip
Or if you are using pathogen.vim: Or if you are using pathogen.vim:
# cd ~/.vim/bundle # or make directory # cd ~/.vim/bundle # or make directory
# unzip /path/to/zencoding-vim.zip # unzip /path/to/emmet-vim.zip
Or if you get the sources from the repository: Or if you get the sources from the repository:
# cd ~/.vim/bundle # or make directory # cd ~/.vim/bundle # or make directory
# git clone http://github.com/mattn/zencoding-vim.git # git clone http://github.com/mattn/emmet-vim.git
15. Enable zencoding.vim for the language you using. 15. Enable emmet.vim for the language you using.
You can customize the behavior of the languages you are using. You can customize the behavior of the languages you are using.
--------------------- ---------------------
# cat >> ~/.vimrc # cat >> ~/.vimrc
let g:user_zen_settings = { let g:user_emmet_settings = {
\ 'php' : { \ 'php' : {
\ 'extends' : 'html', \ 'extends' : 'html',
\ 'filters' : 'c', \ 'filters' : 'c',

View File

@@ -1,20 +1,20 @@
"============================================================================= "=============================================================================
" zencoding.vim " emmet.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> " Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 10-Jun-2013. " Last Change: 06-Aug-2013.
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! zencoding#getExpandos(type, key) function! emmet#getExpandos(type, key)
let expandos = zencoding#getResource(a:type, 'expandos', {}) let expandos = emmet#getResource(a:type, 'expandos', {})
if has_key(expandos, a:key) if has_key(expandos, a:key)
return expandos[a:key] return expandos[a:key]
endif endif
return a:key return a:key
endfunction endfunction
function! zencoding#splitFilterArg(filters) function! emmet#splitFilterArg(filters)
for f in a:filters for f in a:filters
if f =~ '^/' if f =~ '^/'
return f[1:] return f[1:]
@@ -23,7 +23,7 @@ function! zencoding#splitFilterArg(filters)
return '' return ''
endfunction endfunction
function! zencoding#useFilter(filters, filter) function! emmet#useFilter(filters, filter)
for f in a:filters for f in a:filters
if a:filter == '/' && f =~ '^/' if a:filter == '/' && f =~ '^/'
return 1 return 1
@@ -34,30 +34,30 @@ function! zencoding#useFilter(filters, filter)
return 0 return 0
endfunction endfunction
function! zencoding#getIndentation(...) function! emmet#getIndentation(...)
if a:0 > 0 if a:0 > 0
let type = a:1 let type = a:1
else else
let type = zencoding#getFileType() let type = emmet#getFileType()
endif endif
if has_key(s:zen_settings, type) && has_key(s:zen_settings[type], 'indentation') if has_key(s:emmet_settings, type) && has_key(s:emmet_settings[type], 'indentation')
let indent = s:zen_settings[type].indentation let indent = s:emmet_settings[type].indentation
elseif has_key(s:zen_settings, 'indentation') elseif has_key(s:emmet_settings, 'indentation')
let indent = s:zen_settings.indentation let indent = s:emmet_settings.indentation
else else
let indent = (&l:expandtab || &l:tabstop != &l:shiftwidth) ? repeat(' ', &l:shiftwidth) : "\t" let indent = (&l:expandtab || &l:tabstop != &l:shiftwidth) ? repeat(' ', &l:shiftwidth) : "\t"
endif endif
return indent return indent
endfunction endfunction
function! zencoding#getBaseType(type) function! emmet#getBaseType(type)
if !has_key(s:zen_settings, a:type) if !has_key(s:emmet_settings, a:type)
return '' return ''
endif endif
if !has_key(s:zen_settings[a:type], 'extends') if !has_key(s:emmet_settings[a:type], 'extends')
return a:type return a:type
endif endif
let extends = s:zen_settings[a:type].extends let extends = s:emmet_settings[a:type].extends
if type(extends) == 1 if type(extends) == 1
let tmp = split(extends, '\s*,\s*') let tmp = split(extends, '\s*,\s*')
let ext = tmp[0] let ext = tmp[0]
@@ -65,22 +65,22 @@ function! zencoding#getBaseType(type)
let ext = extends[0] let ext = extends[0]
endif endif
if a:type != ext if a:type != ext
return zencoding#getBaseType(ext) return emmet#getBaseType(ext)
endif endif
return '' return ''
endfunction endfunction
function! zencoding#isExtends(type, extend) function! emmet#isExtends(type, extend)
if a:type == a:extend if a:type == a:extend
return 1 return 1
endif endif
if !has_key(s:zen_settings, a:type) if !has_key(s:emmet_settings, a:type)
return 0 return 0
endif endif
if !has_key(s:zen_settings[a:type], 'extends') if !has_key(s:emmet_settings[a:type], 'extends')
return 0 return 0
endif endif
let extends = s:zen_settings[a:type].extends let extends = s:emmet_settings[a:type].extends
if type(extends) == 1 if type(extends) == 1
let tmp = split(extends, '\s*,\s*') let tmp = split(extends, '\s*,\s*')
unlet! extends unlet! extends
@@ -94,14 +94,14 @@ function! zencoding#isExtends(type, extend)
return 0 return 0
endfunction endfunction
function! zencoding#parseIntoTree(abbr, type) function! emmet#parseIntoTree(abbr, type)
let abbr = a:abbr let abbr = a:abbr
let type = a:type let type = a:type
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#parseIntoTree(abbr, type) return emmet#lang#{rtype}#parseIntoTree(abbr, type)
endfunction endfunction
function! zencoding#mergeConfig(lhs, rhs) function! emmet#mergeConfig(lhs, rhs)
if type(a:lhs) == 3 && type(a:rhs) == 3 if type(a:lhs) == 3 && type(a:rhs) == 3
let a:lhs += a:rhs let a:lhs += a:rhs
if len(a:lhs) if len(a:lhs)
@@ -119,7 +119,7 @@ function! zencoding#mergeConfig(lhs, rhs)
let a:lhs[key] += a:rhs[key] let a:lhs[key] += a:rhs[key]
elseif type(a:rhs[key]) == 4 elseif type(a:rhs[key]) == 4
if has_key(a:lhs, key) if has_key(a:lhs, key)
call zencoding#mergeConfig(a:lhs[key], a:rhs[key]) call emmet#mergeConfig(a:lhs[key], a:rhs[key])
else else
let a:lhs[key] = a:rhs[key] let a:lhs[key] = a:rhs[key]
endif endif
@@ -130,7 +130,7 @@ function! zencoding#mergeConfig(lhs, rhs)
endif endif
endfunction endfunction
function! zencoding#toString(...) function! emmet#toString(...)
let current = a:1 let current = a:1
if a:0 > 1 if a:0 > 1
let type = a:2 let type = a:2
@@ -163,16 +163,16 @@ function! zencoding#toString(...)
let indent = '' let indent = ''
endif endif
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
let itemno = 0 let itemno = 0
let str = '' let str = ''
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
while itemno < current.multiplier while itemno < current.multiplier
if len(current.name) if len(current.name)
if group_itemno != 0 if group_itemno != 0
let inner = zencoding#lang#{rtype}#toString(s:zen_settings, current, type, inline, filters, group_itemno, indent) let inner = emmet#lang#{rtype}#toString(s:emmet_settings, current, type, inline, filters, group_itemno, indent)
else else
let inner = zencoding#lang#{rtype}#toString(s:zen_settings, current, type, inline, filters, itemno, indent) let inner = emmet#lang#{rtype}#toString(s:emmet_settings, current, type, inline, filters, itemno, indent)
endif endif
if current.multiplier > 1 if current.multiplier > 1
let inner = substitute(inner, '\$#', '$line'.(itemno+1).'$', 'g') let inner = substitute(inner, '\$#', '$line'.(itemno+1).'$', 'g')
@@ -181,16 +181,16 @@ function! zencoding#toString(...)
else else
let snippet = current.snippet let snippet = current.snippet
if len(current.snippet) == 0 if len(current.snippet) == 0
let snippets = zencoding#getResource(type, 'snippets', {}) let snippets = emmet#getResource(type, 'snippets', {})
if !empty(snippets) && has_key(snippets, 'zensnippet') if !empty(snippets) && has_key(snippets, 'emmet_snippet')
let snippet = snippets['zensnippet'] let snippet = snippets['emmet_snippet']
endif endif
endif endif
if len(snippet) > 0 if len(snippet) > 0
let tmp = snippet let tmp = snippet
let tmp = substitute(tmp, '\${zenname}', current.name, 'g') let tmp = substitute(tmp, '\${emmet_name}', current.name, 'g')
let snippet_node = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 0, 'parent': {}, 'value': '{'.tmp.'}', 'pos': 0, 'important': current.important } let snippet_node = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 0, 'parent': {}, 'value': '{'.tmp.'}', 'pos': 0, 'important': current.important }
let str = zencoding#lang#{rtype}#toString(s:zen_settings, snippet_node, type, inline, filters, group_itemno, indent) let str = emmet#lang#{rtype}#toString(s:emmet_settings, snippet_node, type, inline, filters, group_itemno, indent)
else else
if len(current.name) if len(current.name)
let str .= current.name let str .= current.name
@@ -198,7 +198,8 @@ function! zencoding#toString(...)
if len(current.value) if len(current.value)
let text = current.value[1:-2] let text = current.value[1:-2]
if dollar_expr if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", max([itemno, group_itemno])+1).submatch(2)', 'g') " TODO: regexp engine specified
let text = substitute(text, '\%#=1\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", max([itemno, group_itemno])+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g') let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g') let text = substitute(text, '\\\$', '$', 'g')
endif endif
@@ -207,9 +208,9 @@ function! zencoding#toString(...)
endif endif
let inner = '' let inner = ''
if len(current.child) if len(current.child)
let render_type = zencoding#getFileType(1) let render_type = emmet#getFileType(1)
for n in current.child for n in current.child
let inner .= zencoding#toString(n, type, inline, filters, group_itemno, indent) let inner .= emmet#toString(n, type, inline, filters, group_itemno, indent)
endfor endfor
endif endif
let spaces = matchstr(str, '\s*\ze\${child}') let spaces = matchstr(str, '\s*\ze\${child}')
@@ -221,49 +222,49 @@ function! zencoding#toString(...)
return str return str
endfunction endfunction
function! zencoding#getSettings() function! emmet#getSettings()
return s:zen_settings return s:emmet_settings
endfunction endfunction
function! zencoding#getResource(type, name, default) function! emmet#getResource(type, name, default)
if !has_key(s:zen_settings, a:type) if !has_key(s:emmet_settings, a:type)
return a:default return a:default
endif endif
let ret = a:default let ret = a:default
if has_key(s:zen_settings[a:type], 'extends') if has_key(s:emmet_settings[a:type], 'extends')
let extends = s:zen_settings[a:type].extends let extends = s:emmet_settings[a:type].extends
if type(extends) == 1 if type(extends) == 1
let tmp = split(extends, '\s*,\s*') let tmp = split(extends, '\s*,\s*')
unlet! extends unlet! extends
let extends = tmp let extends = tmp
endif endif
for ext in extends for ext in extends
if has_key(s:zen_settings, ext) && has_key(s:zen_settings[ext], a:name) if has_key(s:emmet_settings, ext) && has_key(s:emmet_settings[ext], a:name)
call zencoding#mergeConfig(ret, s:zen_settings[ext][a:name]) call emmet#mergeConfig(ret, s:emmet_settings[ext][a:name])
endif endif
endfor endfor
endif endif
if has_key(s:zen_settings[a:type], a:name) if has_key(s:emmet_settings[a:type], a:name)
let v = s:zen_settings[a:type][a:name] let v = s:emmet_settings[a:type][a:name]
if type(ret) == 3 || type(ret) == 4 if type(ret) == 3 || type(ret) == 4
call zencoding#mergeConfig(ret, s:zen_settings[a:type][a:name]) call emmet#mergeConfig(ret, s:emmet_settings[a:type][a:name])
else else
let ret = s:zen_settings[a:type][a:name] let ret = s:emmet_settings[a:type][a:name]
endif endif
endif endif
return ret return ret
endfunction endfunction
function! zencoding#getFileType(...) function! emmet#getFileType(...)
let flg = get(a:000, 0, 0) let flg = get(a:000, 0, 0)
let type = &ft let type = &ft
if zencoding#lang#exists(&ft) if emmet#lang#exists(&ft)
let type = &ft let type = &ft
else else
let base = zencoding#getBaseType(type) let base = emmet#getBaseType(type)
if base != "" if base != ""
if flg if flg
let type = &ft let type = &ft
@@ -291,7 +292,7 @@ function! zencoding#getFileType(...)
return type return type
endfunction endfunction
function! zencoding#getDollarExprs(expand) function! emmet#getDollarExprs(expand)
let expand = a:expand let expand = a:expand
let dollar_list = [] let dollar_list = []
let dollar_reg = '\%(\\\)\@<!\${\(\([^{}]\|\%(\\\)\@\<=[{}]\)\{}\)}' let dollar_reg = '\%(\\\)\@<!\${\(\([^{}]\|\%(\\\)\@\<=[{}]\)\{}\)}'
@@ -302,7 +303,7 @@ function! zencoding#getDollarExprs(expand)
if key !~ '^\d\+:' if key !~ '^\d\+:'
let key = substitute(key, '\\{', '{', 'g') let key = substitute(key, '\\{', '{', 'g')
let key = substitute(key, '\\}', '}', 'g') let key = substitute(key, '\\}', '}', 'g')
let value = zencoding#getDollarValueByKey(key) let value = emmet#getDollarValueByKey(key)
if type(value) == type('') if type(value) == type('')
let expr = get(matcharr, 0) let expr = get(matcharr, 0)
call add(dollar_list, {'expr': expr, 'value': value}) call add(dollar_list, {'expr': expr, 'value': value})
@@ -316,22 +317,22 @@ function! zencoding#getDollarExprs(expand)
return dollar_list return dollar_list
endfunction endfunction
function! zencoding#getDollarValueByKey(key) function! emmet#getDollarValueByKey(key)
let ret = 0 let ret = 0
let key = a:key let key = a:key
let ftsetting = get(s:zen_settings, zencoding#getFileType()) let ftsetting = get(s:emmet_settings, emmet#getFileType())
if type(ftsetting) == 4 && has_key(ftsetting, key) if type(ftsetting) == 4 && has_key(ftsetting, key)
let V = get(ftsetting, key) let V = get(ftsetting, key)
if type(V) == 1 | return V | endif if type(V) == 1 | return V | endif
endif endif
if type(ret) != 1 && has_key(s:zen_settings, key) if type(ret) != 1 && has_key(s:emmet_settings, key)
let V = get(s:zen_settings, key) let V = get(s:emmet_settings, key)
if type(V) == 1 | return V | endif if type(V) == 1 | return V | endif
endif endif
if has_key(s:zen_settings, 'custom_expands') && type(s:zen_settings['custom_expands']) == 4 if has_key(s:emmet_settings, 'custom_expands') && type(s:emmet_settings['custom_expands']) == 4
for k in keys(s:zen_settings['custom_expands']) for k in keys(s:emmet_settings['custom_expands'])
if key =~ k if key =~ k
let V = get(s:zen_settings['custom_expands'], k) let V = get(s:emmet_settings['custom_expands'], k)
if type(V) == 1 | return V | endif if type(V) == 1 | return V | endif
if type(V) == 2 | return V(key) | endif if type(V) == 2 | return V(key) | endif
endif endif
@@ -340,9 +341,9 @@ function! zencoding#getDollarValueByKey(key)
return ret return ret
endfunction endfunction
function! zencoding#reExpandDollarExpr(expand, times) function! emmet#reExpandDollarExpr(expand, times)
let expand = a:expand let expand = a:expand
let dollar_exprs = zencoding#getDollarExprs(expand) let dollar_exprs = emmet#getDollarExprs(expand)
if len(dollar_exprs) > 0 if len(dollar_exprs) > 0
if a:times < 9 if a:times < 9
for n in range(len(dollar_exprs)) for n in range(len(dollar_exprs))
@@ -351,20 +352,20 @@ function! zencoding#reExpandDollarExpr(expand, times)
let sub = get(pair, 'value') let sub = get(pair, 'value')
let expand = substitute(expand, pat, sub, '') let expand = substitute(expand, pat, sub, '')
endfor endfor
return zencoding#reExpandDollarExpr(expand, a:times + 1) return emmet#reExpandDollarExpr(expand, a:times + 1)
endif endif
endif endif
return expand return expand
endfunction endfunction
function! zencoding#expandDollarExpr(expand) function! emmet#expandDollarExpr(expand)
return zencoding#reExpandDollarExpr(a:expand, 0) return emmet#reExpandDollarExpr(a:expand, 0)
endfunction endfunction
function! zencoding#expandCursorExpr(expand, mode) function! emmet#expandCursorExpr(expand, mode)
let expand = a:expand let expand = a:expand
let type = zencoding#getFileType() let type = emmet#getFileType()
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1) let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
if use_pipe_for_cursor if use_pipe_for_cursor
let expand = substitute(expand, '|', '${cursor}', 'g') let expand = substitute(expand, '|', '${cursor}', 'g')
endif endif
@@ -380,22 +381,22 @@ function! zencoding#expandCursorExpr(expand, mode)
return expand return expand
endfunction endfunction
function! zencoding#unescapeDollarExpr(expand) function! emmet#unescapeDollarExpr(expand)
return substitute(a:expand, '\\\$', '$', 'g') return substitute(a:expand, '\\\$', '$', 'g')
endfunction endfunction
function! zencoding#expandAbbr(mode, abbr) range function! emmet#expandAbbr(mode, abbr) range
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#getFileType(1) let rtype = emmet#getFileType(1)
let indent = zencoding#getIndentation(type) let indent = emmet#getIndentation(type)
let expand = '' let expand = ''
let filters = ['html'] let filters = ['html']
let line = '' let line = ''
let part = '' let part = ''
let rest = '' let rest = ''
if has_key(s:zen_settings, type) && has_key(s:zen_settings[type], 'filters') if has_key(s:emmet_settings, type) && has_key(s:emmet_settings[type], 'filters')
let filters = split(s:zen_settings[type].filters, '\s*,\s*') let filters = split(s:emmet_settings[type].filters, '\s*,\s*')
endif endif
if a:mode == 2 if a:mode == 2
@@ -413,16 +414,16 @@ function! zencoding#expandAbbr(mode, abbr) range
if query !~ '}\s*$' if query !~ '}\s*$'
let query .= '>{$#}' let query .= '>{$#}'
endif endif
if zencoding#useFilter(filters, '/') if emmet#useFilter(filters, '/')
let spl = zencoding#splitFilterArg(filters) let spl = emmet#splitFilterArg(filters)
let fline = getline(a:firstline) let fline = getline(a:firstline)
let query = substitute(query, '>\{0,1}{\$#}\s*$', '{\\$column\\$}*' . len(split(fline, spl)), '') let query = substitute(query, '>\{0,1}{\$#}\s*$', '{\\$column\\$}*' . len(split(fline, spl)), '')
endif endif
let items = zencoding#parseIntoTree(query, type).child let items = emmet#parseIntoTree(query, type).child
for item in items for item in items
let expand .= zencoding#toString(item, type, 0, filters, 0, indent) let expand .= emmet#toString(item, type, 0, filters, 0, indent)
endfor endfor
if zencoding#useFilter(filters, 'e') if emmet#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')
let expand = substitute(expand, '<', '\&lt;', 'g') let expand = substitute(expand, '<', '\&lt;', 'g')
let expand = substitute(expand, '>', '\&gt;', 'g') let expand = substitute(expand, '>', '\&gt;', 'g')
@@ -432,11 +433,11 @@ function! zencoding#expandAbbr(mode, abbr) range
for n in range(a:firstline, a:lastline) for n in range(a:firstline, a:lastline)
let lline = getline(n) let lline = getline(n)
let lpart = substitute(lline, '^\s\+', '', '') let lpart = substitute(lline, '^\s\+', '', '')
if zencoding#useFilter(filters, 't') if emmet#useFilter(filters, 't')
let lpart = substitute(lpart, '^[0-9.-]\+\s\+', '', '') let lpart = substitute(lpart, '^[0-9.-]\+\s\+', '', '')
let lpart = substitute(lpart, '\s\+$', '', '') let lpart = substitute(lpart, '\s\+$', '', '')
endif endif
if zencoding#useFilter(filters, '/') if emmet#useFilter(filters, '/')
for column in split(lpart, spl) for column in split(lpart, spl)
let expand = substitute(expand, '\$column\$', '\=column', '') let expand = substitute(expand, '\$column\$', '\=column', '')
endfor endfor
@@ -465,19 +466,19 @@ function! zencoding#expandAbbr(mode, abbr) range
endif endif
endfor endfor
let leader .= (str =~ "\n" ? ">{\n" : "{") . str . "}" let leader .= (str =~ "\n" ? ">{\n" : "{") . str . "}"
let items = zencoding#parseIntoTree(leader, type).child let items = emmet#parseIntoTree(leader, type).child
else else
let save_regcont = @" let save_regcont = @"
let save_regtype = getregtype('"') let save_regtype = getregtype('"')
silent! normal! gvygv silent! normal! gvygv
let str = @" let str = @"
call setreg('"', save_regcont, save_regtype) call setreg('"', save_regcont, save_regtype)
let items = zencoding#parseIntoTree(leader . "{".str."}", type).child let items = emmet#parseIntoTree(leader . "{".str."}", type).child
endif endif
for item in items for item in items
let expand .= zencoding#toString(item, type, 0, filters, 0, '') let expand .= emmet#toString(item, type, 0, filters, 0, '')
endfor endfor
if zencoding#useFilter(filters, 'e') if emmet#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')
let expand = substitute(expand, '<', '\&lt;', 'g') let expand = substitute(expand, '<', '\&lt;', 'g')
let expand = substitute(expand, '>', '\&gt;', 'g') let expand = substitute(expand, '>', '\&gt;', 'g')
@@ -492,7 +493,7 @@ function! zencoding#expandAbbr(mode, abbr) range
call setline('.', spaces.a:abbr) call setline('.', spaces.a:abbr)
endif endif
normal! $ normal! $
call zencoding#expandAbbr(0, "") call emmet#expandAbbr(0, "")
return return
else else
let line = getline('.') let line = getline('.')
@@ -503,8 +504,8 @@ function! zencoding#expandAbbr(mode, abbr) range
let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$') let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$')
else else
let part = matchstr(line, '\(\S.*\)$') let part = matchstr(line, '\(\S.*\)$')
let ftype = zencoding#lang#exists(type) ? type : 'html' let ftype = emmet#lang#exists(type) ? type : 'html'
let part = zencoding#lang#{ftype}#findTokens(part) let part = emmet#lang#{ftype}#findTokens(part)
endif endif
let rest = getline('.')[len(line):] let rest = getline('.')[len(line):]
let str = part let str = part
@@ -513,27 +514,27 @@ function! zencoding#expandAbbr(mode, abbr) range
let filters = split(matchstr(str, mx)[1:], '\s*,\s*') let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
let str = substitute(str, mx, '', '') let str = substitute(str, mx, '', '')
endif endif
let items = zencoding#parseIntoTree(str, rtype).child let items = emmet#parseIntoTree(str, rtype).child
for item in items for item in items
let expand .= zencoding#toString(item, rtype, 0, filters, 0, indent) let expand .= emmet#toString(item, rtype, 0, filters, 0, indent)
endfor endfor
if zencoding#useFilter(filters, 'e') if emmet#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')
let expand = substitute(expand, '<', '\&lt;', 'g') let expand = substitute(expand, '<', '\&lt;', 'g')
let expand = substitute(expand, '>', '\&gt;', 'g') let expand = substitute(expand, '>', '\&gt;', 'g')
endif endif
let expand = substitute(expand, '\$line\([0-9]\+\)\$', '\=submatch(1)', 'g') let expand = substitute(expand, '\$line\([0-9]\+\)\$', '\=submatch(1)', 'g')
endif endif
let expand = zencoding#expandDollarExpr(expand) let expand = emmet#expandDollarExpr(expand)
let expand = zencoding#expandCursorExpr(expand, a:mode) let expand = emmet#expandCursorExpr(expand, a:mode)
if len(expand) if len(expand)
if has_key(s:zen_settings, 'timezone') && len(s:zen_settings.timezone) 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:zen_settings.timezone, 'g') let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S") . s:emmet_settings.timezone, 'g')
else else
" TODO: on windows, %z/%Z is 'Tokyo(Standard)' " TODO: on windows, %z/%Z is 'Tokyo(Standard)'
let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S %z"), 'g') let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S %z"), 'g')
endif endif
let expand = zencoding#unescapeDollarExpr(expand) let expand = emmet#unescapeDollarExpr(expand)
if a:mode == 2 && visualmode() ==# 'v' if a:mode == 2 && visualmode() ==# 'v'
if a:firstline == a:lastline if a:firstline == a:lastline
let expand = substitute(expand, '\n\s*', '', 'g') let expand = substitute(expand, '\n\s*', '', 'g')
@@ -577,115 +578,115 @@ function! zencoding#expandAbbr(mode, abbr) range
silent! exe "normal! v7h\"_s" silent! exe "normal! v7h\"_s"
let &selection = oldselection let &selection = oldselection
endif endif
if g:zencoding_debug > 1 if g:emmet_debug > 1
call getchar() call getchar()
endif endif
endfunction endfunction
function! zencoding#moveNextPrev(flag) function! emmet#moveNextPrev(flag)
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#moveNextPrev(a:flag) return emmet#lang#{rtype}#moveNextPrev(a:flag)
endfunction endfunction
function! zencoding#imageSize() function! emmet#imageSize()
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#imageSize() return emmet#lang#{rtype}#imageSize()
endfunction endfunction
function! zencoding#encodeImage() function! emmet#encodeImage()
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#encodeImage() return emmet#lang#{rtype}#encodeImage()
endfunction endfunction
function! zencoding#toggleComment() function! emmet#toggleComment()
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#toggleComment() return emmet#lang#{rtype}#toggleComment()
endfunction endfunction
function! zencoding#balanceTag(flag) range function! emmet#balanceTag(flag) range
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#balanceTag(a:flag) return emmet#lang#{rtype}#balanceTag(a:flag)
endfunction endfunction
function! zencoding#splitJoinTag() function! emmet#splitJoinTag()
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#splitJoinTag() return emmet#lang#{rtype}#splitJoinTag()
endfunction endfunction
function! zencoding#mergeLines() range function! emmet#mergeLines() range
let lines = join(map(getline(a:firstline, a:lastline), 'matchstr(v:val, "^\\s*\\zs.*\\ze\\s*$")'), '') let lines = join(map(getline(a:firstline, a:lastline), 'matchstr(v:val, "^\\s*\\zs.*\\ze\\s*$")'), '')
let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '') let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '')
silent! exe "normal! gvc" silent! exe "normal! gvc"
call setline('.', indent . lines) call setline('.', indent . lines)
endfunction endfunction
function! zencoding#removeTag() function! emmet#removeTag()
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
return zencoding#lang#{rtype}#removeTag() return emmet#lang#{rtype}#removeTag()
endfunction endfunction
function! zencoding#anchorizeURL(flag) function! emmet#anchorizeURL(flag)
let mx = 'https\=:\/\/[-!#$%&*+,./:;=?@0-9a-zA-Z_~]\+' let mx = 'https\=:\/\/[-!#$%&*+,./:;=?@0-9a-zA-Z_~]\+'
let pos1 = searchpos(mx, 'bcnW') let pos1 = searchpos(mx, 'bcnW')
let url = matchstr(getline(pos1[0])[pos1[1]-1:], mx) let url = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
let block = [pos1, [pos1[0], pos1[1] + len(url) - 1]] let block = [pos1, [pos1[0], pos1[1] + len(url) - 1]]
if !zencoding#util#cursorInRegion(block) if !emmet#util#cursorInRegion(block)
return return
endif endif
let mx = '.*<title[^>]*>\s*\zs\([^<]\+\)\ze\s*<\/title[^>]*>.*' let mx = '.*<title[^>]*>\s*\zs\([^<]\+\)\ze\s*<\/title[^>]*>.*'
let content = zencoding#util#getContentFromURL(url) let content = emmet#util#getContentFromURL(url)
let content = substitute(content, '\r', '', 'g') let content = substitute(content, '\r', '', 'g')
let content = substitute(content, '[ \n]\+', ' ', 'g') let content = substitute(content, '[ \n]\+', ' ', 'g')
let content = substitute(content, '<!--.\{-}-->', '', 'g') let content = substitute(content, '<!--.\{-}-->', '', 'g')
let title = matchstr(content, mx) let title = matchstr(content, mx)
let type = zencoding#getFileType() let type = emmet#getFileType()
let rtype = zencoding#lang#exists(type) ? type : 'html' let rtype = emmet#lang#exists(type) ? type : 'html'
if a:flag == 0 if a:flag == 0
let a = zencoding#lang#html#parseTag('<a>') let a = emmet#lang#html#parseTag('<a>')
let a.attr.href = url let a.attr.href = url
let a.value = '{' . title . '}' let a.value = '{' . title . '}'
let expand = zencoding#toString(a, rtype, 0, []) let expand = emmet#toString(a, rtype, 0, [])
let expand = substitute(expand, '\${cursor}', '', 'g') let expand = substitute(expand, '\${cursor}', '', 'g')
else else
let body = zencoding#util#getTextFromHTML(content) let body = emmet#util#getTextFromHTML(content)
let body = '{' . substitute(body, '^\(.\{0,100}\).*', '\1', '') . '...}' let body = '{' . substitute(body, '^\(.\{0,100}\).*', '\1', '') . '...}'
let blockquote = zencoding#lang#html#parseTag('<blockquote class="quote">') let blockquote = emmet#lang#html#parseTag('<blockquote class="quote">')
let a = zencoding#lang#html#parseTag('<a>') let a = emmet#lang#html#parseTag('<a>')
let a.attr.href = url let a.attr.href = url
let a.value = '{' . title . '}' let a.value = '{' . title . '}'
call add(blockquote.child, a) call add(blockquote.child, a)
call add(blockquote.child, zencoding#lang#html#parseTag('<br/>')) call add(blockquote.child, emmet#lang#html#parseTag('<br/>'))
let p = zencoding#lang#html#parseTag('<p>') let p = emmet#lang#html#parseTag('<p>')
let p.value = body let p.value = body
call add(blockquote.child, p) call add(blockquote.child, p)
let cite = zencoding#lang#html#parseTag('<cite>') let cite = emmet#lang#html#parseTag('<cite>')
let cite.value = '{' . url . '}' let cite.value = '{' . url . '}'
call add(blockquote.child, cite) call add(blockquote.child, cite)
let expand = zencoding#toString(blockquote, rtype, 0, []) let expand = emmet#toString(blockquote, rtype, 0, [])
let expand = substitute(expand, '\${cursor}', '', 'g') let expand = substitute(expand, '\${cursor}', '', 'g')
endif endif
let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '') let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '')
let expand = substitute(expand, "\n", "\n" . indent, 'g') let expand = substitute(expand, "\n", "\n" . indent, 'g')
call zencoding#util#setContent(block, expand) call emmet#util#setContent(block, expand)
endfunction endfunction
function! zencoding#codePretty() range function! emmet#codePretty() range
let type = input('FileType: ', &ft, 'filetype') let type = input('FileType: ', &ft, 'filetype')
if len(type) == 0 if len(type) == 0
return return
endif endif
let block = zencoding#util#getVisualBlock() let block = emmet#util#getVisualBlock()
let content = zencoding#util#getContent(block) let content = emmet#util#getContent(block)
silent! 1new silent! 1new
let &l:filetype = type let &l:filetype = type
call setline(1, split(content, "\n")) call setline(1, split(content, "\n"))
@@ -697,50 +698,50 @@ function! zencoding#codePretty() range
silent! bw! silent! bw!
silent! bw! silent! bw!
let content = matchstr(content, '<body[^>]*>[\s\n]*\zs.*\ze</body>') let content = matchstr(content, '<body[^>]*>[\s\n]*\zs.*\ze</body>')
call zencoding#util#setContent(block, content) call emmet#util#setContent(block, content)
endfunction endfunction
function! zencoding#ExpandWord(abbr, type, orig) function! emmet#ExpandWord(abbr, type, orig)
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$' let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
let str = a:abbr let str = a:abbr
let type = a:type let type = a:type
let indent = zencoding#getIndentation(type) let indent = emmet#getIndentation(type)
if len(type) == 0 | let type = 'html' | endif if len(type) == 0 | let type = 'html' | endif
if str =~ mx if str =~ mx
let filters = split(matchstr(str, mx)[1:], '\s*,\s*') let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
let str = substitute(str, mx, '', '') let str = substitute(str, mx, '', '')
elseif has_key(s:zen_settings[a:type], 'filters') elseif has_key(s:emmet_settings[a:type], 'filters')
let filters = split(s:zen_settings[a:type].filters, '\s*,\s*') let filters = split(s:emmet_settings[a:type].filters, '\s*,\s*')
else else
let filters = ['html'] let filters = ['html']
endif endif
let items = zencoding#parseIntoTree(str, a:type).child let items = emmet#parseIntoTree(str, a:type).child
let expand = '' let expand = ''
for item in items for item in items
let expand .= zencoding#toString(item, a:type, 0, filters, 0, indent) let expand .= emmet#toString(item, a:type, 0, filters, 0, indent)
endfor endfor
if zencoding#useFilter(filters, 'e') if emmet#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')
let expand = substitute(expand, '<', '\&lt;', 'g') let expand = substitute(expand, '<', '\&lt;', 'g')
let expand = substitute(expand, '>', '\&gt;', 'g') let expand = substitute(expand, '>', '\&gt;', 'g')
endif endif
if a:orig == 0 if a:orig == 0
let expand = zencoding#expandDollarExpr(expand) let expand = emmet#expandDollarExpr(expand)
let expand = substitute(expand, '\${cursor}', '', 'g') let expand = substitute(expand, '\${cursor}', '', 'g')
endif endif
return expand return expand
endfunction endfunction
function! zencoding#getSnippets(type) function! emmet#getSnippets(type)
let type = a:type let type = a:type
if len(type) == 0 || !has_key(s:zen_settings, type) if len(type) == 0 || !has_key(s:emmet_settings, type)
let type = 'html' let type = 'html'
endif endif
return zencoding#getResource(type, 'snippets', {}) return emmet#getResource(type, 'snippets', {})
endfunction endfunction
function! zencoding#CompleteTag(findstart, base) function! emmet#CompleteTag(findstart, base)
if a:findstart if a:findstart
let line = getline('.') let line = getline('.')
let start = col('.') - 1 let start = col('.') - 1
@@ -749,16 +750,16 @@ function! zencoding#CompleteTag(findstart, base)
endwhile endwhile
return start return start
else else
let type = zencoding#getFileType() let type = emmet#getFileType()
let res = [] let res = []
let snippets = zencoding#getResource(type, 'snippets', {}) let snippets = emmet#getResource(type, 'snippets', {})
for item in keys(snippets) for item in keys(snippets)
if stridx(item, a:base) != -1 if stridx(item, a:base) != -1
call add(res, substitute(item, '\${cursor}\||', '', 'g')) call add(res, substitute(item, '\${cursor}\||', '', 'g'))
endif endif
endfor endfor
let aliases = zencoding#getResource(type, 'aliases', {}) let aliases = emmet#getResource(type, 'aliases', {})
for item in values(aliases) for item in values(aliases)
if stridx(item, a:base) != -1 if stridx(item, a:base) != -1
call add(res, substitute(item, '\${cursor}\||', '', 'g')) call add(res, substitute(item, '\${cursor}\||', '', 'g'))
@@ -768,12 +769,12 @@ function! zencoding#CompleteTag(findstart, base)
endif endif
endfunction endfunction
unlet! s:zen_settings unlet! s:emmet_settings
let s:zen_settings = { let s:emmet_settings = {
\ 'lang': "en", \ 'lang': "en",
\ 'charset': "UTF-8", \ 'charset': "UTF-8",
\ 'custom_expands' : { \ 'custom_expands' : {
\ '^\%(lorem\|lipsum\)\(\d*\)$' : function('zencoding#lorem#en#expand'), \ '^\%(lorem\|lipsum\)\(\d*\)$' : function('emmet#lorem#en#expand'),
\ }, \ },
\ 'css': { \ 'css': {
\ 'snippets': { \ 'snippets': {
@@ -1275,6 +1276,7 @@ let s:zen_settings = {
\ 'extends': 'css', \ 'extends': 'css',
\ }, \ },
\ 'html': { \ 'html': {
\ 'indentation': "\t",
\ 'snippets': { \ 'snippets': {
\ 'cc:ie6': "<!--[if lte IE 6]>\n\t${child}|\n<![endif]-->", \ 'cc:ie6': "<!--[if lte IE 6]>\n\t${child}|\n<![endif]-->",
\ 'cc:ie': "<!--[if IE]>\n\t${child}|\n<![endif]-->", \ 'cc:ie': "<!--[if IE]>\n\t${child}|\n<![endif]-->",
@@ -1563,8 +1565,8 @@ let s:zen_settings = {
\ } \ }
\} \}
if exists('g:user_zen_settings') if exists('g:user_emmet_settings')
call zencoding#mergeConfig(s:zen_settings, g:user_zen_settings) call emmet#mergeConfig(s:emmet_settings, g:user_emmet_settings)
endif endif
let &cpo = s:save_cpo let &cpo = s:save_cpo

View File

@@ -1,11 +1,11 @@
let s:exists = {} let s:exists = {}
function zencoding#lang#exists(type) function! emmet#lang#exists(type)
if len(a:type) == 0 if len(a:type) == 0
return 0 return 0
elseif has_key(s:exists, a:type) elseif has_key(s:exists, a:type)
return s:exists[a:type] return s:exists[a:type]
endif endif
let s:exists[a:type] = len(globpath(&rtp, 'autoload/zencoding/lang/'.a:type.'.vim')) > 0 let s:exists[a:type] = len(globpath(&rtp, 'autoload/emmet/lang/'.a:type.'.vim')) > 0
return s:exists[a:type] return s:exists[a:type]
endfunction endfunction

View File

@@ -1,18 +1,18 @@
function! zencoding#lang#css#findTokens(str) function! emmet#lang#css#findTokens(str)
return substitute(a:str, '^.*[;{]\s*', '', '') return substitute(a:str, '^.*[;{]\s*', '', '')
endfunction endfunction
function! zencoding#lang#css#parseIntoTree(abbr, type) function! emmet#lang#css#parseIntoTree(abbr, type)
let abbr = a:abbr let abbr = a:abbr
let type = a:type let type = a:type
let prefix = 0 let prefix = 0
let value = '' let value = ''
let settings = zencoding#getSettings() let settings = emmet#getSettings()
let indent = zencoding#getIndentation(type) let indent = emmet#getIndentation(type)
let aliases = zencoding#getResource(type, 'aliases', {}) let aliases = emmet#getResource(type, 'aliases', {})
let snippets = zencoding#getResource(type, 'snippets', {}) let snippets = emmet#getResource(type, 'snippets', {})
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1) let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 } let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
@@ -115,10 +115,10 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
return root return root
endfunction endfunction
function! zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent) function! emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
let current = a:current let current = a:current
let value = current.value[1:-2] let value = current.value[1:-2]
if zencoding#useFilter(a:filters, 'fc') if emmet#useFilter(a:filters, 'fc')
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1: \2', 'g') let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1: \2', 'g')
else else
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1:\2', 'g') let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1:\2', 'g')
@@ -129,25 +129,25 @@ function! zencoding#lang#css#toString(settings, current, type, inline, filters,
return value return value
endfunction endfunction
function! zencoding#lang#css#imageSize() function! emmet#lang#css#imageSize()
endfunction endfunction
function! zencoding#lang#css#encodeImage() function! emmet#lang#css#encodeImage()
endfunction endfunction
function! zencoding#lang#css#parseTag(tag) function! emmet#lang#css#parseTag(tag)
return {} return {}
endfunction endfunction
function! zencoding#lang#css#toggleComment() function! emmet#lang#css#toggleComment()
let line = getline('.') let line = getline('.')
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$' let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
if line =~ '{\s*$' if line =~ '{\s*$'
let block = zencoding#util#searchRegion('/\*', '\*/\zs') let block = emmet#util#searchRegion('/\*', '\*/\zs')
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
let content = zencoding#util#getContent(block) let content = emmet#util#getContent(block)
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '') let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
call zencoding#util#setContent(block, content) call emmet#util#setContent(block, content)
else else
let node = expand('<cword>') let node = expand('<cword>')
if len(node) if len(node)
@@ -167,28 +167,28 @@ function! zencoding#lang#css#toggleComment()
endif endif
endfunction endfunction
function! zencoding#lang#css#balanceTag(flag) range function! emmet#lang#css#balanceTag(flag) range
if a:flag == -2 || a:flag == 2 if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0] let curpos = [0, line("'<"), col("'<"), 0]
else else
let curpos = getpos('.') let curpos = getpos('.')
endif endif
let block = zencoding#util#getVisualBlock() let block = emmet#util#getVisualBlock()
if !zencoding#util#regionIsValid(block) if !emmet#util#regionIsValid(block)
if a:flag > 0 if a:flag > 0
let block = zencoding#util#searchRegion('^', ';') let block = emmet#util#searchRegion('^', ';')
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
call zencoding#util#selectRegion(block) call emmet#util#selectRegion(block)
return return
endif endif
endif endif
else else
if a:flag > 0 if a:flag > 0
let content = zencoding#util#getContent(block) let content = emmet#util#getContent(block)
if content !~ '^{.*}$' if content !~ '^{.*}$'
let block = zencoding#util#searchRegion('{', '}') let block = emmet#util#searchRegion('{', '}')
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
call zencoding#util#selectRegion(block) call emmet#util#selectRegion(block)
return return
endif endif
endif endif
@@ -196,9 +196,9 @@ function! zencoding#lang#css#balanceTag(flag) range
let pos = searchpos('.*;', 'nW') let pos = searchpos('.*;', 'nW')
if pos[0] != 0 if pos[0] != 0
call setpos('.', [0, pos[0], pos[1], 0]) call setpos('.', [0, pos[0], pos[1], 0])
let block = zencoding#util#searchRegion('^', ';') let block = emmet#util#searchRegion('^', ';')
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
call zencoding#util#selectRegion(block) call emmet#util#selectRegion(block)
return return
endif endif
endif endif
@@ -211,7 +211,7 @@ function! zencoding#lang#css#balanceTag(flag) range
endif endif
endfunction endfunction
function! zencoding#lang#css#moveNextPrev(flag) function! emmet#lang#css#moveNextPrev(flag)
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp') let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
if pos == 2 if pos == 2
startinsert! startinsert!
@@ -221,10 +221,10 @@ function! zencoding#lang#css#moveNextPrev(flag)
endif endif
endfunction endfunction
function! zencoding#lang#css#splitJoinTag() function! emmet#lang#css#splitJoinTag()
" nothing to do " nothing to do
endfunction endfunction
function! zencoding#lang#css#removeTag() function! emmet#lang#css#removeTag()
" nothing to do " nothing to do
endfunction endfunction

View File

@@ -1,20 +1,20 @@
function! zencoding#lang#haml#findTokens(str) function! emmet#lang#haml#findTokens(str)
return zencoding#lang#html#findTokens(a:str) return emmet#lang#html#findTokens(a:str)
endfunction endfunction
function! zencoding#lang#haml#parseIntoTree(abbr, type) function! emmet#lang#haml#parseIntoTree(abbr, type)
return zencoding#lang#html#parseIntoTree(a:abbr, a:type) return emmet#lang#html#parseIntoTree(a:abbr, a:type)
endfunction endfunction
function! zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) function! emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings let settings = a:settings
let current = a:current let current = a:current
let type = a:type let type = a:type
let inline = a:inline let inline = a:inline
let filters = a:filters let filters = a:filters
let itemno = a:itemno let itemno = a:itemno
let indent = zencoding#getIndentation(type) let indent = emmet#getIndentation(type)
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
let str = "" let str = ""
let comment_indent = '' let comment_indent = ''
@@ -26,7 +26,7 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
if len(current.name) > 0 if len(current.name) > 0
let str .= '%' . current_name let str .= '%' . current_name
let tmp = '' let tmp = ''
for attr in zencoding#util#unique(current.attrs_order + keys(current.attr)) for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
if !has_key(current.attr, attr) if !has_key(current.attr, attr)
continue continue
endif endif
@@ -92,7 +92,7 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
endif endif
elseif len(current.child) > 0 elseif len(current.child) > 0
for child in current.child for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno, indent) let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
endfor endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
@@ -110,9 +110,9 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
return str return str
endfunction endfunction
function! zencoding#lang#haml#imageSize() function! emmet#lang#haml#imageSize()
let line = getline('.') let line = getline('.')
let current = zencoding#lang#haml#parseTag(line) let current = emmet#lang#haml#parseTag(line)
if empty(current) || !has_key(current.attr, 'src') if empty(current) || !has_key(current.attr, 'src')
return return
endif endif
@@ -123,22 +123,22 @@ function! zencoding#lang#haml#imageSize()
let fn = simplify(expand('%:h') . '/' . fn) let fn = simplify(expand('%:h') . '/' . fn)
endif endif
let [width, height] = zencoding#util#getImageSize(fn) let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1 if width == -1 && height == -1
return return
endif endif
let current.attr.width = width let current.attr.width = width
let current.attr.height = height let current.attr.height = height
let current.attrs_order += ['width', 'height'] let current.attrs_order += ['width', 'height']
let haml = zencoding#toString(current, 'haml', 1) let haml = emmet#toString(current, 'haml', 1)
let haml = substitute(haml, '\${cursor}', '', '') let haml = substitute(haml, '\${cursor}', '', '')
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", "", "g")) call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", "", "g"))
endfunction endfunction
function! zencoding#lang#haml#encodeImage() function! emmet#lang#haml#encodeImage()
endfunction endfunction
function! zencoding#lang#haml#parseTag(tag) function! emmet#lang#haml#parseTag(tag)
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] } let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] }
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)' let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
let match = matchstr(a:tag, mx) let match = matchstr(a:tag, mx)
@@ -160,7 +160,7 @@ function! zencoding#lang#haml#parseTag(tag)
return current return current
endfunction endfunction
function! zencoding#lang#haml#toggleComment() function! emmet#lang#haml#toggleComment()
let line = getline('.') let line = getline('.')
let space = matchstr(line, '^\s*') let space = matchstr(line, '^\s*')
if line =~ '^\s*-#' if line =~ '^\s*-#'
@@ -170,8 +170,8 @@ function! zencoding#lang#haml#toggleComment()
endif endif
endfunction endfunction
function! zencoding#lang#haml#balanceTag(flag) range function! emmet#lang#haml#balanceTag(flag) range
let block = zencoding#util#getVisualBlock() let block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2 if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0] let curpos = [0, line("'<"), col("'<"), 0]
else else
@@ -181,7 +181,7 @@ function! zencoding#lang#haml#balanceTag(flag) range
let ml = len(matchstr(getline(n), '^\s*')) let ml = len(matchstr(getline(n), '^\s*'))
if a:flag > 0 if a:flag > 0
if a:flag == 1 || !zencoding#util#regionIsValid(block) if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.') let n = line('.')
else else
while n > 0 while n > 0
@@ -235,7 +235,7 @@ function! zencoding#lang#haml#balanceTag(flag) range
endif endif
endfunction endfunction
function! zencoding#lang#haml#moveNextPrev(flag) function! emmet#lang#haml#moveNextPrev(flag)
let pos = search('""', a:flag ? 'Wb' : 'W') let pos = search('""', a:flag ? 'Wb' : 'W')
if pos != 0 if pos != 0
silent! normal! l silent! normal! l
@@ -243,7 +243,7 @@ function! zencoding#lang#haml#moveNextPrev(flag)
endif endif
endfunction endfunction
function! zencoding#lang#haml#splitJoinTag() function! emmet#lang#haml#splitJoinTag()
let n = line('.') let n = line('.')
let sml = len(matchstr(getline(n), '^\s*%[a-z]')) let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
while n > 0 while n > 0
@@ -268,7 +268,7 @@ function! zencoding#lang#haml#splitJoinTag()
else else
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)') let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
let spaces = matchstr(getline(sn), '^\s*') let spaces = matchstr(getline(sn), '^\s*')
let settings = zencoding#getSettings() let settings = emmet#getSettings()
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1 if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
call append(sn, spaces . ' ') call append(sn, spaces . ' ')
call setpos('.', [0, sn+1, 1, 0]) call setpos('.', [0, sn+1, 1, 0])
@@ -283,7 +283,7 @@ function! zencoding#lang#haml#splitJoinTag()
endwhile endwhile
endfunction endfunction
function! zencoding#lang#haml#removeTag() function! emmet#lang#haml#removeTag()
let n = line('.') let n = line('.')
let ml = 0 let ml = 0
while n > 0 while n > 0

View File

@@ -12,7 +12,7 @@ let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
\ .'\%(\*\([0-9]\+\)\)\{0,1}' \ .'\%(\*\([0-9]\+\)\)\{0,1}'
\ .'\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)' \ .'\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)'
function! zencoding#lang#html#findTokens(str) function! emmet#lang#html#findTokens(str)
let str = a:str let str = a:str
let [pos, last_pos] = [0, 0] let [pos, last_pos] = [0, 0]
while 1 while 1
@@ -37,24 +37,24 @@ function! zencoding#lang#html#findTokens(str)
return a:str[last_pos :-1] return a:str[last_pos :-1]
endfunction endfunction
function! zencoding#lang#html#parseIntoTree(abbr, type) function! emmet#lang#html#parseIntoTree(abbr, type)
let abbr = a:abbr let abbr = a:abbr
let type = a:type let type = a:type
let settings = zencoding#getSettings() let settings = emmet#getSettings()
if !has_key(settings, type) if !has_key(settings, type)
let type = 'html' let type = 'html'
endif endif
if len(type) == 0 | let type = 'html' | endif if len(type) == 0 | let type = 'html' | endif
let settings = zencoding#getSettings() let settings = emmet#getSettings()
let indent = zencoding#getIndentation(type) let indent = emmet#getIndentation(type)
" try 'foo' to (foo-x) " try 'foo' to (foo-x)
let rabbr = zencoding#getExpandos(type, abbr) let rabbr = emmet#getExpandos(type, abbr)
if rabbr == abbr if rabbr == abbr
" try 'foo+(' to (foo-x) " try 'foo+(' to (foo-x)
let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".zencoding#getExpandos(type, submatch(1)).")".submatch(2)', 'i') let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".emmet#getExpandos(type, submatch(1)).")".submatch(2)', 'i')
endif endif
let abbr = rabbr let abbr = rabbr
@@ -98,15 +98,15 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
let current.important = important let current.important = important
" aliases " aliases
let aliases = zencoding#getResource(type, 'aliases', {}) let aliases = emmet#getResource(type, 'aliases', {})
if has_key(aliases, tag_name) if has_key(aliases, tag_name)
let current.name = aliases[tag_name] let current.name = aliases[tag_name]
endif endif
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1) let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
" snippets " snippets
let snippets = zencoding#getResource(type, 'snippets', {}) let snippets = emmet#getResource(type, 'snippets', {})
if !empty(snippets) && has_key(snippets, tag_name) if !empty(snippets) && has_key(snippets, tag_name)
let snippet = snippets[tag_name] let snippet = snippets[tag_name]
if use_pipe_for_cursor if use_pipe_for_cursor
@@ -118,16 +118,16 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
let current.name = '' let current.name = ''
endif endif
let custom_expands = zencoding#getResource(type, 'custom_expands', {}) let custom_expands = emmet#getResource(type, 'custom_expands', {})
if empty(custom_expands) && has_key(settings, 'custom_expands') if empty(custom_expands) && has_key(settings, 'custom_expands')
let custom_expands = settings['custom_expands'] let custom_expands = settings['custom_expands']
endif endif
for k in keys(custom_expands) for k in keys(custom_expands)
if tag_name =~ k if tag_name =~ k
if parent.name == '' if parent.name == ''
let div = zencoding#lang#html#parseTag('<div/>') let div = emmet#lang#html#parseTag('<div/>')
let div.value = '{\${' . tag_name . '}}' let div.value = '{\${' . tag_name . '}}'
let current.snippet = zencoding#toString(div, type, 0, []) let current.snippet = emmet#toString(div, type, 0, [])
else else
let current.snippet = '${' . tag_name . '}' let current.snippet = '${' . tag_name . '}'
endif endif
@@ -137,7 +137,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
endfor endfor
" default_attributes " default_attributes
let default_attributes = zencoding#getResource(type, 'default_attributes', {}) let default_attributes = emmet#getResource(type, 'default_attributes', {})
if !empty(default_attributes) if !empty(default_attributes)
for pat in [current.name, tag_name] for pat in [current.name, tag_name]
if has_key(default_attributes, pat) if has_key(default_attributes, pat)
@@ -288,7 +288,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
endif endif
let abbr = abbr[stridx(abbr, match) + len(match):] let abbr = abbr[stridx(abbr, match) + len(match):]
if g:zencoding_debug > 1 if g:emmet_debug > 1
echomsg "str=".str echomsg "str=".str
echomsg "block_start=".block_start echomsg "block_start=".block_start
echomsg "tag_name=".tag_name echomsg "tag_name=".tag_name
@@ -305,7 +305,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
return root return root
endfunction endfunction
function! zencoding#lang#html#toString(settings, current, type, inline, filters, itemno, indent) function! emmet#lang#html#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings let settings = a:settings
let current = a:current let current = a:current
let type = a:type let type = a:type
@@ -313,13 +313,13 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
let filters = a:filters let filters = a:filters
let itemno = a:itemno let itemno = a:itemno
let indent = a:indent let indent = a:indent
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
if zencoding#useFilter(filters, 'haml') if emmet#useFilter(filters, 'haml')
return zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) return emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
endif endif
if zencoding#useFilter(filters, 'slim') if emmet#useFilter(filters, 'slim')
return zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) return emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
endif endif
let comment = '' let comment = ''
@@ -332,7 +332,8 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
if len(current_name) == 0 if len(current_name) == 0
let text = current.value[1:-2] let text = current.value[1:-2]
if dollar_expr if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') " TODO: regexp engine specified
let text = substitute(text, '\%#=1\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g') let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g') let text = substitute(text, '\\\$', '$', 'g')
endif endif
@@ -340,19 +341,20 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
endif endif
if len(current_name) > 0 if len(current_name) > 0
let str .= '<' . current_name let str .= '<' . current_name
for attr in zencoding#util#unique(current.attrs_order + keys(current.attr)) for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
if !has_key(current.attr, attr) if !has_key(current.attr, attr)
continue continue
endif endif
let val = current.attr[attr] let val = current.attr[attr]
if dollar_expr if dollar_expr
while val =~ '\$\([^#{]\|$\)' while val =~ '\$\([^#{]\|$\)'
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') " TODO: regexp engine specified
let val = substitute(val, '\%#=1\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile endwhile
let attr = substitute(attr, '\$$', itemno+1, '') let attr = substitute(attr, '\$$', itemno+1, '')
endif endif
let str .= ' ' . attr . '="' . val . '"' let str .= ' ' . attr . '="' . val . '"'
if zencoding#useFilter(filters, 'c') if emmet#useFilter(filters, 'c')
if attr == 'id' | let comment .= '#' . val | endif if attr == 'id' | let comment .= '#' . val | endif
if attr == 'class' | let comment .= '.' . val | endif if attr == 'class' | let comment .= '.' . val | endif
endif endif
@@ -366,7 +368,8 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
let str .= ">" let str .= ">"
let text = current.value[1:-2] let text = current.value[1:-2]
if dollar_expr if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') " TODO: regexp engine specified
let text = substitute(text, '\%#=1\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g') let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g') let text = substitute(text, '\\\$', '$', 'g')
let str = substitute(str, '\("\zs$#\ze"\|\s\zs\$#"\|"\$#\ze\s\)', text, 'g') let str = substitute(str, '\("\zs$#\ze"\|\s\zs\$#"\|"\$#\ze\s\)', text, 'g')
@@ -389,7 +392,7 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
let dr = 1 let dr = 1
endif endif
endif endif
let inner = zencoding#toString(child, type, 0, filters, itemno, indent) let inner = emmet#toString(child, type, 0, filters, itemno, indent)
let inner = substitute(inner, "^\n", "", 'g') let inner = substitute(inner, "^\n", "", 'g')
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
@@ -412,16 +415,16 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
return str return str
endfunction endfunction
function! zencoding#lang#html#imageSize() function! emmet#lang#html#imageSize()
let img_region = zencoding#util#searchRegion('<img\s', '>') let img_region = emmet#util#searchRegion('<img\s', '>')
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region) if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
return return
endif endif
let content = zencoding#util#getContent(img_region) let content = emmet#util#getContent(img_region)
if content !~ '^<img[^><]\+>$' if content !~ '^<img[^><]\+>$'
return return
endif endif
let current = zencoding#lang#html#parseTag(content) let current = emmet#lang#html#parseTag(content)
if empty(current) || !has_key(current.attr, 'src') if empty(current) || !has_key(current.attr, 'src')
return return
endif endif
@@ -432,28 +435,28 @@ function! zencoding#lang#html#imageSize()
let fn = simplify(expand('%:h') . '/' . fn) let fn = simplify(expand('%:h') . '/' . fn)
endif endif
let [width, height] = zencoding#util#getImageSize(fn) let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1 if width == -1 && height == -1
return return
endif endif
let current.attr.width = width let current.attr.width = width
let current.attr.height = height let current.attr.height = height
let current.attrs_order += ['width', 'height'] let current.attrs_order += ['width', 'height']
let html = substitute(zencoding#toString(current, 'html', 1), '\n', '', '') let html = substitute(emmet#toString(current, 'html', 1), '\n', '', '')
let html = substitute(html, '\${cursor}', '', '') let html = substitute(html, '\${cursor}', '', '')
call zencoding#util#setContent(img_region, html) call emmet#util#setContent(img_region, html)
endfunction endfunction
function! zencoding#lang#html#encodeImage() function! emmet#lang#html#encodeImage()
let img_region = zencoding#util#searchRegion('<img\s', '>') let img_region = emmet#util#searchRegion('<img\s', '>')
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region) if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
return return
endif endif
let content = zencoding#util#getContent(img_region) let content = emmet#util#getContent(img_region)
if content !~ '^<img[^><]\+>$' if content !~ '^<img[^><]\+>$'
return return
endif endif
let current = zencoding#lang#html#parseTag(content) let current = emmet#lang#html#parseTag(content)
if empty(current) || !has_key(current.attr, 'src') if empty(current) || !has_key(current.attr, 'src')
return return
endif endif
@@ -462,17 +465,17 @@ function! zencoding#lang#html#encodeImage()
let fn = simplify(expand('%:h') . '/' . fn) let fn = simplify(expand('%:h') . '/' . fn)
endif endif
let [width, height] = zencoding#util#getImageSize(fn) let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1 if width == -1 && height == -1
return return
endif endif
let current.attr.width = width let current.attr.width = width
let current.attr.height = height let current.attr.height = height
let html = zencoding#toString(current, 'html', 1) let html = emmet#toString(current, 'html', 1)
call zencoding#util#setContent(img_region, html) call emmet#util#setContent(img_region, html)
endfunction endfunction
function! zencoding#lang#html#parseTag(tag) function! emmet#lang#html#parseTag(tag)
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] } let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] }
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>' 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 match = matchstr(a:tag, mx)
@@ -494,22 +497,22 @@ function! zencoding#lang#html#parseTag(tag)
return current return current
endfunction endfunction
function! zencoding#lang#html#toggleComment() function! emmet#lang#html#toggleComment()
let orgpos = getpos('.') let orgpos = getpos('.')
let curpos = getpos('.') let curpos = getpos('.')
let mx = '<\%#[^>]*>' let mx = '<\%#[^>]*>'
while 1 while 1
let block = zencoding#util#searchRegion('<!--', '-->') let block = emmet#util#searchRegion('<!--', '-->')
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
let block[1][1] += 2 let block[1][1] += 2
let content = zencoding#util#getContent(block) let content = emmet#util#getContent(block)
let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '') let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
call zencoding#util#setContent(block, content) call emmet#util#setContent(block, content)
silent! call setpos('.', orgpos) silent! call setpos('.', orgpos)
return return
endif endif
let block = zencoding#util#searchRegion('<[^>]', '>') let block = emmet#util#searchRegion('<[^>]', '>')
if !zencoding#util#regionIsValid(block) if !emmet#util#regionIsValid(block)
let pos1 = searchpos('<', 'bcW') let pos1 = searchpos('<', 'bcW')
if pos1[0] == 0 && pos1[1] == 0 if pos1[0] == 0 && pos1[1] == 0
return return
@@ -519,7 +522,7 @@ function! zencoding#lang#html#toggleComment()
endif endif
let pos1 = block[0] let pos1 = block[0]
let pos2 = block[1] let pos2 = block[1]
let content = zencoding#util#getContent(block) let content = emmet#util#getContent(block)
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+') let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
if tag_name[0] == '/' if tag_name[0] == '/'
call setpos('.', [0, pos1[0], pos1[1], 0]) call setpos('.', [0, pos1[0], pos1[1], 0])
@@ -527,12 +530,12 @@ function! zencoding#lang#html#toggleComment()
let pos1 = searchpos('>', 'cneW') let pos1 = searchpos('>', 'cneW')
let block = [pos2, pos1] let block = [pos2, pos1]
elseif tag_name =~ '/$' elseif tag_name =~ '/$'
if !zencoding#util#pointInRegion(orgpos[1:2], block) if !emmet#util#pointInRegion(orgpos[1:2], block)
" it's broken tree " it's broken tree
call setpos('.', orgpos) call setpos('.', orgpos)
let block = zencoding#util#searchRegion('>', '<') let block = emmet#util#searchRegion('>', '<')
let content = '><!-- ' . zencoding#util#getContent(block)[1:-2] . ' --><' let content = '><!-- ' . emmet#util#getContent(block)[1:-2] . ' --><'
call zencoding#util#setContent(block, content) call emmet#util#setContent(block, content)
silent! call setpos('.', orgpos) silent! call setpos('.', orgpos)
return return
endif endif
@@ -543,27 +546,27 @@ function! zencoding#lang#html#toggleComment()
let pos2 = searchpos('>', 'neW') let pos2 = searchpos('>', 'neW')
let block = [pos1, pos2] let block = [pos1, pos2]
endif endif
if !zencoding#util#regionIsValid(block) if !emmet#util#regionIsValid(block)
silent! call setpos('.', orgpos) silent! call setpos('.', orgpos)
return return
endif endif
if zencoding#util#pointInRegion(curpos[1:2], block) if emmet#util#pointInRegion(curpos[1:2], block)
let content = '<!-- ' . zencoding#util#getContent(block) . ' -->' let content = '<!-- ' . emmet#util#getContent(block) . ' -->'
call zencoding#util#setContent(block, content) call emmet#util#setContent(block, content)
silent! call setpos('.', orgpos) silent! call setpos('.', orgpos)
return return
endif endif
endwhile endwhile
endfunction endfunction
function! zencoding#lang#html#balanceTag(flag) range function! emmet#lang#html#balanceTag(flag) range
let vblock = zencoding#util#getVisualBlock() let vblock = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2 if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0] let curpos = [0, line("'<"), col("'<"), 0]
else else
let curpos = getpos('.') let curpos = getpos('.')
endif endif
let settings = zencoding#getSettings() let settings = emmet#getSettings()
if a:flag > 0 if a:flag > 0
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
@@ -580,8 +583,8 @@ function! zencoding#lang#html#balanceTag(flag) range
if pos1[0] == 0 && pos1[1] == 0 if pos1[0] == 0 && pos1[1] == 0
break break
endif endif
if zencoding#util#pointInRegion(curpos[1:2], block) && zencoding#util#regionIsValid(block) if emmet#util#pointInRegion(curpos[1:2], block) && emmet#util#regionIsValid(block)
call zencoding#util#selectRegion(block) call emmet#util#selectRegion(block)
return return
endif endif
endwhile endwhile
@@ -593,8 +596,8 @@ function! zencoding#lang#html#balanceTag(flag) range
let pos1 = searchpos(mx . '\zs', 'W') let pos1 = searchpos(mx . '\zs', 'W')
let pos2 = searchpos('.\ze<', 'W') let pos2 = searchpos('.\ze<', 'W')
let block = [pos1, pos2] let block = [pos1, pos2]
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
call zencoding#util#selectRegion(block) call emmet#util#selectRegion(block)
return return
endif endif
endif endif
@@ -609,8 +612,8 @@ function! zencoding#lang#html#balanceTag(flag) range
if pos1[0] == 0 && pos1[1] == 0 if pos1[0] == 0 && pos1[1] == 0
break break
endif endif
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
call zencoding#util#selectRegion(block) call emmet#util#selectRegion(block)
return return
endif endif
endwhile endwhile
@@ -622,7 +625,7 @@ function! zencoding#lang#html#balanceTag(flag) range
endif endif
endfunction endfunction
function! zencoding#lang#html#moveNextPrev(flag) function! emmet#lang#html#moveNextPrev(flag)
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp') let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
if pos == 3 if pos == 3
startinsert! startinsert!
@@ -632,7 +635,7 @@ function! zencoding#lang#html#moveNextPrev(flag)
endif endif
endfunction endfunction
function! zencoding#lang#html#splitJoinTag() function! emmet#lang#html#splitJoinTag()
let curpos = getpos('.') let curpos = getpos('.')
while 1 while 1
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
@@ -640,9 +643,9 @@ function! zencoding#lang#html#splitJoinTag()
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) 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 tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]] let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block) if content[-2:] == '/>' && emmet#util#cursorInRegion(block)
let content = content[:-3] . "></" . tag_name . '>' let content = content[:-3] . "></" . tag_name . '>'
call zencoding#util#setContent(block, content) call emmet#util#setContent(block, content)
call setpos('.', [0, block[0][0], block[0][1], 0]) call setpos('.', [0, block[0][0], block[0][1], 0])
return return
else else
@@ -654,10 +657,10 @@ function! zencoding#lang#html#splitJoinTag()
let pos2 = searchpos('</' . tag_name . '>', 'cneW') let pos2 = searchpos('</' . tag_name . '>', 'cneW')
endif endif
let block = [pos1, pos2] let block = [pos1, pos2]
let content = zencoding#util#getContent(block) let content = emmet#util#getContent(block)
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>' if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
let content = matchstr(content, mx)[:-2] . '/>' let content = matchstr(content, mx)[:-2] . '/>'
call zencoding#util#setContent(block, content) call emmet#util#setContent(block, content)
call setpos('.', [0, block[0][0], block[0][1], 0]) call setpos('.', [0, block[0][0], block[0][1], 0])
return return
else else
@@ -672,7 +675,7 @@ function! zencoding#lang#html#splitJoinTag()
endwhile endwhile
endfunction endfunction
function! zencoding#lang#html#removeTag() function! emmet#lang#html#removeTag()
let curpos = getpos('.') let curpos = getpos('.')
while 1 while 1
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
@@ -680,8 +683,8 @@ function! zencoding#lang#html#removeTag()
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '') let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '')
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]] let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block) if content[-2:] == '/>' && emmet#util#cursorInRegion(block)
call zencoding#util#setContent(block, '') call emmet#util#setContent(block, '')
call setpos('.', [0, block[0][0], block[0][1], 0]) call setpos('.', [0, block[0][0], block[0][1], 0])
return return
else else
@@ -693,9 +696,9 @@ function! zencoding#lang#html#removeTag()
let pos2 = searchpos('</' . tag_name . '>', 'cneW') let pos2 = searchpos('</' . tag_name . '>', 'cneW')
endif endif
let block = [pos1, pos2] let block = [pos1, pos2]
let content = zencoding#util#getContent(block) let content = emmet#util#getContent(block)
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>' if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
call zencoding#util#setContent(block, '') call emmet#util#setContent(block, '')
call setpos('.', [0, block[0][0], block[0][1], 0]) call setpos('.', [0, block[0][0], block[0][1], 0])
return return
else else

View File

@@ -1,16 +1,16 @@
function! zencoding#lang#sass#findTokens(str) function! emmet#lang#sass#findTokens(str)
return zencoding#lang#html#findTokens(a:str) return emmet#lang#html#findTokens(a:str)
endfunction endfunction
function! zencoding#lang#sass#parseIntoTree(abbr, type) function! emmet#lang#sass#parseIntoTree(abbr, type)
if a:abbr =~ '>' if a:abbr =~ '>'
return zencoding#lang#html#parseIntoTree(a:abbr, a:type) return emmet#lang#html#parseIntoTree(a:abbr, a:type)
else else
return zencoding#lang#css#parseIntoTree(a:abbr, a:type) return emmet#lang#css#parseIntoTree(a:abbr, a:type)
endif endif
endfunction endfunction
function! zencoding#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings let settings = a:settings
let current = a:current let current = a:current
let type = a:type let type = a:type
@@ -50,33 +50,33 @@ function! zencoding#lang#sass#toString(settings, current, type, inline, filters,
let inner = '' let inner = ''
for child in current.child for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno) let inner .= emmet#toString(child, type, inline, filters, itemno)
endfor endfor
let inner = substitute(inner, "\n", "\n" . indent, 'g') let inner = substitute(inner, "\n", "\n" . indent, 'g')
let inner = substitute(inner, "\n" . indent . "$", "", 'g') let inner = substitute(inner, "\n" . indent . "$", "", 'g')
let str .= indent . inner let str .= indent . inner
else else
let text = zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent) let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g') let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
return text return text
endif endif
return str return str
endfunction endfunction
function! zencoding#lang#sass#imageSize() function! emmet#lang#sass#imageSize()
endfunction endfunction
function! zencoding#lang#sass#encodeImage() function! emmet#lang#sass#encodeImage()
endfunction endfunction
function! zencoding#lang#sass#parseTag(tag) function! emmet#lang#sass#parseTag(tag)
endfunction endfunction
function! zencoding#lang#sass#toggleComment() function! emmet#lang#sass#toggleComment()
endfunction endfunction
function! zencoding#lang#sass#balanceTag(flag) range function! emmet#lang#sass#balanceTag(flag) range
let block = zencoding#util#getVisualBlock() let block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2 if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0] let curpos = [0, line("'<"), col("'<"), 0]
else else
@@ -86,7 +86,7 @@ function! zencoding#lang#sass#balanceTag(flag) range
let ml = len(matchstr(getline(n), '^\s*')) let ml = len(matchstr(getline(n), '^\s*'))
if a:flag > 0 if a:flag > 0
if a:flag == 1 || !zencoding#util#regionIsValid(block) if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.') let n = line('.')
else else
while n > 0 while n > 0
@@ -140,7 +140,7 @@ function! zencoding#lang#sass#balanceTag(flag) range
endif endif
endfunction endfunction
function! zencoding#lang#sass#moveNextPrev(flag) function! emmet#lang#sass#moveNextPrev(flag)
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp') let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2 if pos == 2
startinsert! startinsert!
@@ -150,8 +150,8 @@ function! zencoding#lang#sass#moveNextPrev(flag)
endif endif
endfunction endfunction
function! zencoding#lang#sass#splitJoinTag() function! emmet#lang#sass#splitJoinTag()
endfunction endfunction
function! zencoding#lang#sass#removeTag() function! emmet#lang#sass#removeTag()
endfunction endfunction

View File

@@ -1,16 +1,16 @@
function! zencoding#lang#scss#findTokens(str) function! emmet#lang#scss#findTokens(str)
return zencoding#lang#html#findTokens(a:str) return emmet#lang#html#findTokens(a:str)
endfunction endfunction
function! zencoding#lang#scss#parseIntoTree(abbr, type) function! emmet#lang#scss#parseIntoTree(abbr, type)
if a:abbr =~ '>' if a:abbr =~ '>'
return zencoding#lang#html#parseIntoTree(a:abbr, a:type) return emmet#lang#html#parseIntoTree(a:abbr, a:type)
else else
return zencoding#lang#css#parseIntoTree(a:abbr, a:type) return emmet#lang#css#parseIntoTree(a:abbr, a:type)
endif endif
endfunction endfunction
function! zencoding#lang#scss#toString(settings, current, type, inline, filters, itemno, indent) function! emmet#lang#scss#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings let settings = a:settings
let current = a:current let current = a:current
let type = a:type let type = a:type
@@ -49,34 +49,34 @@ function! zencoding#lang#scss#toString(settings, current, type, inline, filters,
let inner = '' let inner = ''
for child in current.child for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno) let inner .= emmet#toString(child, type, inline, filters, itemno)
endfor endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
let str .= indent . inner . "\n}\n" let str .= indent . inner . "\n}\n"
else else
return zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent) return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
endif endif
return str return str
endfunction endfunction
function! zencoding#lang#scss#imageSize() function! emmet#lang#scss#imageSize()
call zencoding#lang#css#imageSize() call emmet#lang#css#imageSize()
endfunction endfunction
function! zencoding#lang#scss#encodeImage() function! emmet#lang#scss#encodeImage()
return zencoding#lang#css#encodeImage() return emmet#lang#css#encodeImage()
endfunction endfunction
function! zencoding#lang#scss#parseTag(tag) function! emmet#lang#scss#parseTag(tag)
return zencoding#lang#css#parseTag(a:tag) return emmet#lang#css#parseTag(a:tag)
endfunction endfunction
function! zencoding#lang#scss#toggleComment() function! emmet#lang#scss#toggleComment()
call zencoding#lang#css#toggleComment() call emmet#lang#css#toggleComment()
endfunction endfunction
function! zencoding#lang#scss#balanceTag(flag) range function! emmet#lang#scss#balanceTag(flag) range
if a:flag == -2 || a:flag == 2 if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0] let curpos = [0, line("'<"), col("'<"), 0]
call setpos('.', curpos) call setpos('.', curpos)
@@ -96,8 +96,8 @@ function! zencoding#lang#scss#balanceTag(flag) range
let pos2 = searchpairpos('{', '', '}') let pos2 = searchpairpos('{', '', '}')
endif endif
let block = [pos1, pos2] let block = [pos1, pos2]
if zencoding#util#regionIsValid(block) if emmet#util#regionIsValid(block)
call zencoding#util#selectRegion(block) call emmet#util#selectRegion(block)
return return
endif endif
endif endif
@@ -108,14 +108,14 @@ function! zencoding#lang#scss#balanceTag(flag) range
endif endif
endfunction endfunction
function! zencoding#lang#scss#moveNextPrev(flag) function! emmet#lang#scss#moveNextPrev(flag)
call zencoding#lang#css#moveNextPrev(a:flag) call emmet#lang#css#moveNextPrev(a:flag)
endfunction endfunction
function! zencoding#lang#scss#splitJoinTag() function! emmet#lang#scss#splitJoinTag()
call zencoding#lang#css#splitJoinTag() call emmet#lang#css#splitJoinTag()
endfunction endfunction
function! zencoding#lang#scss#removeTag() function! emmet#lang#scss#removeTag()
call zencoding#lang#ss#removeTag() call emmet#lang#ss#removeTag()
endfunction endfunction

View File

@@ -1,20 +1,20 @@
function! zencoding#lang#slim#findTokens(str) function! emmet#lang#slim#findTokens(str)
return zencoding#lang#html#findTokens(a:str) return emmet#lang#html#findTokens(a:str)
endfunction endfunction
function! zencoding#lang#slim#parseIntoTree(abbr, type) function! emmet#lang#slim#parseIntoTree(abbr, type)
return zencoding#lang#html#parseIntoTree(a:abbr, a:type) return emmet#lang#html#parseIntoTree(a:abbr, a:type)
endfunction endfunction
function! zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) function! emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings let settings = a:settings
let current = a:current let current = a:current
let type = a:type let type = a:type
let inline = a:inline let inline = a:inline
let filters = a:filters let filters = a:filters
let itemno = a:itemno let itemno = a:itemno
let indent = zencoding#getIndentation(type) let indent = emmet#getIndentation(type)
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
let str = "" let str = ""
let comment_indent = '' let comment_indent = ''
@@ -25,7 +25,7 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
endif endif
if len(current.name) > 0 if len(current.name) > 0
let str .= current_name let str .= current_name
for attr in zencoding#util#unique(current.attrs_order + keys(current.attr)) for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
if !has_key(current.attr, attr) if !has_key(current.attr, attr)
continue continue
endif endif
@@ -68,7 +68,7 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
endfor endfor
elseif len(current.child) > 0 elseif len(current.child) > 0
for child in current.child for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno, indent) let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
endfor endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
@@ -88,9 +88,9 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
return str return str
endfunction endfunction
function! zencoding#lang#slim#imageSize() function! emmet#lang#slim#imageSize()
let line = getline('.') let line = getline('.')
let current = zencoding#lang#slim#parseTag(line) let current = emmet#lang#slim#parseTag(line)
if empty(current) || !has_key(current.attr, 'src') if empty(current) || !has_key(current.attr, 'src')
return return
endif endif
@@ -101,22 +101,22 @@ function! zencoding#lang#slim#imageSize()
let fn = simplify(expand('%:h') . '/' . fn) let fn = simplify(expand('%:h') . '/' . fn)
endif endif
let [width, height] = zencoding#util#getImageSize(fn) let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1 if width == -1 && height == -1
return return
endif endif
let current.attr.width = width let current.attr.width = width
let current.attr.height = height let current.attr.height = height
let current.attrs_order += ['width', 'height'] let current.attrs_order += ['width', 'height']
let slim = zencoding#toString(current, 'slim', 1) let slim = emmet#toString(current, 'slim', 1)
let slim = substitute(slim, '\${cursor}', '', '') let slim = substitute(slim, '\${cursor}', '', '')
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", "", "g")) call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", "", "g"))
endfunction endfunction
function! zencoding#lang#slim#encodeImage() function! emmet#lang#slim#encodeImage()
endfunction endfunction
function! zencoding#lang#slim#parseTag(tag) function! emmet#lang#slim#parseTag(tag)
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] } let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] }
let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)' let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
let match = matchstr(a:tag, mx) let match = matchstr(a:tag, mx)
@@ -138,7 +138,7 @@ function! zencoding#lang#slim#parseTag(tag)
return current return current
endfunction endfunction
function! zencoding#lang#slim#toggleComment() function! emmet#lang#slim#toggleComment()
let line = getline('.') let line = getline('.')
let space = matchstr(line, '^\s*') let space = matchstr(line, '^\s*')
if line =~ '^\s*/' if line =~ '^\s*/'
@@ -148,8 +148,8 @@ function! zencoding#lang#slim#toggleComment()
endif endif
endfunction endfunction
function! zencoding#lang#slim#balanceTag(flag) range function! emmet#lang#slim#balanceTag(flag) range
let block = zencoding#util#getVisualBlock() let block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2 if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0] let curpos = [0, line("'<"), col("'<"), 0]
else else
@@ -159,7 +159,7 @@ function! zencoding#lang#slim#balanceTag(flag) range
let ml = len(matchstr(getline(n), '^\s*')) let ml = len(matchstr(getline(n), '^\s*'))
if a:flag > 0 if a:flag > 0
if a:flag == 1 || !zencoding#util#regionIsValid(block) if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.') let n = line('.')
else else
while n > 0 while n > 0
@@ -213,7 +213,7 @@ function! zencoding#lang#slim#balanceTag(flag) range
endif endif
endfunction endfunction
function! zencoding#lang#slim#moveNextPrev(flag) function! emmet#lang#slim#moveNextPrev(flag)
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp') let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2 if pos == 2
startinsert! startinsert!
@@ -223,7 +223,7 @@ function! zencoding#lang#slim#moveNextPrev(flag)
endif endif
endfunction endfunction
function! zencoding#lang#slim#splitJoinTag() function! emmet#lang#slim#splitJoinTag()
let n = line('.') let n = line('.')
while n > 0 while n > 0
if getline(n) =~ '^\s*\ze[a-z]' if getline(n) =~ '^\s*\ze[a-z]'
@@ -249,7 +249,7 @@ function! zencoding#lang#slim#splitJoinTag()
endwhile endwhile
endfunction endfunction
function! zencoding#lang#slim#removeTag() function! emmet#lang#slim#removeTag()
let n = line('.') let n = line('.')
let ml = 0 let ml = 0
while n > 0 while n > 0

View File

@@ -1,4 +1,4 @@
function! zencoding#lorem#en#expand(command) function! emmet#lorem#en#expand(command)
let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '') let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
let wcount = wcount > 0 ? wcount : 30 let wcount = wcount > 0 ? wcount : 30
@@ -39,19 +39,19 @@ function! zencoding#lorem#en#expand(command)
if sentence > 0 if sentence > 0
let arr += words let arr += words
endif endif
let r = zencoding#util#rand() let r = emmet#util#rand()
let word = arr[r % len(arr)] let word = arr[r % len(arr)]
if sentence == 0 if sentence == 0
let word = substitute(word, '^.', '\U&', '') let word = substitute(word, '^.', '\U&', '')
endif endif
let sentence += 1 let sentence += 1
call add(ret, word) call add(ret, word)
if (sentence > 5 && zencoding#util#rand() < 10000) || i == wcount - 1 if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1
if i == wcount - 1 if i == wcount - 1
let endc = "?!..."[zencoding#util#rand() % 5] let endc = "?!..."[emmet#util#rand() % 5]
call add(ret, endc) call add(ret, endc)
else else
let endc = "?!,..."[zencoding#util#rand() % 6] let endc = "?!,..."[emmet#util#rand() % 6]
call add(ret, endc . ' ') call add(ret, endc . ' ')
endif endif
if endc != ',' if endc != ','

View File

@@ -1,19 +1,19 @@
scriptencoding utf-8 scriptencoding utf-8
function! zencoding#lorem#ja#expand(command) function! emmet#lorem#ja#expand(command)
let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '') let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
let wcount = wcount > 0 ? wcount : 30 let wcount = wcount > 0 ? wcount : 30
let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html" let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
let content = zencoding#util#cache(url) let content = emmet#util#cache(url)
if len(content) == 0 if len(content) == 0
let content = zencoding#util#getContentFromURL(url) let content = emmet#util#getContentFromURL(url)
let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>') let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>')
let content = substitute(content, '[ \r]', '', 'g') let content = substitute(content, '[ \r]', '', 'g')
let content = substitute(content, '<br[^>]*>', "\n", 'g') let content = substitute(content, '<br[^>]*>', "\n", 'g')
let content = substitute(content, '<[^>]\+>', '', 'g') let content = substitute(content, '<[^>]\+>', '', 'g')
let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n") let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n")
call zencoding#util#cache(url, content) call emmet#util#cache(url, content)
endif endif
let content = substitute(content, "、\n", "、", "g") let content = substitute(content, "、\n", "、", "g")
@@ -22,6 +22,6 @@ function! zencoding#lorem#ja#expand(command)
if len(lines) == 0 if len(lines) == 0
let lines = clines let lines = clines
endif endif
let r = zencoding#util#rand() let r = emmet#util#rand()
return lines[r % len(lines)] return lines[r % len(lines)]
endfunction endfunction

View File

@@ -11,7 +11,7 @@
" -------------------- " --------------------
" begin::end " begin::end
" -------------------- " --------------------
function! zencoding#util#deleteContent(region) function! emmet#util#deleteContent(region)
let lines = getline(a:region[0][0], a:region[1][0]) let lines = getline(a:region[0][0], a:region[1][0])
call setpos('.', [0, a:region[0][0], a:region[0][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]) silent! exe "delete ".(a:region[1][0] - a:region[0][0])
@@ -36,7 +36,7 @@ endfunction
" bar " bar
" baz:end " baz:end
" -------------------- " --------------------
function! zencoding#util#setContent(region, content) function! emmet#util#setContent(region, content)
let newlines = split(a:content, '\n', 1) let newlines = split(a:content, '\n', 1)
let oldlines = getline(a:region[0][0], a:region[1][0]) let oldlines = getline(a:region[0][0], a:region[1][0])
call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
@@ -72,7 +72,7 @@ endfunction
" select_region : select region " select_region : select region
" this function make a selection of region " this function make a selection of region
function! zencoding#util#selectRegion(region) function! emmet#util#selectRegion(region)
call setpos('.', [0, a:region[1][0], a:region[1][1], 0]) call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
normal! v normal! v
call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
@@ -80,8 +80,8 @@ endfunction
" point_in_region : check point is in the region " point_in_region : check point is in the region
" this function return 0 or 1 " this function return 0 or 1
function! zencoding#util#pointInRegion(point, region) function! emmet#util#pointInRegion(point, region)
if !zencoding#util#regionIsValid(a:region) | return 0 | endif if !emmet#util#regionIsValid(a:region) | return 0 | endif
if a:region[0][0] > a:point[0] | 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[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[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
@@ -91,29 +91,29 @@ endfunction
" cursor_in_region : check cursor is in the region " cursor_in_region : check cursor is in the region
" this function return 0 or 1 " this function return 0 or 1
function! zencoding#util#cursorInRegion(region) function! emmet#util#cursorInRegion(region)
if !zencoding#util#regionIsValid(a:region) | return 0 | endif if !emmet#util#regionIsValid(a:region) | return 0 | endif
let cur = getpos('.')[1:2] let cur = getpos('.')[1:2]
return zencoding#util#pointInRegion(cur, a:region) return emmet#util#pointInRegion(cur, a:region)
endfunction endfunction
" region_is_valid : check region is valid " region_is_valid : check region is valid
" this function return 0 or 1 " this function return 0 or 1
function! zencoding#util#regionIsValid(region) function! emmet#util#regionIsValid(region)
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
return 1 return 1
endfunction endfunction
" search_region : make region from pattern which is composing start/end " search_region : make region from pattern which is composing start/end
" this function return array of position " this function return array of position
function! zencoding#util#searchRegion(start, end) function! emmet#util#searchRegion(start, end)
return [searchpairpos(a:start, '', a:end, 'bcnW'), searchpairpos(a:start, '\%#', a:end, 'nW')] return [searchpairpos(a:start, '', a:end, 'bcnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
endfunction endfunction
" get_content : get content in region " get_content : get content in region
" this function return string in region " this function return string in region
function! zencoding#util#getContent(region) function! emmet#util#getContent(region)
if !zencoding#util#regionIsValid(a:region) if !emmet#util#regionIsValid(a:region)
return '' return ''
endif endif
let lines = getline(a:region[0][0], a:region[1][0]) let lines = getline(a:region[0][0], a:region[1][0])
@@ -128,24 +128,24 @@ endfunction
" region_in_region : check region is in the region " region_in_region : check region is in the region
" this function return 0 or 1 " this function return 0 or 1
function! zencoding#util#regionInRegion(outer, inner) function! emmet#util#regionInRegion(outer, inner)
if !zencoding#util#regionIsValid(a:inner) || !zencoding#util#regionIsValid(a:outer) if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer)
return 0 return 0
endif endif
return zencoding#util#pointInRegion(a:inner[0], a:outer) && zencoding#util#pointInRegion(a:inner[1], a:outer) return emmet#util#pointInRegion(a:inner[0], a:outer) && emmet#util#pointInRegion(a:inner[1], a:outer)
endfunction endfunction
" get_visualblock : get region of visual block " get_visualblock : get region of visual block
" this function return region of visual block " this function return region of visual block
function! zencoding#util#getVisualBlock() function! emmet#util#getVisualBlock()
return [[line("'<"), col("'<")], [line("'>"), col("'>")]] return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
endfunction endfunction
"============================================================================== "==============================================================================
" html utils " html utils
"============================================================================== "==============================================================================
function! zencoding#util#getContentFromURL(url) function! emmet#util#getContentFromURL(url)
let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', '')))) let res = system(printf("%s %s", g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
let charset = matchstr(res, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>') let charset = matchstr(res, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>')
if len(charset) == 0 if len(charset) == 0
let charset = matchstr(res, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>') let charset = matchstr(res, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>')
@@ -159,7 +159,7 @@ function! zencoding#util#getContentFromURL(url)
return iconv(res, charset, &encoding) return iconv(res, charset, &encoding)
endfunction endfunction
function! zencoding#util#getTextFromHTML(buf) function! emmet#util#getTextFromHTML(buf)
let threshold_len = 100 let threshold_len = 100
let threshold_per = 0.1 let threshold_per = 0.1
let buf = a:buf let buf = a:buf
@@ -196,17 +196,17 @@ function! zencoding#util#getTextFromHTML(buf)
return res return res
endfunction endfunction
function! zencoding#util#getImageSize(fn) function! emmet#util#getImageSize(fn)
let fn = a:fn let fn = a:fn
if zencoding#util#isImageMagickInstalled() if emmet#util#isImageMagickInstalled()
return zencoding#util#imageSizeWithImageMagick(fn) return emmet#util#imageSizeWithImageMagick(fn)
endif endif
if filereadable(fn) if filereadable(fn)
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g') let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
else else
let hex = substitute(system(g:zencoding_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g') let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
endif endif
let [width, height] = [-1, -1] let [width, height] = [-1, -1]
@@ -240,7 +240,7 @@ function! zencoding#util#getImageSize(fn)
return [width, height] return [width, height]
endfunction endfunction
function! zencoding#util#imageSizeWithImageMagick(fn) function! emmet#util#imageSizeWithImageMagick(fn)
let img_info = system('identify -format "%wx%h" "'.a:fn.'"') let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
let img_size = split(substitute(img_info, '\n', '', ''), 'x') let img_size = split(substitute(img_info, '\n', '', ''), 'x')
let width = img_size[0] let width = img_size[0]
@@ -248,14 +248,14 @@ function! zencoding#util#imageSizeWithImageMagick(fn)
return [width, height] return [width, height]
endfunction endfunction
function! zencoding#util#isImageMagickInstalled() function! emmet#util#isImageMagickInstalled()
if !get(s:, 'zencoding_use_identify', 1) if !get(s:, 'emmet_use_identify', 1)
return 0 return 0
endif endif
return executable('identify') return executable('identify')
endfunction endfunction
function! zencoding#util#unique(arr) function! emmet#util#unique(arr)
let m = {} let m = {}
let r = [] let r = []
for i in a:arr for i in a:arr
@@ -268,18 +268,18 @@ function! zencoding#util#unique(arr)
endfunction endfunction
let s:seed = localtime() let s:seed = localtime()
function! zencoding#util#srand(seed) function! emmet#util#srand(seed)
let s:seed = a:seed let s:seed = a:seed
endfunction endfunction
function! zencoding#util#rand() function! emmet#util#rand()
let s:seed = s:seed * 214013 + 2531011 let s:seed = s:seed * 214013 + 2531011
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000 return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
endfunction endfunction
function! zencoding#util#cache(name, ...) function! emmet#util#cache(name, ...)
let content = get(a:000, 0, "") let content = get(a:000, 0, "")
let dir = expand("~/.zencoding/cache") let dir = expand("~/.emmet/cache")
if !isdirectory(dir) if !isdirectory(dir)
call mkdir(dir, "p", 0700) call mkdir(dir, "p", 0700)
endif endif

View File

@@ -1,48 +1,48 @@
*zencoding.txt* ZenCoding for Vim *emmet.txt* Emmet for Vim
------------------------------------------------------- -------------------------------------------------------
ZenCoding: vim plugins for HTML and CSS hi-speed coding Emmet: vim plugins for HTML and CSS hi-speed coding
------------------------------------------------------- -------------------------------------------------------
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
WebSite: http://mattn.kaoriya.net/ WebSite: http://mattn.kaoriya.net/
Repository: http://github.com/mattn/zencoding-vim Repository: http://github.com/mattn/emmet-vim
Site: http://mattn.github.com/zencoding-vim Site: http://mattn.github.com/emmet-vim
License: BSD style license License: BSD style license
============================================================================== ==============================================================================
CONTENTS *zencoding-contents* CONTENTS *emmet-contents*
Introduction |zencoding-introduction| Introduction |emmet-introduction|
Install |zencoding-install| Install |emmet-install|
Tutorial |zencoding-tutorial| Tutorial |emmet-tutorial|
1. Expand Abbreviation |zencoding-expandabbr| 1. Expand Abbreviation |emmet-expandabbr|
2. Wrap with Abbreviation |zencoding-wrap-with-abbreviation| 2. Wrap with Abbreviation |emmet-wrap-with-abbreviation|
3. Balance Tag Inward |zencoding-balance-tag-inward| 3. Balance Tag Inward |emmet-balance-tag-inward|
4. Balance Tag Outward |zencoding-balance-tag-outward| 4. Balance Tag Outward |emmet-balance-tag-outward|
5. Go to Next Edit Point |zencoding-goto-next-point| |<C-Y>n| 5. Go to Next Edit Point |emmet-goto-next-point| |<C-Y>n|
6. Go to Previous Edit Point |zencoding-goto-previous-point| 6. Go to Previous Edit Point |emmet-goto-previous-point|
7. Update <img> Size |zencoding-update-image-size| 7. Update <img> Size |emmet-update-image-size|
8. Merge Lines |zencoding-merge-lines| 8. Merge Lines |emmet-merge-lines|
9. Remove Tag |zencoding-remove-tag| 9. Remove Tag |emmet-remove-tag|
10. Split/Join Tag |zencoding-split-join-tag| 10. Split/Join Tag |emmet-split-join-tag|
11. Toggle Comment |zencoding-toggle-comment| 11. Toggle Comment |emmet-toggle-comment|
12. Make anchor from URL |zencoding-make-anchor-url| 12. Make anchor from URL |emmet-make-anchor-url|
13. Make quoted text from URL |zencoding-quoted-text-url| 13. Make quoted text from URL |emmet-quoted-text-url|
14. Code Pretty |zencoding-code-pretty| 14. Code Pretty |emmet-code-pretty|
15. Lorem Ipsum |zencoding-lorem-ipsum| 15. Lorem Ipsum |emmet-lorem-ipsum|
Customize |zencoding-customize| Customize |emmet-customize|
1. Key Mappings |zencoding-customize-keymappings| 1. Key Mappings |emmet-customize-keymappings|
2. Indent Size |zencoding-indent-size| 2. Indent Size |emmet-indent-size|
3. Define Tag's Behavior |zencoding-define-tags-behavior| 3. Define Tag's Behavior |emmet-define-tags-behavior|
4. Complete Tag |zencoding-complete-tag| 4. Complete Tag |emmet-complete-tag|
Links |zencoding-links| Links |emmet-links|
ToDo |zencoding-todo| ToDo |emmet-todo|
============================================================================== ==============================================================================
INTRODUCTION *zencoding-introduction* *zencoding* INTRODUCTION *emmet-introduction* *emmet*
|ZenCoding| is an editor plugin for high-speed HTML, XML, XSL (or any other |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 structured code format) coding and editing. The core of this plugin is a
powerful abbreviation engine which allows you to expand expressions?similar to powerful abbreviation engine which allows you to expand expressions?similar to
CSS selectors?into HTML code: CSS selectors?into HTML code:
@@ -62,15 +62,15 @@ CSS selectors?into HTML code:
</ul> </ul>
</div> </div>
< <
Read more about current Zen Coding syntax Read more about current Emmet syntax
http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn http://docs.emmet.io/abbreviations/
Abbreviation engine has a modular structure which allows you to expand Abbreviation engine has a modular structure which allows you to expand
abbreviations into different languages. Zen Coding currently supports CSS, abbreviations into different languages. Emmet currently supports CSS,
HTML, XML/XSL and HAML, Slim languages via filters. HTML, XML/XSL and HAML, Slim languages via filters.
============================================================================== ==============================================================================
INSTALL *zencoding-install* INSTALL *emmet-install*
Install the distributed files into Vim runtime directory which is usually Install the distributed files into Vim runtime directory which is usually
~/.vim/, or $HOME/vimfiles on Windows. ~/.vim/, or $HOME/vimfiles on Windows.
@@ -79,13 +79,13 @@ If you install pathogen that provided from Tim Pope, you should extract the
file into 'bundle' directory. file into 'bundle' directory.
============================================================================== ==============================================================================
TUTORIAL *zencoding-tutorial* TUTORIAL *emmet-tutorial*
If you are seeing this file as :help, then you can't edit this file. 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 You should copy this section and create new buffer, paste and write as
'zencoding-tutor.txt'. Formally, open the file to start tutorial. 'emmet-tutor.txt'. Formally, open the file to start tutorial.
1. Expand Abbreviation *zencoding-expandabbr* *<C-Y>,* 1. Expand Abbreviation *emmet-expandabbr* *<C-Y>,*
Type abbreviation as 'div>p#foo$*3>a' and type |<C-Y>,|. Type abbreviation as 'div>p#foo$*3>a' and type |<C-Y>,|.
> >
@@ -101,7 +101,7 @@ You should copy this section and create new buffer, paste and write as
</p> </p>
</div> </div>
< <
2. Wrap with Abbreviation *zencoding-wrap-with-abbreviation* *v_<C-Y>,* 2. Wrap with Abbreviation *emmet-wrap-with-abbreviation* *v_<C-Y>,*
Write as below. Write as below.
> >
@@ -126,7 +126,7 @@ You should copy this section and create new buffer, paste and write as
test3 test3
</blockquote> </blockquote>
< <
3. Balance Tag Inward *zencoding-balance-tag-inward* *<C-Y>d* 3. Balance Tag Inward *emmet-balance-tag-inward* *<C-Y>d*
To select inward of ul tag, type |<C-Y>d| in insert mode. To select inward of ul tag, type |<C-Y>d| in insert mode.
> >
@@ -139,7 +139,7 @@ You should copy this section and create new buffer, paste and write as
If cursor is at '*', |<C-Y>d| select from begin of <ul> to end of </ul>. If cursor is at '*', |<C-Y>d| select from begin of <ul> to end of </ul>.
If cursor is at first of <li>, it select <li class="list1"></li>. If cursor is at first of <li>, it select <li class="list1"></li>.
4. Balance Tag Outward *zencoding-balance-tag-outward* *<C-Y>D* 4. Balance Tag Outward *emmet-balance-tag-outward* *<C-Y>D*
To select outward of ul tag, insert mode, type <C-Y>D in insert mode. To select outward of ul tag, insert mode, type <C-Y>D in insert mode.
> >
@@ -153,7 +153,7 @@ You should copy this section and create new buffer, paste and write as
letter of </ul>. letter of </ul>.
If cursor is at first of <li>, it select <li class="list1"></li>. If cursor is at first of <li>, it select <li class="list1"></li>.
5. Go to Next Edit Point *zencoding-goto-next-point* *<C-Y>n* 5. Go to Next Edit Point *emmet-goto-next-point* *<C-Y>n*
To jump next point that need to edit, type |<C-Y>n| in insert mode. To jump next point that need to edit, type |<C-Y>n| in insert mode.
> >
@@ -164,7 +164,7 @@ You should copy this section and create new buffer, paste and write as
specified id as 'foo'. And type again |<C-Y>n| move a cursor into inner of specified id as 'foo'. And type again |<C-Y>n| move a cursor into inner of
div specified id as 'bar'. div specified id as 'bar'.
6. Go to Previous Edit Point *zencoding-goto-previous-point* *<C-Y>N* 6. Go to Previous Edit Point *emmet-goto-previous-point* *<C-Y>N*
To jump previous point that need to edit, type |<C-Y>N| in insert mode. To jump previous point that need to edit, type |<C-Y>N| in insert mode.
> >
@@ -174,7 +174,7 @@ You should copy this section and create new buffer, paste and write as
If cursor is at '*', |<C-Y>N| move a cursor into div specified id as 'bar'. If cursor is at '*', |<C-Y>N| move a cursor into div specified id as 'bar'.
And type again |<C-Y>N| move a cursor into attribute value of 'foo'. And type again |<C-Y>N| move a cursor into attribute value of 'foo'.
7. Update <img> Size *zencoding-update-image-size* *<C-Y>i* 7. Update <img> Size *emmet-update-image-size* *<C-Y>i*
To expand or update size of image, type |<C-Y>i| on img tag To expand or update size of image, type |<C-Y>i| on img tag
> >
@@ -188,7 +188,7 @@ You should copy this section and create new buffer, paste and write as
> >
<img src="foo-48.png" width="32" height="48" /> <img src="foo-48.png" width="32" height="48" />
< <
8. Merge Lines *zencoding-merge-lines* 8. Merge Lines *emmet-merge-lines*
To join multi line text like following, type |J|. To join multi line text like following, type |J|.
> >
@@ -205,7 +205,7 @@ You should copy this section and create new buffer, paste and write as
<li class="list1"></li><li class="list2"></li><li class="list3"></li> <li class="list1"></li><li class="list2"></li><li class="list3"></li>
</ul> </ul>
< <
9. Remove Tag *zencoding-remove-tag* *<C-Y>k* 9. Remove Tag *emmet-remove-tag* *<C-Y>k*
To remove tag in the block, type |<C-Y>k|. To remove tag in the block, type |<C-Y>k|.
> >
@@ -221,7 +221,7 @@ You should copy this section and create new buffer, paste and write as
< <
And type |<C-Y>k| in there again, then div will be removed. And type |<C-Y>k| in there again, then div will be removed.
10. Split/Join Tag *zencoding-split-join-tag* *<C-Y>j* 10. Split/Join Tag *emmet-split-join-tag* *<C-Y>j*
To join block, type |<C-Y>j|. To join block, type |<C-Y>j|.
> >
@@ -238,7 +238,7 @@ You should copy this section and create new buffer, paste and write as
<div class="foo"> <div class="foo">
</div> </div>
< <
11. Toggle Comment *zencoding-toggle-comment* *<C-Y>/* 11. Toggle Comment *emmet-toggle-comment* *<C-Y>/*
Move cursor to block Move cursor to block
> >
@@ -258,7 +258,7 @@ You should copy this section and create new buffer, paste and write as
hello world hello world
</div> </div>
< <
12. Make anchor from URL *zencoding-make-anchor-url* *<C-Y>a* 12. Make anchor from URL *emmet-make-anchor-url* *<C-Y>a*
Move cursor to URL Move cursor to URL
> >
@@ -268,7 +268,7 @@ You should copy this section and create new buffer, paste and write as
> >
<a href="http://www.google.com/">Google</a> <a href="http://www.google.com/">Google</a>
< <
13. Make quoted text from URL *zencoding-quoted-text-url* *<C-Y>A* 13. Make quoted text from URL *emmet-quoted-text-url* *<C-Y>A*
Move cursor to URL Move cursor to URL
> >
@@ -282,7 +282,7 @@ You should copy this section and create new buffer, paste and write as
<cite>http://github.com/</cite> <cite>http://github.com/</cite>
</blockquote> </blockquote>
< <
14. Code Pretty *zencoding-code-pretty* *<C-Y>c* 14. Code Pretty *emmet-code-pretty* *<C-Y>c*
Select code block, for example select following code from "int main()". Select code block, for example select following code from "int main()".
> >
@@ -298,7 +298,7 @@ You should copy this section and create new buffer, paste and write as
&nbsp;&nbsp;puts(<span class="Constant">&quot;hello world&quot;</span>);<br /> &nbsp;&nbsp;puts(<span class="Constant">&quot;hello world&quot;</span>);<br />
}<br /> }<br />
< <
15. Lorem Ipsum *zencoding-lorem-ipsum* 15. Lorem Ipsum *emmet-lorem-ipsum*
To insert dummy text. To insert dummy text.
> >
@@ -311,13 +311,13 @@ You should copy this section and create new buffer, paste and write as
deserunt ab, veritatis commodi. Eius nobis ab deserunt magni iure quo deserunt ab, veritatis commodi. Eius nobis ab deserunt magni iure quo
laboriosam laboriosam.</div> laboriosam laboriosam.</div>
< <
For japanese user, put like follow into your g:user_zen_settings: For japanese user, put like follow into your g:user_emmet_settings:
> >
let g:user_zen_settings = { let g:user_emmet_settings = {
... ...
\ 'custom_expands1' : { \ 'custom_expands1' : {
\ '^\%(lorem\|lipsum\)\(\d*\)$' : function('zencoding#lorem#ja#expand'), \ '^\%(lorem\|lipsum\)\(\d*\)$' : function('emmet#lorem#ja#expand'),
\ }, \ },
... ...
@@ -325,35 +325,35 @@ You should copy this section and create new buffer, paste and write as
You will get japanese dummy text. You will get japanese dummy text.
> >
============================================================================== ==============================================================================
CUSTOMIZE *zencoding-customize* CUSTOMIZE *emmet-customize*
1. Key Mapping *zencoding-customize-keymappings* 1. Key Mapping *emmet-customize-keymappings*
To specify leading key for expanding or balance tag, or for all, To specify leading key for expanding or balance tag, or for all,
Add this line in your vimrc: > Add this line in your vimrc: >
> >
let g:user_zen_leader_key = '<c-y>' let g:user_emmet_leader_key = '<c-y>'
< <
Or if you prefer to map for each actions, then you set each variables. Or if you prefer to map for each actions, then you set each variables.
'user_zen_expandabbr_key' 'user_emmet_expandabbr_key'
'user_zen_expandword_key' 'user_emmet_expandword_key'
'user_zen_balancetaginward_key' 'user_emmet_balancetaginward_key'
'user_zen_balancetagoutward_key' 'user_emmet_balancetagoutward_key'
'user_zen_next_key' 'user_emmet_next_key'
'user_zen_prev_key' 'user_emmet_prev_key'
'user_zen_imagesize_key' 'user_emmet_imagesize_key'
'user_zen_togglecomment_key' 'user_emmet_togglecomment_key'
'user_zen_splitjointag_key' 'user_emmet_splitjointag_key'
'user_zen_removetag_key' 'user_emmet_removetag_key'
'user_zen_anchorizeurl_key' 'user_emmet_anchorizeurl_key'
'user_zen_anchorizesummary_key' 'user_emmet_anchorizesummary_key'
2. Indent Size *zencoding-indent-size* 2. Indent Size *emmet-indent-size*
To change indent size of html, add this code in your vimrc. To change indent size of html, add this code in your vimrc.
> >
let g:user_zen_settings = { let g:user_emmet_settings = {
\ 'html' : { \ 'html' : {
\ 'indentation' : ' ' \ 'indentation' : ' '
\ }, \ },
@@ -361,17 +361,17 @@ CUSTOMIZE *zencoding-customize*
< <
If you prefer to change global indent size then add this. If you prefer to change global indent size then add this.
> >
let g:user_zen_settings = { let g:user_emmet_settings = {
\ 'indentation' : ' ' \ 'indentation' : ' '
\} \}
< <
3. Define Tag's Behavior *zencoding-define-tags-behavior* 3. Define Tag's Behavior *emmet-define-tags-behavior*
zencoding.vim can change behavior of expanding abbreviation for each Emmet.vim can change behavior of expanding abbreviation for each
filetypes as |Dictionary|. For details, see official site of zencoding. filetypes as |Dictionary|. For details, see official site of Emmet.
for example, vimmer can add following. for example, vimmer can add following.
> >
let g:user_zen_settings = { let g:user_emmet_settings = {
\ 'lang' : 'ja', \ 'lang' : 'ja',
\ 'html' : { \ 'html' : {
\ 'filters' : 'html', \ 'filters' : 'html',
@@ -412,23 +412,29 @@ CUSTOMIZE *zencoding-customize*
\ }, \ },
\} \}
< <
4. Complete Tag *zencoding-complete-tag* 4. Complete Tag *emmet-complete-tag*
If you want to complete tags using |omnifunc| then add this. If you want to complete tags using |omnifunc| then add this.
> >
let g:use_zen_complete_tag = 1 let g:use_emmet_complete_tag = 1
< <
5. Enable functions in different mode 5. Enable functions in different mode
If you want to use zencoding only in some modes, set an mode option: If you want to use Emmet only in some modes, set an mode option:
let g:user_zen_mode='n' "only enable normal mode functions, or let g:user_emmet_mode='n' "only enable normal mode functions, or
let g:user_zen_mode='inv' "enable all functions, which is equal to let g:user_emmet_mode='inv' "enable all functions, which is equal to
let g:user_zen_mode='a' "enable all function in all mode. let g:user_emmet_mode='a' "enable all function in all mode.
============================================================================== ==============================================================================
LINKS *zencoding-links* LINKS *emmet-links*
Emmet official site:
http://emmet.io/
zen-coding official site:
http://code.google.com/p/zen-coding/
zen-coding official site: zen-coding official site:
http://code.google.com/p/zen-coding/ http://code.google.com/p/zen-coding/
@@ -453,11 +459,11 @@ tutorial translated in Chinese:
http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html
============================================================================== ==============================================================================
TODO *zencoding-todo* TODO *emmet-todo*
* wrapping inline selected. * wrapping inline selected.
* more documents. * more documents.
* more contributor. * more contributor.
* more time to improve zencoding.vim. * more time to improve emmet.vim.
============================================================================== ==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0: vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:

View File

@@ -1,21 +1,21 @@
script_name: ZenCoding.vim script_name: Emmet.vim
script_id: '2981' script_id: '2981'
script_type: utility script_type: utility
script_package: zencoding-vim.zip script_package: emmet-vim.zip
script_version: '0.80' script_version: '0.80'
required_vim_version: '7.0' required_vim_version: '7.0'
summary: vim plugins for HTML and CSS hi-speed coding. summary: vim plugins for HTML and CSS hi-speed coding.
detailed_description: | detailed_description: |
This is vim script support expanding abbreviation like zen-coding. This is vim script support expanding abbreviation like emmet.
ref: http://code.google.com/p/zen-coding/ ref: http://emmet.io/
There is a movie using zencoding.vim There is a movie using emmet.vim
ref: http://mattn.github.com/zencoding-vim ref: http://mattn.github.com/emmet-vim
Source Repository. Source Repository.
ref: http://github.com/mattn/zencoding-vim ref: http://github.com/mattn/emmet-vim
Type abbreviation Type abbreviation
+------------------------------------- +-------------------------------------
@@ -52,18 +52,18 @@ detailed_description: |
Tutorial: Tutorial:
http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL http://github.com/mattn/emmet-vim/raw/master/TUTORIAL
How work this: How work this:
http://mattn.github.com/zencoding-vim http://mattn.github.com/emmet-vim
Tips: Tips:
You can customize behavior of expanding with overriding config. You can customize behavior of expanding with overriding config.
This configuration will be merged at loading plugin. This configuration will be merged at loading plugin.
let g:user_zen_settings = { let g:user_emmet_settings = {
\ 'indentation' : ' ', \ 'indentation' : ' ',
\ 'perl' : { \ 'perl' : {
\ 'aliases' : { \ 'aliases' : {
@@ -76,28 +76,30 @@ detailed_description: |
\ } \ }
\} \}
let g:user_zen_expandabbr_key = '<c-e>' let g:user_emmet_expandabbr_key = '<c-e>'
let g:use_zen_complete_tag = 1 let g:use_emmet_complete_tag = 1
You can set language attribute in html using zen_settings['lang']. You can set language attribute in html using emmet_settings['lang'].
install_details: | install_details: |
# cd ~/.vim # cd ~/.vim
# unzip zencoding-vim.zip # unzip emmet-vim.zip
or if you install pathogen.vim: or if you install pathogen.vim:
# cd ~/.vim/bundle # or make directory # cd ~/.vim/bundle # or make directory
# unzip /path/to/zencoding-vim.zip # unzip /path/to/emmet-vim.zip
if you get sources from repository: if you get sources from repository:
# cd ~/.vim/bundle # or make directory # cd ~/.vim/bundle # or make directory
# git clone http://github.com/mattn/zencoding-vim.git # git clone http://github.com/mattn/emmet-vim.git
versions: versions:
- '0.81': |
Release of Emmet.vim: renamed from ZenCoding.vim.
- '0.80': | - '0.80': |
This is an upgrade for ZenCoding.vim: add emmet features. This is an upgrade for ZenCoding.vim: add emmet features.
- '0.74': | - '0.74': |

215
plugin/emmet.vim Normal file
View File

@@ -0,0 +1,215 @@
"=============================================================================
" File: emmet.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 06-Aug-2013.
" Version: 0.75
" WebPage: http://github.com/mattn/emmet-vim
" Description: vim plugins for HTML and CSS hi-speed coding.
" SeeAlso: http://emmet.io/
" Usage:
"
" This is vim script support expanding abbreviation like emmet.
" ref: http://emmet.io/
"
" Type abbreviation
" +-------------------------------------
" | html:5_
" +-------------------------------------
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
" NOTE: Don't worry about key map. you can change it easily.
" +-------------------------------------
" | <!DOCTYPE HTML>
" | <html lang="en">
" | <head>
" | <title></title>
" | <meta charset="UTF-8">
" | </head>
" | <body>
" | _
" | </body>
" | </html>
" +-------------------------------------
" Type following
" +-------------------------------------
" | div#foo$*2>div.bar
" +-------------------------------------
" And type "<c-y>,"
" +-------------------------------------
" |<div id="foo1">
" | <div class="bar">_</div>
" |</div>
" |<div id="foo2">
" | <div class="bar"></div>
" |</div>
" +-------------------------------------
"
" Tips:
"
" You can customize behavior of expanding with overriding config.
" This configuration will be marged at loading plugin.
"
" let g:user_emmet_settings = {
" \ 'indentation' : ' ',
" \ 'perl' : {
" \ 'aliases' : {
" \ 'req' : 'require '
" \ },
" \ 'snippets' : {
" \ 'use' : "use strict\nuse warnings\n\n",
" \ 'warn' : "warn \"|\";",
" \ }
" \ }
" \}
"
" You can set language attribute in html using 'emmet_settings.lang'.
"
" GetLatestVimScripts: 2981 1 :AutoInstall: emmet.vim
" script type: plugin
if &cp || v:version < 702 || (exists('g:loaded_emmet_vim') && g:loaded_emmet_vim)
finish
endif
let g:loaded_emmet_vim = 1
let s:save_cpo = &cpo
set cpo&vim
if !exists('g:emmet_debug')
let g:emmet_debug = 0
endif
if !exists('g:emmet_curl_command')
let g:emmet_curl_command = 'curl -s -L -A Mozilla/5.0'
endif
if exists('g:use_emmet_complete_tag') && g:use_emmet_complete_tag
setlocal omnifunc=emmet#CompleteTag
endif
if !exists('g:user_emmet_leader_key')
let g:user_emmet_leader_key = '<c-y>'
endif
function! s:install_plugin_i()
for item in [
\ {'mode': 'i', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'EmmetExpandAbbr', 'func': '<c-g>u<esc>:call emmet#expandAbbr(0,"")<cr>a'},
\ {'mode': 'i', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'EmmetExpandWord', 'func': '<c-g>u<esc>:call emmet#expandAbbr(1,"")<cr>a'},
\ {'mode': 'i', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'EmmetBalanceTagInwardInsert', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
\ {'mode': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'EmmetBalanceTagOutwardInsert', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'EmmetNext', 'func': '<esc>:call emmet#moveNextPrev(0)<cr>'},
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'EmmetPrev', 'func': '<esc>:call emmet#moveNextPrev(1)<cr>'},
\ {'mode': 'i', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'EmmetImageSize', 'func': '<esc>:call emmet#imageSize()<cr>a'},
\ {'mode': 'i', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'EmmetToggleComment', 'func': '<esc>:call emmet#toggleComment()<cr>a'},
\ {'mode': 'i', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'EmmetSplitJoinTagInsert', 'func': '<esc>:call emmet#splitJoinTag()<cr>'},
\ {'mode': 'i', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'EmmetRemoveTag', 'func': '<esc>:call emmet#removeTag()<cr>a'},
\ {'mode': 'i', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'EmmetAnchorizeURL', 'func': '<esc>:call emmet#anchorizeURL(0)<cr>a'},
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'EmmetAnchorizeSummary', 'func': '<esc>:call emmet#anchorizeURL(1)<cr>a'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_emmet_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
function! s:install_plugin_n()
for item in [
\ {'mode': 'n', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'EmmetExpandNormal', 'func': ':call emmet#expandAbbr(3,"")<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_expandword_key', 'key': ',', 'plug': 'EmmetExpandWord', 'func': ':call emmet#expandAbbr(1,"")<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'EmmetBalanceTagInwardNormal', 'func': ':call emmet#balanceTag(1)<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'EmmetBalanceTagOutwardNormal', 'func': ':call emmet#balanceTag(-1)<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'EmmetNext', 'func': ':call emmet#moveNextPrev(0)<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'EmmetPrev', 'func': ':call emmet#moveNextPrev(1)<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'EmmetImageSize', 'func': ':call emmet#imageSize()<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'EmmetToggleComment', 'func': ':call emmet#toggleComment()<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'EmmetSplitJoinTagNormal', 'func': ':call emmet#splitJoinTag()<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'EmmetRemoveTag', 'func': ':call emmet#removeTag()<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'EmmetAnchorizeURL', 'func': ':call emmet#anchorizeURL(0)<cr>'},
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'EmmetAnchorizeSummary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_emmet_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
function! s:install_plugin_v()
for item in [
\ {'mode': 'v', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'EmmetExpandVisual', 'func': ':call emmet#expandAbbr(2,"")<cr>'},
\ {'mode': 'v', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'EmmetBalanceTagInwardVisual', 'func': ':call emmet#balanceTag(2)<cr>'},
\ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'EmmetBalanceTagOutwardVisual', 'func': ':call emmet#balanceTag(-2)<cr>'},
\ {'mode': 'v', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'EmmetMergeLines', 'func': ':call emmet#mergeLines()<cr>'},
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'EmmetCodePretty', 'func': ':call emmet#codePretty()<cr>'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_emmet_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
if exists('g:user_emmet_mode')
let imode = matchstr(g:user_emmet_mode, '[ai]')
let nmode = matchstr(g:user_emmet_mode, '[an]')
let vmode = matchstr(g:user_emmet_mode, '[av]')
if !empty(imode)
call s:install_plugin_i()
endif
if !empty(nmode)
call s:install_plugin_n()
endif
if !empty(vmode)
call s:install_plugin_v()
endif
else
call s:install_plugin_i()
call s:install_plugin_n()
call s:install_plugin_v()
endif
delfunction s:install_plugin_i
delfunction s:install_plugin_n
delfunction s:install_plugin_v
command! -nargs=1 Emmet call emmet#expandAbbr(4, <q-args>)
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et:

View File

@@ -1,215 +0,0 @@
"=============================================================================
" File: zencoding.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 17-Jun-2013.
" Version: 0.75
" WebPage: http://github.com/mattn/zencoding-vim
" Description: vim plugins for HTML and CSS hi-speed coding.
" SeeAlso: http://code.google.com/p/zen-coding/
" Usage:
"
" This is vim script support expanding abbreviation like zen-coding.
" ref: http://code.google.com/p/zen-coding/
"
" Type abbreviation
" +-------------------------------------
" | html:5_
" +-------------------------------------
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
" NOTE: Don't worry about key map. you can change it easily.
" +-------------------------------------
" | <!DOCTYPE HTML>
" | <html lang="en">
" | <head>
" | <title></title>
" | <meta charset="UTF-8">
" | </head>
" | <body>
" | _
" | </body>
" | </html>
" +-------------------------------------
" Type following
" +-------------------------------------
" | div#foo$*2>div.bar
" +-------------------------------------
" And type "<c-y>,"
" +-------------------------------------
" |<div id="foo1">
" | <div class="bar">_</div>
" |</div>
" |<div id="foo2">
" | <div class="bar"></div>
" |</div>
" +-------------------------------------
"
" Tips:
"
" You can customize behavior of expanding with overriding config.
" This configuration will be marged at loading plugin.
"
" let g:user_zen_settings = {
" \ 'indentation' : ' ',
" \ 'perl' : {
" \ 'aliases' : {
" \ 'req' : 'require '
" \ },
" \ 'snippets' : {
" \ 'use' : "use strict\nuse warnings\n\n",
" \ 'warn' : "warn \"|\";",
" \ }
" \ }
" \}
"
" You can set language attribute in html using 'zen_settings.lang'.
"
" GetLatestVimScripts: 2981 1 :AutoInstall: zencoding.vim
" script type: plugin
if &cp || v:version < 702 || (exists('g:loaded_zencoding_vim') && g:loaded_zencoding_vim)
finish
endif
let g:loaded_zencoding_vim = 1
let s:save_cpo = &cpo
set cpo&vim
if !exists('g:zencoding_debug')
let g:zencoding_debug = 0
endif
if !exists('g:zencoding_curl_command')
let g:zencoding_curl_command = 'curl -s -L -A Mozilla/5.0'
endif
if exists('g:use_zen_complete_tag') && g:use_zen_complete_tag
setlocal omnifunc=zencoding#CompleteTag
endif
if !exists('g:user_zen_leader_key')
let g:user_zen_leader_key = '<c-y>'
endif
function! s:install_plugin_i()
for item in [
\ {'mode': 'i', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandAbbr', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(0,"")<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_expandword_key', 'key': ';', 'plug': 'ZenCodingExpandWord', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(1,"")<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardInsert', 'func': '<esc>:call zencoding#balanceTag(1)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardInsert', 'func': '<esc>:call zencoding#balanceTag(-1)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': '<esc>:call zencoding#moveNextPrev(0)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': '<esc>:call zencoding#moveNextPrev(1)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': '<esc>:call zencoding#imageSize()<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': '<esc>:call zencoding#toggleComment()<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagInsert', 'func': '<esc>:call zencoding#splitJoinTag()<cr>'},
\ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': '<esc>:call zencoding#removeTag()<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': '<esc>:call zencoding#anchorizeURL(0)<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': '<esc>:call zencoding#anchorizeURL(1)<cr>a'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_zen_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
function! s:install_plugin_n()
for item in [
\ {'mode': 'n', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandNormal', 'func': ':call zencoding#expandAbbr(3,"")<cr>'},
\ {'mode': 'n', 'var': 'user_zen_expandword_key', 'key': ',', 'plug': 'ZenCodingExpandWord', 'func': ':call zencoding#expandAbbr(1,"")<cr>'},
\ {'mode': 'n', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardNormal', 'func': ':call zencoding#balanceTag(1)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardNormal', 'func': ':call zencoding#balanceTag(-1)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagNormal', 'func': ':call zencoding#splitJoinTag()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)<cr>'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_zen_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
function! s:install_plugin_v()
for item in [
\ {'mode': 'v', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandVisual', 'func': ':call zencoding#expandAbbr(2,"")<cr>'},
\ {'mode': 'v', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardVisual', 'func': ':call zencoding#balanceTag(2)<cr>'},
\ {'mode': 'v', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardVisual', 'func': ':call zencoding#balanceTag(-2)<cr>'},
\ {'mode': 'v', 'var': 'user_zen_mergelines_key', 'key': 'm', 'plug': 'ZenCodingMergeLines', 'func': ':call zencoding#mergeLines()<cr>'},
\ {'mode': 'v', 'var': 'user_zen_codepretty_key', 'key': 'c', 'plug': 'ZenCodingCodePretty', 'func': ':call zencoding#codePretty()<cr>'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_zen_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
if exists('g:user_zen_mode')
let imode = matchstr(g:user_zen_mode, '[ai]')
let nmode = matchstr(g:user_zen_mode, '[an]')
let vmode = matchstr(g:user_zen_mode, '[av]')
if !empty(imode)
call s:install_plugin_i()
endif
if !empty(nmode)
call s:install_plugin_n()
endif
if !empty(vmode)
call s:install_plugin_v()
endif
else
call s:install_plugin_i()
call s:install_plugin_n()
call s:install_plugin_v()
endif
delfunction s:install_plugin_i
delfunction s:install_plugin_n
delfunction s:install_plugin_v
command! -nargs=1 Zen call zencoding#expandAbbr(4, <q-args>)
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et:

View File

@@ -1,7 +1,7 @@
let s:sfile = expand('<sfile>') let s:sfile = expand('<sfile>')
function! s:reload(d) function! s:reload(d)
exe "so" a:d."/plugin/zencoding.vim" exe "so" a:d."/plugin/emmet.vim"
for f in split(globpath(a:d, 'autoload/**/*.vim'), "\n") for f in split(globpath(a:d, 'autoload/**/*.vim'), "\n")
silent! exe "so" f silent! exe "so" f
endfor endfor
@@ -117,7 +117,7 @@ function! s:test(...)
call s:show_title(n+1, query) call s:show_title(n+1, query)
else else
call s:show_title(n+1, query) call s:show_title(n+1, query)
unlet! res | let res = zencoding#ExpandWord(query, testgroup.type, 0) unlet! res | let res = emmet#ExpandWord(query, testgroup.type, 0)
endif endif
if stridx(result, '$$$$') != -1 if stridx(result, '$$$$') != -1
if res ==# result if res ==# result
@@ -140,9 +140,9 @@ endfunction
function! s:do_tests(...) function! s:do_tests(...)
try try
if exists('g:user_zen_settings') if exists('g:user_emmet_settings')
let s:old_user_zen_settings = g:user_zen_settings let s:old_user_emmet_settings = g:user_emmet_settings
let g:user_zen_settings = { 'indentation': "\t" } let g:user_emmet_settings = { 'indentation': "\t" }
endif endif
let oldmore = &more let oldmore = &more
call s:reload(fnamemodify(s:sfile, ':h')) call s:reload(fnamemodify(s:sfile, ':h'))
@@ -153,13 +153,13 @@ function! s:do_tests(...)
echohl ErrorMsg | echomsg v:exception | echohl None echohl ErrorMsg | echomsg v:exception | echohl None
finally finally
let &more=oldmore let &more=oldmore
if exists('g:user_zen_settings') if exists('g:user_emmet_settings')
let g:user_zen_settings = s:old_user_zen_settings let g:user_emmet_settings = s:old_user_emmet_settings
endif endif
endtry endtry
endfunction endfunction
function! g:zencoding_unittest_complete(arglead, cmdline, cmdpos) function! g:emmet_unittest_complete(arglead, cmdline, cmdpos)
let args = split(a:cmdline, '\s\+', 1) let args = split(a:cmdline, '\s\+', 1)
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'"))) let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
try try
@@ -173,9 +173,9 @@ function! g:zencoding_unittest_complete(arglead, cmdline, cmdpos)
return [] return []
endfunction endfunction
command! -nargs=* -complete=customlist,g:zencoding_unittest_complete ZenCodingUnitTest call s:do_tests(<f-args>) command! -nargs=* -complete=customlist,g:emmet_unittest_complete EmmetUnitTest call s:do_tests(<f-args>)
if s:sfile == expand('%:p') if s:sfile == expand('%:p')
ZenCodingUnitTest EmmetUnitTest
endif endif
finish finish
@@ -255,8 +255,8 @@ finish
'result': "<a href=\"http://www.google.com/\">Google</a>\n", 'result': "<a href=\"http://www.google.com/\">Google</a>\n",
}, },
{ {
'query': "{ZenCoding}", 'query': "{Emmet}",
'result': "ZenCoding", 'result': "Emmet",
}, },
{ {
'query': "a+b", 'query': "a+b",
@@ -768,7 +768,7 @@ finish
}, },
{ {
'query': "ap>wp", 'query': "ap>wp",
'result': "<xsl:apply-templates select=\"\" mode=\"\">\n\t<xsl:with-param name=\"\" select=\"\"></xsl:with-param>\n</xsl:apply-templates>\n", 'result': "<xsl:apply-templates select=\"\" mode=\"\">\n <xsl:with-param name=\"\" select=\"\"></xsl:with-param>\n</xsl:apply-templates>\n",
}, },
], ],
}, },
@@ -782,7 +782,7 @@ finish
'tests': [ 'tests': [
{ {
'query': "xsd:w3c", 'query': "xsd:w3c",
'result': "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n\t<xsd:element name=\"\" type=\"\"/>\n</xsd:schema>", 'result': "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <xsd:element name=\"\" type=\"\"/>\n</xsd:schema>",
}, },
], ],
}, },