forked from VimPlug/emmet-vim
Rename to Emmet.vim!
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
"=============================================================================
|
||||
" zencoding.vim
|
||||
" emmet.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 10-Jun-2013.
|
||||
" Last Change: 06-Aug-2013.
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! zencoding#getExpandos(type, key)
|
||||
let expandos = zencoding#getResource(a:type, 'expandos', {})
|
||||
function! emmet#getExpandos(type, key)
|
||||
let expandos = emmet#getResource(a:type, 'expandos', {})
|
||||
if has_key(expandos, a:key)
|
||||
return expandos[a:key]
|
||||
endif
|
||||
return a:key
|
||||
endfunction
|
||||
|
||||
function! zencoding#splitFilterArg(filters)
|
||||
function! emmet#splitFilterArg(filters)
|
||||
for f in a:filters
|
||||
if f =~ '^/'
|
||||
return f[1:]
|
||||
@@ -23,7 +23,7 @@ function! zencoding#splitFilterArg(filters)
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! zencoding#useFilter(filters, filter)
|
||||
function! emmet#useFilter(filters, filter)
|
||||
for f in a:filters
|
||||
if a:filter == '/' && f =~ '^/'
|
||||
return 1
|
||||
@@ -34,30 +34,30 @@ function! zencoding#useFilter(filters, filter)
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! zencoding#getIndentation(...)
|
||||
function! emmet#getIndentation(...)
|
||||
if a:0 > 0
|
||||
let type = a:1
|
||||
else
|
||||
let type = zencoding#getFileType()
|
||||
let type = emmet#getFileType()
|
||||
endif
|
||||
if has_key(s:zen_settings, type) && has_key(s:zen_settings[type], 'indentation')
|
||||
let indent = s:zen_settings[type].indentation
|
||||
elseif has_key(s:zen_settings, 'indentation')
|
||||
let indent = s:zen_settings.indentation
|
||||
if has_key(s:emmet_settings, type) && has_key(s:emmet_settings[type], 'indentation')
|
||||
let indent = s:emmet_settings[type].indentation
|
||||
elseif has_key(s:emmet_settings, 'indentation')
|
||||
let indent = s:emmet_settings.indentation
|
||||
else
|
||||
let indent = (&l:expandtab || &l:tabstop != &l:shiftwidth) ? repeat(' ', &l:shiftwidth) : "\t"
|
||||
endif
|
||||
return indent
|
||||
endfunction
|
||||
|
||||
function! zencoding#getBaseType(type)
|
||||
if !has_key(s:zen_settings, a:type)
|
||||
function! emmet#getBaseType(type)
|
||||
if !has_key(s:emmet_settings, a:type)
|
||||
return ''
|
||||
endif
|
||||
if !has_key(s:zen_settings[a:type], 'extends')
|
||||
if !has_key(s:emmet_settings[a:type], 'extends')
|
||||
return a:type
|
||||
endif
|
||||
let extends = s:zen_settings[a:type].extends
|
||||
let extends = s:emmet_settings[a:type].extends
|
||||
if type(extends) == 1
|
||||
let tmp = split(extends, '\s*,\s*')
|
||||
let ext = tmp[0]
|
||||
@@ -65,22 +65,22 @@ function! zencoding#getBaseType(type)
|
||||
let ext = extends[0]
|
||||
endif
|
||||
if a:type != ext
|
||||
return zencoding#getBaseType(ext)
|
||||
return emmet#getBaseType(ext)
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! zencoding#isExtends(type, extend)
|
||||
function! emmet#isExtends(type, extend)
|
||||
if a:type == a:extend
|
||||
return 1
|
||||
endif
|
||||
if !has_key(s:zen_settings, a:type)
|
||||
if !has_key(s:emmet_settings, a:type)
|
||||
return 0
|
||||
endif
|
||||
if !has_key(s:zen_settings[a:type], 'extends')
|
||||
if !has_key(s:emmet_settings[a:type], 'extends')
|
||||
return 0
|
||||
endif
|
||||
let extends = s:zen_settings[a:type].extends
|
||||
let extends = s:emmet_settings[a:type].extends
|
||||
if type(extends) == 1
|
||||
let tmp = split(extends, '\s*,\s*')
|
||||
unlet! extends
|
||||
@@ -94,14 +94,14 @@ function! zencoding#isExtends(type, extend)
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! zencoding#parseIntoTree(abbr, type)
|
||||
function! emmet#parseIntoTree(abbr, type)
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#parseIntoTree(abbr, type)
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#parseIntoTree(abbr, type)
|
||||
endfunction
|
||||
|
||||
function! zencoding#mergeConfig(lhs, rhs)
|
||||
function! emmet#mergeConfig(lhs, rhs)
|
||||
if type(a:lhs) == 3 && type(a:rhs) == 3
|
||||
let a:lhs += a:rhs
|
||||
if len(a:lhs)
|
||||
@@ -119,7 +119,7 @@ function! zencoding#mergeConfig(lhs, rhs)
|
||||
let a:lhs[key] += a:rhs[key]
|
||||
elseif type(a:rhs[key]) == 4
|
||||
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
|
||||
let a:lhs[key] = a:rhs[key]
|
||||
endif
|
||||
@@ -130,7 +130,7 @@ function! zencoding#mergeConfig(lhs, rhs)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#toString(...)
|
||||
function! emmet#toString(...)
|
||||
let current = a:1
|
||||
if a:0 > 1
|
||||
let type = a:2
|
||||
@@ -163,16 +163,16 @@ function! zencoding#toString(...)
|
||||
let indent = ''
|
||||
endif
|
||||
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let itemno = 0
|
||||
let str = ''
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
while itemno < current.multiplier
|
||||
if len(current.name)
|
||||
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
|
||||
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
|
||||
if current.multiplier > 1
|
||||
let inner = substitute(inner, '\$#', '$line'.(itemno+1).'$', 'g')
|
||||
@@ -181,16 +181,16 @@ function! zencoding#toString(...)
|
||||
else
|
||||
let snippet = current.snippet
|
||||
if len(current.snippet) == 0
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
if !empty(snippets) && has_key(snippets, 'zensnippet')
|
||||
let snippet = snippets['zensnippet']
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
if !empty(snippets) && has_key(snippets, 'emmet_snippet')
|
||||
let snippet = snippets['emmet_snippet']
|
||||
endif
|
||||
endif
|
||||
if len(snippet) > 0
|
||||
let tmp = snippet
|
||||
let tmp = substitute(tmp, '\${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 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
|
||||
if len(current.name)
|
||||
let str .= current.name
|
||||
@@ -198,7 +198,8 @@ function! zencoding#toString(...)
|
||||
if len(current.value)
|
||||
let text = current.value[1:-2]
|
||||
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, '\\\$', '$', 'g')
|
||||
endif
|
||||
@@ -207,9 +208,9 @@ function! zencoding#toString(...)
|
||||
endif
|
||||
let inner = ''
|
||||
if len(current.child)
|
||||
let render_type = zencoding#getFileType(1)
|
||||
let render_type = emmet#getFileType(1)
|
||||
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
|
||||
endif
|
||||
let spaces = matchstr(str, '\s*\ze\${child}')
|
||||
@@ -221,49 +222,49 @@ function! zencoding#toString(...)
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#getSettings()
|
||||
return s:zen_settings
|
||||
function! emmet#getSettings()
|
||||
return s:emmet_settings
|
||||
endfunction
|
||||
|
||||
function! zencoding#getResource(type, name, default)
|
||||
if !has_key(s:zen_settings, a:type)
|
||||
function! emmet#getResource(type, name, default)
|
||||
if !has_key(s:emmet_settings, a:type)
|
||||
return a:default
|
||||
endif
|
||||
let ret = a:default
|
||||
|
||||
if has_key(s:zen_settings[a:type], 'extends')
|
||||
let extends = s:zen_settings[a:type].extends
|
||||
if has_key(s:emmet_settings[a:type], 'extends')
|
||||
let extends = s:emmet_settings[a:type].extends
|
||||
if type(extends) == 1
|
||||
let tmp = split(extends, '\s*,\s*')
|
||||
unlet! extends
|
||||
let extends = tmp
|
||||
endif
|
||||
for ext in extends
|
||||
if has_key(s:zen_settings, ext) && has_key(s:zen_settings[ext], a:name)
|
||||
call zencoding#mergeConfig(ret, s:zen_settings[ext][a:name])
|
||||
if has_key(s:emmet_settings, ext) && has_key(s:emmet_settings[ext], a:name)
|
||||
call emmet#mergeConfig(ret, s:emmet_settings[ext][a:name])
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if has_key(s:zen_settings[a:type], a:name)
|
||||
let v = s:zen_settings[a:type][a:name]
|
||||
if has_key(s:emmet_settings[a:type], a:name)
|
||||
let v = s:emmet_settings[a:type][a:name]
|
||||
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
|
||||
let ret = s:zen_settings[a:type][a:name]
|
||||
let ret = s:emmet_settings[a:type][a:name]
|
||||
endif
|
||||
endif
|
||||
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
function! zencoding#getFileType(...)
|
||||
function! emmet#getFileType(...)
|
||||
let flg = get(a:000, 0, 0)
|
||||
let type = &ft
|
||||
if zencoding#lang#exists(&ft)
|
||||
if emmet#lang#exists(&ft)
|
||||
let type = &ft
|
||||
else
|
||||
let base = zencoding#getBaseType(type)
|
||||
let base = emmet#getBaseType(type)
|
||||
if base != ""
|
||||
if flg
|
||||
let type = &ft
|
||||
@@ -291,7 +292,7 @@ function! zencoding#getFileType(...)
|
||||
return type
|
||||
endfunction
|
||||
|
||||
function! zencoding#getDollarExprs(expand)
|
||||
function! emmet#getDollarExprs(expand)
|
||||
let expand = a:expand
|
||||
let dollar_list = []
|
||||
let dollar_reg = '\%(\\\)\@<!\${\(\([^{}]\|\%(\\\)\@\<=[{}]\)\{}\)}'
|
||||
@@ -302,7 +303,7 @@ function! zencoding#getDollarExprs(expand)
|
||||
if key !~ '^\d\+:'
|
||||
let key = substitute(key, '\\{', '{', 'g')
|
||||
let key = substitute(key, '\\}', '}', 'g')
|
||||
let value = zencoding#getDollarValueByKey(key)
|
||||
let value = emmet#getDollarValueByKey(key)
|
||||
if type(value) == type('')
|
||||
let expr = get(matcharr, 0)
|
||||
call add(dollar_list, {'expr': expr, 'value': value})
|
||||
@@ -316,22 +317,22 @@ function! zencoding#getDollarExprs(expand)
|
||||
return dollar_list
|
||||
endfunction
|
||||
|
||||
function! zencoding#getDollarValueByKey(key)
|
||||
function! emmet#getDollarValueByKey(key)
|
||||
let ret = 0
|
||||
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)
|
||||
let V = get(ftsetting, key)
|
||||
if type(V) == 1 | return V | endif
|
||||
endif
|
||||
if type(ret) != 1 && has_key(s:zen_settings, key)
|
||||
let V = get(s:zen_settings, key)
|
||||
if type(ret) != 1 && has_key(s:emmet_settings, key)
|
||||
let V = get(s:emmet_settings, key)
|
||||
if type(V) == 1 | return V | endif
|
||||
endif
|
||||
if has_key(s:zen_settings, 'custom_expands') && type(s:zen_settings['custom_expands']) == 4
|
||||
for k in keys(s:zen_settings['custom_expands'])
|
||||
if has_key(s:emmet_settings, 'custom_expands') && type(s:emmet_settings['custom_expands']) == 4
|
||||
for k in keys(s:emmet_settings['custom_expands'])
|
||||
if key =~ k
|
||||
let V = get(s:zen_settings['custom_expands'], k)
|
||||
let V = get(s:emmet_settings['custom_expands'], k)
|
||||
if type(V) == 1 | return V | endif
|
||||
if type(V) == 2 | return V(key) | endif
|
||||
endif
|
||||
@@ -340,9 +341,9 @@ function! zencoding#getDollarValueByKey(key)
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
function! zencoding#reExpandDollarExpr(expand, times)
|
||||
function! emmet#reExpandDollarExpr(expand, times)
|
||||
let expand = a:expand
|
||||
let dollar_exprs = zencoding#getDollarExprs(expand)
|
||||
let dollar_exprs = emmet#getDollarExprs(expand)
|
||||
if len(dollar_exprs) > 0
|
||||
if a:times < 9
|
||||
for n in range(len(dollar_exprs))
|
||||
@@ -351,20 +352,20 @@ function! zencoding#reExpandDollarExpr(expand, times)
|
||||
let sub = get(pair, 'value')
|
||||
let expand = substitute(expand, pat, sub, '')
|
||||
endfor
|
||||
return zencoding#reExpandDollarExpr(expand, a:times + 1)
|
||||
return emmet#reExpandDollarExpr(expand, a:times + 1)
|
||||
endif
|
||||
endif
|
||||
return expand
|
||||
endfunction
|
||||
|
||||
function! zencoding#expandDollarExpr(expand)
|
||||
return zencoding#reExpandDollarExpr(a:expand, 0)
|
||||
function! emmet#expandDollarExpr(expand)
|
||||
return emmet#reExpandDollarExpr(a:expand, 0)
|
||||
endfunction
|
||||
|
||||
function! zencoding#expandCursorExpr(expand, mode)
|
||||
function! emmet#expandCursorExpr(expand, mode)
|
||||
let expand = a:expand
|
||||
let type = zencoding#getFileType()
|
||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
let type = emmet#getFileType()
|
||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
if use_pipe_for_cursor
|
||||
let expand = substitute(expand, '|', '${cursor}', 'g')
|
||||
endif
|
||||
@@ -380,22 +381,22 @@ function! zencoding#expandCursorExpr(expand, mode)
|
||||
return expand
|
||||
endfunction
|
||||
|
||||
function! zencoding#unescapeDollarExpr(expand)
|
||||
function! emmet#unescapeDollarExpr(expand)
|
||||
return substitute(a:expand, '\\\$', '$', 'g')
|
||||
endfunction
|
||||
|
||||
function! zencoding#expandAbbr(mode, abbr) range
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#getFileType(1)
|
||||
let indent = zencoding#getIndentation(type)
|
||||
function! emmet#expandAbbr(mode, abbr) range
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#getFileType(1)
|
||||
let indent = emmet#getIndentation(type)
|
||||
let expand = ''
|
||||
let filters = ['html']
|
||||
let line = ''
|
||||
let part = ''
|
||||
let rest = ''
|
||||
|
||||
if has_key(s:zen_settings, type) && has_key(s:zen_settings[type], 'filters')
|
||||
let filters = split(s:zen_settings[type].filters, '\s*,\s*')
|
||||
if has_key(s:emmet_settings, type) && has_key(s:emmet_settings[type], 'filters')
|
||||
let filters = split(s:emmet_settings[type].filters, '\s*,\s*')
|
||||
endif
|
||||
|
||||
if a:mode == 2
|
||||
@@ -413,16 +414,16 @@ function! zencoding#expandAbbr(mode, abbr) range
|
||||
if query !~ '}\s*$'
|
||||
let query .= '>{$#}'
|
||||
endif
|
||||
if zencoding#useFilter(filters, '/')
|
||||
let spl = zencoding#splitFilterArg(filters)
|
||||
if emmet#useFilter(filters, '/')
|
||||
let spl = emmet#splitFilterArg(filters)
|
||||
let fline = getline(a:firstline)
|
||||
let query = substitute(query, '>\{0,1}{\$#}\s*$', '{\\$column\\$}*' . len(split(fline, spl)), '')
|
||||
endif
|
||||
let items = zencoding#parseIntoTree(query, type).child
|
||||
let items = emmet#parseIntoTree(query, type).child
|
||||
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
|
||||
if zencoding#useFilter(filters, 'e')
|
||||
if emmet#useFilter(filters, 'e')
|
||||
let expand = substitute(expand, '&', '\&', 'g')
|
||||
let expand = substitute(expand, '<', '\<', 'g')
|
||||
let expand = substitute(expand, '>', '\>', 'g')
|
||||
@@ -432,11 +433,11 @@ function! zencoding#expandAbbr(mode, abbr) range
|
||||
for n in range(a:firstline, a:lastline)
|
||||
let lline = getline(n)
|
||||
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, '\s\+$', '', '')
|
||||
endif
|
||||
if zencoding#useFilter(filters, '/')
|
||||
if emmet#useFilter(filters, '/')
|
||||
for column in split(lpart, spl)
|
||||
let expand = substitute(expand, '\$column\$', '\=column', '')
|
||||
endfor
|
||||
@@ -465,19 +466,19 @@ function! zencoding#expandAbbr(mode, abbr) range
|
||||
endif
|
||||
endfor
|
||||
let leader .= (str =~ "\n" ? ">{\n" : "{") . str . "}"
|
||||
let items = zencoding#parseIntoTree(leader, type).child
|
||||
let items = emmet#parseIntoTree(leader, type).child
|
||||
else
|
||||
let save_regcont = @"
|
||||
let save_regtype = getregtype('"')
|
||||
silent! normal! gvygv
|
||||
let str = @"
|
||||
call setreg('"', save_regcont, save_regtype)
|
||||
let items = zencoding#parseIntoTree(leader . "{".str."}", type).child
|
||||
let items = emmet#parseIntoTree(leader . "{".str."}", type).child
|
||||
endif
|
||||
for item in items
|
||||
let expand .= zencoding#toString(item, type, 0, filters, 0, '')
|
||||
let expand .= emmet#toString(item, type, 0, filters, 0, '')
|
||||
endfor
|
||||
if zencoding#useFilter(filters, 'e')
|
||||
if emmet#useFilter(filters, 'e')
|
||||
let expand = substitute(expand, '&', '\&', 'g')
|
||||
let expand = substitute(expand, '<', '\<', 'g')
|
||||
let expand = substitute(expand, '>', '\>', 'g')
|
||||
@@ -492,7 +493,7 @@ function! zencoding#expandAbbr(mode, abbr) range
|
||||
call setline('.', spaces.a:abbr)
|
||||
endif
|
||||
normal! $
|
||||
call zencoding#expandAbbr(0, "")
|
||||
call emmet#expandAbbr(0, "")
|
||||
return
|
||||
else
|
||||
let line = getline('.')
|
||||
@@ -503,8 +504,8 @@ function! zencoding#expandAbbr(mode, abbr) range
|
||||
let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$')
|
||||
else
|
||||
let part = matchstr(line, '\(\S.*\)$')
|
||||
let ftype = zencoding#lang#exists(type) ? type : 'html'
|
||||
let part = zencoding#lang#{ftype}#findTokens(part)
|
||||
let ftype = emmet#lang#exists(type) ? type : 'html'
|
||||
let part = emmet#lang#{ftype}#findTokens(part)
|
||||
endif
|
||||
let rest = getline('.')[len(line):]
|
||||
let str = part
|
||||
@@ -513,27 +514,27 @@ function! zencoding#expandAbbr(mode, abbr) range
|
||||
let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
|
||||
let str = substitute(str, mx, '', '')
|
||||
endif
|
||||
let items = zencoding#parseIntoTree(str, rtype).child
|
||||
let items = emmet#parseIntoTree(str, rtype).child
|
||||
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
|
||||
if zencoding#useFilter(filters, 'e')
|
||||
if emmet#useFilter(filters, 'e')
|
||||
let expand = substitute(expand, '&', '\&', 'g')
|
||||
let expand = substitute(expand, '<', '\<', 'g')
|
||||
let expand = substitute(expand, '>', '\>', 'g')
|
||||
endif
|
||||
let expand = substitute(expand, '\$line\([0-9]\+\)\$', '\=submatch(1)', 'g')
|
||||
endif
|
||||
let expand = zencoding#expandDollarExpr(expand)
|
||||
let expand = zencoding#expandCursorExpr(expand, a:mode)
|
||||
let expand = emmet#expandDollarExpr(expand)
|
||||
let expand = emmet#expandCursorExpr(expand, a:mode)
|
||||
if len(expand)
|
||||
if has_key(s:zen_settings, 'timezone') && len(s:zen_settings.timezone)
|
||||
let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S") . s:zen_settings.timezone, 'g')
|
||||
if has_key(s:emmet_settings, 'timezone') && len(s:emmet_settings.timezone)
|
||||
let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S") . s:emmet_settings.timezone, 'g')
|
||||
else
|
||||
" TODO: on windows, %z/%Z is 'Tokyo(Standard)'
|
||||
let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S %z"), 'g')
|
||||
endif
|
||||
let expand = zencoding#unescapeDollarExpr(expand)
|
||||
let expand = emmet#unescapeDollarExpr(expand)
|
||||
if a:mode == 2 && visualmode() ==# 'v'
|
||||
if a:firstline == a:lastline
|
||||
let expand = substitute(expand, '\n\s*', '', 'g')
|
||||
@@ -577,115 +578,115 @@ function! zencoding#expandAbbr(mode, abbr) range
|
||||
silent! exe "normal! v7h\"_s"
|
||||
let &selection = oldselection
|
||||
endif
|
||||
if g:zencoding_debug > 1
|
||||
if g:emmet_debug > 1
|
||||
call getchar()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#moveNextPrev(flag)
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#moveNextPrev(a:flag)
|
||||
function! emmet#moveNextPrev(flag)
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#imageSize()
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#imageSize()
|
||||
function! emmet#imageSize()
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#encodeImage()
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#encodeImage()
|
||||
function! emmet#encodeImage()
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#toggleComment()
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#toggleComment()
|
||||
function! emmet#toggleComment()
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! zencoding#balanceTag(flag) range
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#balanceTag(a:flag)
|
||||
function! emmet#balanceTag(flag) range
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#balanceTag(a:flag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#splitJoinTag()
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#splitJoinTag()
|
||||
function! emmet#splitJoinTag()
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#splitJoinTag()
|
||||
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 indent = substitute(getline('.'), '^\(\s*\).*', '\1', '')
|
||||
silent! exe "normal! gvc"
|
||||
call setline('.', indent . lines)
|
||||
endfunction
|
||||
|
||||
function! zencoding#removeTag()
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
return zencoding#lang#{rtype}#removeTag()
|
||||
function! emmet#removeTag()
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#removeTag()
|
||||
endfunction
|
||||
|
||||
function! zencoding#anchorizeURL(flag)
|
||||
function! emmet#anchorizeURL(flag)
|
||||
let mx = 'https\=:\/\/[-!#$%&*+,./:;=?@0-9a-zA-Z_~]\+'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let url = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(url) - 1]]
|
||||
if !zencoding#util#cursorInRegion(block)
|
||||
if !emmet#util#cursorInRegion(block)
|
||||
return
|
||||
endif
|
||||
|
||||
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, '[ \n]\+', ' ', 'g')
|
||||
let content = substitute(content, '<!--.\{-}-->', '', 'g')
|
||||
let title = matchstr(content, mx)
|
||||
|
||||
let type = zencoding#getFileType()
|
||||
let rtype = zencoding#lang#exists(type) ? type : 'html'
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
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.value = '{' . title . '}'
|
||||
let expand = zencoding#toString(a, rtype, 0, [])
|
||||
let expand = emmet#toString(a, rtype, 0, [])
|
||||
let expand = substitute(expand, '\${cursor}', '', 'g')
|
||||
else
|
||||
let body = zencoding#util#getTextFromHTML(content)
|
||||
let body = emmet#util#getTextFromHTML(content)
|
||||
let body = '{' . substitute(body, '^\(.\{0,100}\).*', '\1', '') . '...}'
|
||||
|
||||
let blockquote = zencoding#lang#html#parseTag('<blockquote class="quote">')
|
||||
let a = zencoding#lang#html#parseTag('<a>')
|
||||
let blockquote = emmet#lang#html#parseTag('<blockquote class="quote">')
|
||||
let a = emmet#lang#html#parseTag('<a>')
|
||||
let a.attr.href = url
|
||||
let a.value = '{' . title . '}'
|
||||
call add(blockquote.child, a)
|
||||
call add(blockquote.child, zencoding#lang#html#parseTag('<br/>'))
|
||||
let p = zencoding#lang#html#parseTag('<p>')
|
||||
call add(blockquote.child, emmet#lang#html#parseTag('<br/>'))
|
||||
let p = emmet#lang#html#parseTag('<p>')
|
||||
let p.value = body
|
||||
call add(blockquote.child, p)
|
||||
let cite = zencoding#lang#html#parseTag('<cite>')
|
||||
let cite = emmet#lang#html#parseTag('<cite>')
|
||||
let cite.value = '{' . url . '}'
|
||||
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')
|
||||
endif
|
||||
let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '')
|
||||
let expand = substitute(expand, "\n", "\n" . indent, 'g')
|
||||
call zencoding#util#setContent(block, expand)
|
||||
call emmet#util#setContent(block, expand)
|
||||
endfunction
|
||||
|
||||
function! zencoding#codePretty() range
|
||||
function! emmet#codePretty() range
|
||||
let type = input('FileType: ', &ft, 'filetype')
|
||||
if len(type) == 0
|
||||
return
|
||||
endif
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
let content = zencoding#util#getContent(block)
|
||||
let block = emmet#util#getVisualBlock()
|
||||
let content = emmet#util#getContent(block)
|
||||
silent! 1new
|
||||
let &l:filetype = type
|
||||
call setline(1, split(content, "\n"))
|
||||
@@ -697,50 +698,50 @@ function! zencoding#codePretty() range
|
||||
silent! bw!
|
||||
silent! bw!
|
||||
let content = matchstr(content, '<body[^>]*>[\s\n]*\zs.*\ze</body>')
|
||||
call zencoding#util#setContent(block, content)
|
||||
call emmet#util#setContent(block, content)
|
||||
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 str = a:abbr
|
||||
let type = a:type
|
||||
let indent = zencoding#getIndentation(type)
|
||||
let indent = emmet#getIndentation(type)
|
||||
|
||||
if len(type) == 0 | let type = 'html' | endif
|
||||
if str =~ mx
|
||||
let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
|
||||
let str = substitute(str, mx, '', '')
|
||||
elseif has_key(s:zen_settings[a:type], 'filters')
|
||||
let filters = split(s:zen_settings[a:type].filters, '\s*,\s*')
|
||||
elseif has_key(s:emmet_settings[a:type], 'filters')
|
||||
let filters = split(s:emmet_settings[a:type].filters, '\s*,\s*')
|
||||
else
|
||||
let filters = ['html']
|
||||
endif
|
||||
let items = zencoding#parseIntoTree(str, a:type).child
|
||||
let items = emmet#parseIntoTree(str, a:type).child
|
||||
let expand = ''
|
||||
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
|
||||
if zencoding#useFilter(filters, 'e')
|
||||
if emmet#useFilter(filters, 'e')
|
||||
let expand = substitute(expand, '&', '\&', 'g')
|
||||
let expand = substitute(expand, '<', '\<', 'g')
|
||||
let expand = substitute(expand, '>', '\>', 'g')
|
||||
endif
|
||||
if a:orig == 0
|
||||
let expand = zencoding#expandDollarExpr(expand)
|
||||
let expand = emmet#expandDollarExpr(expand)
|
||||
let expand = substitute(expand, '\${cursor}', '', 'g')
|
||||
endif
|
||||
return expand
|
||||
endfunction
|
||||
|
||||
function! zencoding#getSnippets(type)
|
||||
function! emmet#getSnippets(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'
|
||||
endif
|
||||
return zencoding#getResource(type, 'snippets', {})
|
||||
return emmet#getResource(type, 'snippets', {})
|
||||
endfunction
|
||||
|
||||
function! zencoding#CompleteTag(findstart, base)
|
||||
function! emmet#CompleteTag(findstart, base)
|
||||
if a:findstart
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
@@ -749,16 +750,16 @@ function! zencoding#CompleteTag(findstart, base)
|
||||
endwhile
|
||||
return start
|
||||
else
|
||||
let type = zencoding#getFileType()
|
||||
let type = emmet#getFileType()
|
||||
let res = []
|
||||
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
for item in keys(snippets)
|
||||
if stridx(item, a:base) != -1
|
||||
call add(res, substitute(item, '\${cursor}\||', '', 'g'))
|
||||
endif
|
||||
endfor
|
||||
let aliases = zencoding#getResource(type, 'aliases', {})
|
||||
let aliases = emmet#getResource(type, 'aliases', {})
|
||||
for item in values(aliases)
|
||||
if stridx(item, a:base) != -1
|
||||
call add(res, substitute(item, '\${cursor}\||', '', 'g'))
|
||||
@@ -768,12 +769,12 @@ function! zencoding#CompleteTag(findstart, base)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
unlet! s:zen_settings
|
||||
let s:zen_settings = {
|
||||
unlet! s:emmet_settings
|
||||
let s:emmet_settings = {
|
||||
\ 'lang': "en",
|
||||
\ 'charset': "UTF-8",
|
||||
\ 'custom_expands' : {
|
||||
\ '^\%(lorem\|lipsum\)\(\d*\)$' : function('zencoding#lorem#en#expand'),
|
||||
\ '^\%(lorem\|lipsum\)\(\d*\)$' : function('emmet#lorem#en#expand'),
|
||||
\ },
|
||||
\ 'css': {
|
||||
\ 'snippets': {
|
||||
@@ -1275,6 +1276,7 @@ let s:zen_settings = {
|
||||
\ 'extends': 'css',
|
||||
\ },
|
||||
\ 'html': {
|
||||
\ 'indentation': "\t",
|
||||
\ 'snippets': {
|
||||
\ 'cc:ie6': "<!--[if lte IE 6]>\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')
|
||||
call zencoding#mergeConfig(s:zen_settings, g:user_zen_settings)
|
||||
if exists('g:user_emmet_settings')
|
||||
call emmet#mergeConfig(s:emmet_settings, g:user_emmet_settings)
|
||||
endif
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
@@ -1,11 +1,11 @@
|
||||
let s:exists = {}
|
||||
function zencoding#lang#exists(type)
|
||||
function! emmet#lang#exists(type)
|
||||
if len(a:type) == 0
|
||||
return 0
|
||||
elseif has_key(s:exists, a:type)
|
||||
return s:exists[a:type]
|
||||
endif
|
||||
let s:exists[a:type] = len(globpath(&rtp, 'autoload/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]
|
||||
endfunction
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
function! zencoding#lang#css#findTokens(str)
|
||||
function! emmet#lang#css#findTokens(str)
|
||||
return substitute(a:str, '^.*[;{]\s*', '', '')
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#parseIntoTree(abbr, type)
|
||||
function! emmet#lang#css#parseIntoTree(abbr, type)
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
let prefix = 0
|
||||
let value = ''
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
let indent = zencoding#getIndentation(type)
|
||||
let aliases = zencoding#getResource(type, 'aliases', {})
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
let settings = emmet#getSettings()
|
||||
let indent = emmet#getIndentation(type)
|
||||
let aliases = emmet#getResource(type, 'aliases', {})
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
let root = { '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
|
||||
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 value = current.value[1:-2]
|
||||
if zencoding#useFilter(a:filters, 'fc')
|
||||
if emmet#useFilter(a:filters, 'fc')
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1: \2', 'g')
|
||||
else
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1:\2', 'g')
|
||||
@@ -129,25 +129,25 @@ function! zencoding#lang#css#toString(settings, current, type, inline, filters,
|
||||
return value
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#imageSize()
|
||||
function! emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#encodeImage()
|
||||
function! emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#parseTag(tag)
|
||||
function! emmet#lang#css#parseTag(tag)
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#toggleComment()
|
||||
function! emmet#lang#css#toggleComment()
|
||||
let line = getline('.')
|
||||
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
|
||||
if line =~ '{\s*$'
|
||||
let block = zencoding#util#searchRegion('/\*', '\*/\zs')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
let content = zencoding#util#getContent(block)
|
||||
let block = emmet#util#searchRegion('/\*', '\*/\zs')
|
||||
if emmet#util#regionIsValid(block)
|
||||
let content = emmet#util#getContent(block)
|
||||
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
|
||||
call zencoding#util#setContent(block, content)
|
||||
call emmet#util#setContent(block, content)
|
||||
else
|
||||
let node = expand('<cword>')
|
||||
if len(node)
|
||||
@@ -167,28 +167,28 @@ function! zencoding#lang#css#toggleComment()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#balanceTag(flag) range
|
||||
function! emmet#lang#css#balanceTag(flag) range
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if !emmet#util#regionIsValid(block)
|
||||
if a:flag > 0
|
||||
let block = zencoding#util#searchRegion('^', ';')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
let block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if a:flag > 0
|
||||
let content = zencoding#util#getContent(block)
|
||||
let content = emmet#util#getContent(block)
|
||||
if content !~ '^{.*}$'
|
||||
let block = zencoding#util#searchRegion('{', '}')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
let block = emmet#util#searchRegion('{', '}')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
@@ -196,9 +196,9 @@ function! zencoding#lang#css#balanceTag(flag) range
|
||||
let pos = searchpos('.*;', 'nW')
|
||||
if pos[0] != 0
|
||||
call setpos('.', [0, pos[0], pos[1], 0])
|
||||
let block = zencoding#util#searchRegion('^', ';')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
let block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
@@ -211,7 +211,7 @@ function! zencoding#lang#css#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#moveNextPrev(flag)
|
||||
function! emmet#lang#css#moveNextPrev(flag)
|
||||
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
@@ -221,10 +221,10 @@ function! zencoding#lang#css#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#splitJoinTag()
|
||||
function! emmet#lang#css#splitJoinTag()
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#removeTag()
|
||||
function! emmet#lang#css#removeTag()
|
||||
" nothing to do
|
||||
endfunction
|
||||
@@ -1,20 +1,20 @@
|
||||
function! zencoding#lang#haml#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
function! emmet#lang#haml#findTokens(str)
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#parseIntoTree(abbr, type)
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
function! emmet#lang#haml#parseIntoTree(abbr, type)
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
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 current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = zencoding#getIndentation(type)
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ""
|
||||
|
||||
let comment_indent = ''
|
||||
@@ -26,7 +26,7 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
||||
if len(current.name) > 0
|
||||
let str .= '%' . current_name
|
||||
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)
|
||||
continue
|
||||
endif
|
||||
@@ -92,7 +92,7 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
||||
endif
|
||||
elseif len(current.child) > 0
|
||||
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
|
||||
let inner = substitute(inner, "\n", "\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
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#imageSize()
|
||||
function! emmet#lang#haml#imageSize()
|
||||
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')
|
||||
return
|
||||
endif
|
||||
@@ -123,22 +123,22 @@ function! zencoding#lang#haml#imageSize()
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let haml = zencoding#toString(current, 'haml', 1)
|
||||
let haml = emmet#toString(current, 'haml', 1)
|
||||
let haml = substitute(haml, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", "", "g"))
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#encodeImage()
|
||||
function! emmet#lang#haml#encodeImage()
|
||||
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 mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
@@ -160,7 +160,7 @@ function! zencoding#lang#haml#parseTag(tag)
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#toggleComment()
|
||||
function! emmet#lang#haml#toggleComment()
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*-#'
|
||||
@@ -170,8 +170,8 @@ function! zencoding#lang#haml#toggleComment()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
function! emmet#lang#haml#balanceTag(flag) range
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
@@ -181,7 +181,7 @@ function! zencoding#lang#haml#balanceTag(flag) range
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
@@ -235,7 +235,7 @@ function! zencoding#lang#haml#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#moveNextPrev(flag)
|
||||
function! emmet#lang#haml#moveNextPrev(flag)
|
||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if pos != 0
|
||||
silent! normal! l
|
||||
@@ -243,7 +243,7 @@ function! zencoding#lang#haml#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#splitJoinTag()
|
||||
function! emmet#lang#haml#splitJoinTag()
|
||||
let n = line('.')
|
||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
while n > 0
|
||||
@@ -268,7 +268,7 @@ function! zencoding#lang#haml#splitJoinTag()
|
||||
else
|
||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
let settings = zencoding#getSettings()
|
||||
let settings = emmet#getSettings()
|
||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
||||
call append(sn, spaces . ' ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
@@ -283,7 +283,7 @@ function! zencoding#lang#haml#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#removeTag()
|
||||
function! emmet#lang#haml#removeTag()
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
@@ -12,7 +12,7 @@ let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
|
||||
\ .'\%(\*\([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 [pos, last_pos] = [0, 0]
|
||||
while 1
|
||||
@@ -37,24 +37,24 @@ function! zencoding#lang#html#findTokens(str)
|
||||
return a:str[last_pos :-1]
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
let settings = emmet#getSettings()
|
||||
if !has_key(settings, type)
|
||||
let type = 'html'
|
||||
endif
|
||||
if len(type) == 0 | let type = 'html' | endif
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
let indent = zencoding#getIndentation(type)
|
||||
let settings = emmet#getSettings()
|
||||
let indent = emmet#getIndentation(type)
|
||||
|
||||
" try 'foo' to (foo-x)
|
||||
let rabbr = zencoding#getExpandos(type, abbr)
|
||||
let rabbr = emmet#getExpandos(type, abbr)
|
||||
if rabbr == abbr
|
||||
" try 'foo+(' to (foo-x)
|
||||
let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".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
|
||||
let abbr = rabbr
|
||||
|
||||
@@ -98,15 +98,15 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
let current.important = important
|
||||
|
||||
" aliases
|
||||
let aliases = zencoding#getResource(type, 'aliases', {})
|
||||
let aliases = emmet#getResource(type, 'aliases', {})
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
|
||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
" snippets
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
if !empty(snippets) && has_key(snippets, tag_name)
|
||||
let snippet = snippets[tag_name]
|
||||
if use_pipe_for_cursor
|
||||
@@ -118,16 +118,16 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
let current.name = ''
|
||||
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')
|
||||
let custom_expands = settings['custom_expands']
|
||||
endif
|
||||
for k in keys(custom_expands)
|
||||
if tag_name =~ k
|
||||
if parent.name == ''
|
||||
let div = zencoding#lang#html#parseTag('<div/>')
|
||||
let div = emmet#lang#html#parseTag('<div/>')
|
||||
let div.value = '{\${' . tag_name . '}}'
|
||||
let current.snippet = zencoding#toString(div, type, 0, [])
|
||||
let current.snippet = emmet#toString(div, type, 0, [])
|
||||
else
|
||||
let current.snippet = '${' . tag_name . '}'
|
||||
endif
|
||||
@@ -137,7 +137,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
endfor
|
||||
|
||||
" default_attributes
|
||||
let default_attributes = zencoding#getResource(type, 'default_attributes', {})
|
||||
let default_attributes = emmet#getResource(type, 'default_attributes', {})
|
||||
if !empty(default_attributes)
|
||||
for pat in [current.name, tag_name]
|
||||
if has_key(default_attributes, pat)
|
||||
@@ -288,7 +288,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
endif
|
||||
let abbr = abbr[stridx(abbr, match) + len(match):]
|
||||
|
||||
if g:zencoding_debug > 1
|
||||
if g:emmet_debug > 1
|
||||
echomsg "str=".str
|
||||
echomsg "block_start=".block_start
|
||||
echomsg "tag_name=".tag_name
|
||||
@@ -305,7 +305,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
return root
|
||||
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 current = a:current
|
||||
let type = a:type
|
||||
@@ -313,13 +313,13 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
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')
|
||||
return zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
if emmet#useFilter(filters, 'haml')
|
||||
return emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
if zencoding#useFilter(filters, 'slim')
|
||||
return zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
if emmet#useFilter(filters, 'slim')
|
||||
return emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
|
||||
let comment = ''
|
||||
@@ -332,7 +332,8 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
||||
if len(current_name) == 0
|
||||
let text = current.value[1:-2]
|
||||
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, '\\\$', '$', 'g')
|
||||
endif
|
||||
@@ -340,19 +341,20 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
||||
endif
|
||||
if len(current_name) > 0
|
||||
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)
|
||||
continue
|
||||
endif
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
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
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let str .= ' ' . attr . '="' . val . '"'
|
||||
if zencoding#useFilter(filters, 'c')
|
||||
if emmet#useFilter(filters, 'c')
|
||||
if attr == 'id' | let comment .= '#' . val | endif
|
||||
if attr == 'class' | let comment .= '.' . val | endif
|
||||
endif
|
||||
@@ -366,7 +368,8 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
||||
let str .= ">"
|
||||
let text = current.value[1:-2]
|
||||
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, '\\\$', '$', '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
|
||||
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", "\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
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#imageSize()
|
||||
let img_region = zencoding#util#searchRegion('<img\s', '>')
|
||||
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
|
||||
function! emmet#lang#html#imageSize()
|
||||
let img_region = emmet#util#searchRegion('<img\s', '>')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = zencoding#util#getContent(img_region)
|
||||
let content = emmet#util#getContent(img_region)
|
||||
if content !~ '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = zencoding#lang#html#parseTag(content)
|
||||
let current = emmet#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
@@ -432,28 +435,28 @@ function! zencoding#lang#html#imageSize()
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let html = substitute(zencoding#toString(current, 'html', 1), '\n', '', '')
|
||||
let html = substitute(emmet#toString(current, 'html', 1), '\n', '', '')
|
||||
let html = substitute(html, '\${cursor}', '', '')
|
||||
call zencoding#util#setContent(img_region, html)
|
||||
call emmet#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#encodeImage()
|
||||
let img_region = zencoding#util#searchRegion('<img\s', '>')
|
||||
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
|
||||
function! emmet#lang#html#encodeImage()
|
||||
let img_region = emmet#util#searchRegion('<img\s', '>')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = zencoding#util#getContent(img_region)
|
||||
let content = emmet#util#getContent(img_region)
|
||||
if content !~ '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = zencoding#lang#html#parseTag(content)
|
||||
let current = emmet#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
@@ -462,17 +465,17 @@ function! zencoding#lang#html#encodeImage()
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let html = zencoding#toString(current, 'html', 1)
|
||||
call zencoding#util#setContent(img_region, html)
|
||||
let html = emmet#toString(current, 'html', 1)
|
||||
call emmet#util#setContent(img_region, html)
|
||||
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 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)
|
||||
@@ -494,22 +497,22 @@ function! zencoding#lang#html#parseTag(tag)
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#toggleComment()
|
||||
function! emmet#lang#html#toggleComment()
|
||||
let orgpos = getpos('.')
|
||||
let curpos = getpos('.')
|
||||
let mx = '<\%#[^>]*>'
|
||||
while 1
|
||||
let block = zencoding#util#searchRegion('<!--', '-->')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
let block = emmet#util#searchRegion('<!--', '-->')
|
||||
if emmet#util#regionIsValid(block)
|
||||
let block[1][1] += 2
|
||||
let content = zencoding#util#getContent(block)
|
||||
let content = emmet#util#getContent(block)
|
||||
let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
|
||||
call zencoding#util#setContent(block, content)
|
||||
call emmet#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
let block = zencoding#util#searchRegion('<[^>]', '>')
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
let block = emmet#util#searchRegion('<[^>]', '>')
|
||||
if !emmet#util#regionIsValid(block)
|
||||
let pos1 = searchpos('<', 'bcW')
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
return
|
||||
@@ -519,7 +522,7 @@ function! zencoding#lang#html#toggleComment()
|
||||
endif
|
||||
let pos1 = block[0]
|
||||
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>]\+')
|
||||
if tag_name[0] == '/'
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
@@ -527,12 +530,12 @@ function! zencoding#lang#html#toggleComment()
|
||||
let pos1 = searchpos('>', 'cneW')
|
||||
let block = [pos2, pos1]
|
||||
elseif tag_name =~ '/$'
|
||||
if !zencoding#util#pointInRegion(orgpos[1:2], block)
|
||||
if !emmet#util#pointInRegion(orgpos[1:2], block)
|
||||
" it's broken tree
|
||||
call setpos('.', orgpos)
|
||||
let block = zencoding#util#searchRegion('>', '<')
|
||||
let content = '><!-- ' . zencoding#util#getContent(block)[1:-2] . ' --><'
|
||||
call zencoding#util#setContent(block, content)
|
||||
let block = emmet#util#searchRegion('>', '<')
|
||||
let content = '><!-- ' . emmet#util#getContent(block)[1:-2] . ' --><'
|
||||
call emmet#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
@@ -543,27 +546,27 @@ function! zencoding#lang#html#toggleComment()
|
||||
let pos2 = searchpos('>', 'neW')
|
||||
let block = [pos1, pos2]
|
||||
endif
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
if !emmet#util#regionIsValid(block)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block)
|
||||
let content = '<!-- ' . zencoding#util#getContent(block) . ' -->'
|
||||
call zencoding#util#setContent(block, content)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block)
|
||||
let content = '<!-- ' . emmet#util#getContent(block) . ' -->'
|
||||
call emmet#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#balanceTag(flag) range
|
||||
let vblock = zencoding#util#getVisualBlock()
|
||||
function! emmet#lang#html#balanceTag(flag) range
|
||||
let vblock = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let settings = zencoding#getSettings()
|
||||
let settings = emmet#getSettings()
|
||||
|
||||
if a:flag > 0
|
||||
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
|
||||
break
|
||||
endif
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block) && emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
@@ -593,8 +596,8 @@ function! zencoding#lang#html#balanceTag(flag) range
|
||||
let pos1 = searchpos(mx . '\zs', 'W')
|
||||
let pos2 = searchpos('.\ze<', 'W')
|
||||
let block = [pos1, pos2]
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
@@ -609,8 +612,8 @@ function! zencoding#lang#html#balanceTag(flag) range
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
@@ -622,7 +625,7 @@ function! zencoding#lang#html#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#moveNextPrev(flag)
|
||||
function! emmet#lang#html#moveNextPrev(flag)
|
||||
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 3
|
||||
startinsert!
|
||||
@@ -632,7 +635,7 @@ function! zencoding#lang#html#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#splitJoinTag()
|
||||
function! emmet#lang#html#splitJoinTag()
|
||||
let curpos = getpos('.')
|
||||
while 1
|
||||
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 tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
||||
if content[-2:] == '/>' && emmet#util#cursorInRegion(block)
|
||||
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])
|
||||
return
|
||||
else
|
||||
@@ -654,10 +657,10 @@ function! zencoding#lang#html#splitJoinTag()
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = zencoding#util#getContent(block)
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
let content = emmet#util#getContent(block)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
let content = matchstr(content, mx)[:-2] . '/>'
|
||||
call zencoding#util#setContent(block, content)
|
||||
call emmet#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
@@ -672,7 +675,7 @@ function! zencoding#lang#html#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#removeTag()
|
||||
function! emmet#lang#html#removeTag()
|
||||
let curpos = getpos('.')
|
||||
while 1
|
||||
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 tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
||||
call zencoding#util#setContent(block, '')
|
||||
if content[-2:] == '/>' && emmet#util#cursorInRegion(block)
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
@@ -693,9 +696,9 @@ function! zencoding#lang#html#removeTag()
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = zencoding#util#getContent(block)
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
call zencoding#util#setContent(block, '')
|
||||
let content = emmet#util#getContent(block)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
@@ -1,16 +1,16 @@
|
||||
function! zencoding#lang#sass#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
function! emmet#lang#sass#findTokens(str)
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#parseIntoTree(abbr, type)
|
||||
function! emmet#lang#sass#parseIntoTree(abbr, type)
|
||||
if a:abbr =~ '>'
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
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 current = a:current
|
||||
let type = a:type
|
||||
@@ -50,33 +50,33 @@ function! zencoding#lang#sass#toString(settings, current, type, inline, filters,
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
||||
let inner = substitute(inner, "\n" . indent . "$", "", 'g')
|
||||
let str .= indent . inner
|
||||
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')
|
||||
return text
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#imageSize()
|
||||
function! emmet#lang#sass#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#encodeImage()
|
||||
function! emmet#lang#sass#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#parseTag(tag)
|
||||
function! emmet#lang#sass#parseTag(tag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#toggleComment()
|
||||
function! emmet#lang#sass#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
function! emmet#lang#sass#balanceTag(flag) range
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
@@ -86,7 +86,7 @@ function! zencoding#lang#sass#balanceTag(flag) range
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
@@ -140,7 +140,7 @@ function! zencoding#lang#sass#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#moveNextPrev(flag)
|
||||
function! emmet#lang#sass#moveNextPrev(flag)
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
@@ -150,8 +150,8 @@ function! zencoding#lang#sass#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#splitJoinTag()
|
||||
function! emmet#lang#sass#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#removeTag()
|
||||
function! emmet#lang#sass#removeTag()
|
||||
endfunction
|
||||
@@ -1,16 +1,16 @@
|
||||
function! zencoding#lang#scss#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
function! emmet#lang#scss#findTokens(str)
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#parseIntoTree(abbr, type)
|
||||
function! emmet#lang#scss#parseIntoTree(abbr, type)
|
||||
if a:abbr =~ '>'
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
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 current = a:current
|
||||
let type = a:type
|
||||
@@ -49,34 +49,34 @@ function! zencoding#lang#scss#toString(settings, current, type, inline, filters,
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
|
||||
let str .= indent . inner . "\n}\n"
|
||||
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
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#imageSize()
|
||||
call zencoding#lang#css#imageSize()
|
||||
function! emmet#lang#scss#imageSize()
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#encodeImage()
|
||||
return zencoding#lang#css#encodeImage()
|
||||
function! emmet#lang#scss#encodeImage()
|
||||
return emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#parseTag(tag)
|
||||
return zencoding#lang#css#parseTag(a:tag)
|
||||
function! emmet#lang#scss#parseTag(tag)
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#toggleComment()
|
||||
call zencoding#lang#css#toggleComment()
|
||||
function! emmet#lang#scss#toggleComment()
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#balanceTag(flag) range
|
||||
function! emmet#lang#scss#balanceTag(flag) range
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
call setpos('.', curpos)
|
||||
@@ -96,8 +96,8 @@ function! zencoding#lang#scss#balanceTag(flag) range
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
@@ -108,14 +108,14 @@ function! zencoding#lang#scss#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#moveNextPrev(flag)
|
||||
call zencoding#lang#css#moveNextPrev(a:flag)
|
||||
function! emmet#lang#scss#moveNextPrev(flag)
|
||||
call emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#splitJoinTag()
|
||||
call zencoding#lang#css#splitJoinTag()
|
||||
function! emmet#lang#scss#splitJoinTag()
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#removeTag()
|
||||
call zencoding#lang#ss#removeTag()
|
||||
function! emmet#lang#scss#removeTag()
|
||||
call emmet#lang#ss#removeTag()
|
||||
endfunction
|
||||
@@ -1,20 +1,20 @@
|
||||
function! zencoding#lang#slim#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
function! emmet#lang#slim#findTokens(str)
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#parseIntoTree(abbr, type)
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
function! emmet#lang#slim#parseIntoTree(abbr, type)
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
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 current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = zencoding#getIndentation(type)
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ""
|
||||
|
||||
let comment_indent = ''
|
||||
@@ -25,7 +25,7 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
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)
|
||||
continue
|
||||
endif
|
||||
@@ -68,7 +68,7 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
||||
endfor
|
||||
elseif len(current.child) > 0
|
||||
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
|
||||
let inner = substitute(inner, "\n", "\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
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#imageSize()
|
||||
function! emmet#lang#slim#imageSize()
|
||||
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')
|
||||
return
|
||||
endif
|
||||
@@ -101,22 +101,22 @@ function! zencoding#lang#slim#imageSize()
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let slim = zencoding#toString(current, 'slim', 1)
|
||||
let slim = emmet#toString(current, 'slim', 1)
|
||||
let slim = substitute(slim, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", "", "g"))
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#encodeImage()
|
||||
function! emmet#lang#slim#encodeImage()
|
||||
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 mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
@@ -138,7 +138,7 @@ function! zencoding#lang#slim#parseTag(tag)
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#toggleComment()
|
||||
function! emmet#lang#slim#toggleComment()
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*/'
|
||||
@@ -148,8 +148,8 @@ function! zencoding#lang#slim#toggleComment()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
function! emmet#lang#slim#balanceTag(flag) range
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
@@ -159,7 +159,7 @@ function! zencoding#lang#slim#balanceTag(flag) range
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
@@ -213,7 +213,7 @@ function! zencoding#lang#slim#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#moveNextPrev(flag)
|
||||
function! emmet#lang#slim#moveNextPrev(flag)
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
@@ -223,7 +223,7 @@ function! zencoding#lang#slim#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#splitJoinTag()
|
||||
function! emmet#lang#slim#splitJoinTag()
|
||||
let n = line('.')
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
@@ -249,7 +249,7 @@ function! zencoding#lang#slim#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#removeTag()
|
||||
function! emmet#lang#slim#removeTag()
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
@@ -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 = wcount > 0 ? wcount : 30
|
||||
|
||||
@@ -39,19 +39,19 @@ function! zencoding#lorem#en#expand(command)
|
||||
if sentence > 0
|
||||
let arr += words
|
||||
endif
|
||||
let r = zencoding#util#rand()
|
||||
let r = emmet#util#rand()
|
||||
let word = arr[r % len(arr)]
|
||||
if sentence == 0
|
||||
let word = substitute(word, '^.', '\U&', '')
|
||||
endif
|
||||
let sentence += 1
|
||||
call add(ret, word)
|
||||
if (sentence > 5 && zencoding#util#rand() < 10000) || i == wcount - 1
|
||||
if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1
|
||||
if i == wcount - 1
|
||||
let endc = "?!..."[zencoding#util#rand() % 5]
|
||||
let endc = "?!..."[emmet#util#rand() % 5]
|
||||
call add(ret, endc)
|
||||
else
|
||||
let endc = "?!,..."[zencoding#util#rand() % 6]
|
||||
let endc = "?!,..."[emmet#util#rand() % 6]
|
||||
call add(ret, endc . ' ')
|
||||
endif
|
||||
if endc != ','
|
||||
@@ -1,19 +1,19 @@
|
||||
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 = wcount > 0 ? wcount : 30
|
||||
|
||||
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
|
||||
let content = zencoding#util#getContentFromURL(url)
|
||||
let content = emmet#util#getContentFromURL(url)
|
||||
let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>')
|
||||
let content = substitute(content, '[ \r]', '', 'g')
|
||||
let content = substitute(content, '<br[^>]*>', "\n", 'g')
|
||||
let content = substitute(content, '<[^>]\+>', '', 'g')
|
||||
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
|
||||
|
||||
let content = substitute(content, "、\n", "、", "g")
|
||||
@@ -22,6 +22,6 @@ function! zencoding#lorem#ja#expand(command)
|
||||
if len(lines) == 0
|
||||
let lines = clines
|
||||
endif
|
||||
let r = zencoding#util#rand()
|
||||
let r = emmet#util#rand()
|
||||
return lines[r % len(lines)]
|
||||
endfunction
|
||||
@@ -11,7 +11,7 @@
|
||||
" --------------------
|
||||
" begin::end
|
||||
" --------------------
|
||||
function! zencoding#util#deleteContent(region)
|
||||
function! emmet#util#deleteContent(region)
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
|
||||
@@ -36,7 +36,7 @@ endfunction
|
||||
" bar
|
||||
" baz:end
|
||||
" --------------------
|
||||
function! zencoding#util#setContent(region, content)
|
||||
function! emmet#util#setContent(region, content)
|
||||
let newlines = split(a:content, '\n', 1)
|
||||
let oldlines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
@@ -72,7 +72,7 @@ endfunction
|
||||
|
||||
" select_region : select 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])
|
||||
normal! v
|
||||
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
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#pointInRegion(point, region)
|
||||
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
|
||||
function! emmet#util#pointInRegion(point, region)
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
if a:region[0][0] > a:point[0] | return 0 | endif
|
||||
if a:region[1][0] < a:point[0] | return 0 | endif
|
||||
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
|
||||
@@ -91,29 +91,29 @@ endfunction
|
||||
|
||||
" cursor_in_region : check cursor is in the region
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#cursorInRegion(region)
|
||||
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
|
||||
function! emmet#util#cursorInRegion(region)
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
let cur = getpos('.')[1:2]
|
||||
return zencoding#util#pointInRegion(cur, a:region)
|
||||
return emmet#util#pointInRegion(cur, a:region)
|
||||
endfunction
|
||||
|
||||
" region_is_valid : check region is valid
|
||||
" 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
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" search_region : make region from pattern which is composing start/end
|
||||
" 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')]
|
||||
endfunction
|
||||
|
||||
" get_content : get content in region
|
||||
" this function return string in region
|
||||
function! zencoding#util#getContent(region)
|
||||
if !zencoding#util#regionIsValid(a:region)
|
||||
function! emmet#util#getContent(region)
|
||||
if !emmet#util#regionIsValid(a:region)
|
||||
return ''
|
||||
endif
|
||||
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
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#regionInRegion(outer, inner)
|
||||
if !zencoding#util#regionIsValid(a:inner) || !zencoding#util#regionIsValid(a:outer)
|
||||
function! emmet#util#regionInRegion(outer, inner)
|
||||
if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer)
|
||||
return 0
|
||||
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
|
||||
|
||||
" get_visualblock : get region of visual block
|
||||
" this function return region of visual block
|
||||
function! zencoding#util#getVisualBlock()
|
||||
function! emmet#util#getVisualBlock()
|
||||
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
|
||||
endfunction
|
||||
|
||||
"==============================================================================
|
||||
" html utils
|
||||
"==============================================================================
|
||||
function! zencoding#util#getContentFromURL(url)
|
||||
let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
||||
function! emmet#util#getContentFromURL(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["''][^>]*>')
|
||||
if len(charset) == 0
|
||||
let charset = matchstr(res, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>')
|
||||
@@ -159,7 +159,7 @@ function! zencoding#util#getContentFromURL(url)
|
||||
return iconv(res, charset, &encoding)
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#getTextFromHTML(buf)
|
||||
function! emmet#util#getTextFromHTML(buf)
|
||||
let threshold_len = 100
|
||||
let threshold_per = 0.1
|
||||
let buf = a:buf
|
||||
@@ -196,17 +196,17 @@ function! zencoding#util#getTextFromHTML(buf)
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#getImageSize(fn)
|
||||
function! emmet#util#getImageSize(fn)
|
||||
let fn = a:fn
|
||||
|
||||
if zencoding#util#isImageMagickInstalled()
|
||||
return zencoding#util#imageSizeWithImageMagick(fn)
|
||||
if emmet#util#isImageMagickInstalled()
|
||||
return emmet#util#imageSizeWithImageMagick(fn)
|
||||
endif
|
||||
|
||||
if filereadable(fn)
|
||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||
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
|
||||
|
||||
let [width, height] = [-1, -1]
|
||||
@@ -240,7 +240,7 @@ function! zencoding#util#getImageSize(fn)
|
||||
return [width, height]
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#imageSizeWithImageMagick(fn)
|
||||
function! emmet#util#imageSizeWithImageMagick(fn)
|
||||
let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
|
||||
let img_size = split(substitute(img_info, '\n', '', ''), 'x')
|
||||
let width = img_size[0]
|
||||
@@ -248,14 +248,14 @@ function! zencoding#util#imageSizeWithImageMagick(fn)
|
||||
return [width, height]
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#isImageMagickInstalled()
|
||||
if !get(s:, 'zencoding_use_identify', 1)
|
||||
function! emmet#util#isImageMagickInstalled()
|
||||
if !get(s:, 'emmet_use_identify', 1)
|
||||
return 0
|
||||
endif
|
||||
return executable('identify')
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#unique(arr)
|
||||
function! emmet#util#unique(arr)
|
||||
let m = {}
|
||||
let r = []
|
||||
for i in a:arr
|
||||
@@ -268,18 +268,18 @@ function! zencoding#util#unique(arr)
|
||||
endfunction
|
||||
|
||||
let s:seed = localtime()
|
||||
function! zencoding#util#srand(seed)
|
||||
function! emmet#util#srand(seed)
|
||||
let s:seed = a:seed
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#rand()
|
||||
function! emmet#util#rand()
|
||||
let s:seed = s:seed * 214013 + 2531011
|
||||
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#cache(name, ...)
|
||||
function! emmet#util#cache(name, ...)
|
||||
let content = get(a:000, 0, "")
|
||||
let dir = expand("~/.zencoding/cache")
|
||||
let dir = expand("~/.emmet/cache")
|
||||
if !isdirectory(dir)
|
||||
call mkdir(dir, "p", 0700)
|
||||
endif
|
||||
Reference in New Issue
Block a user