Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bundle update

  • Loading branch information...
commit e2cf82391fd5971364342d838f1821ef0ab33f3f 1 parent 82d49ff
@gabesoft authored
Showing with 2,978 additions and 1,582 deletions.
  1. +4 −3 .bashrc
  2. +1 −1  .gitconfig
  3. +13 −13 .gitconfig.view
  4. +5 −4 .vim/bundle/neocomplcache/doc/neocomplcache.txt
  5. +2 −0  .vim/bundle/snipmate.vim/snippets/javascript.snippets
  6. +43 −12 .vim/bundle/zencoding-vim/README.mkd
  7. 0  .vim/bundle/zencoding-vim/TODO
  8. +264 −1,030 .vim/bundle/zencoding-vim/autoload/zencoding.vim
  9. +11 −0 .vim/bundle/zencoding-vim/autoload/zencoding/lang.vim
  10. +157 −0 .vim/bundle/zencoding-vim/autoload/zencoding/lang/css.vim
  11. +303 −0 .vim/bundle/zencoding-vim/autoload/zencoding/lang/haml.vim
  12. +673 −0 .vim/bundle/zencoding-vim/autoload/zencoding/lang/html.vim
  13. +157 −0 .vim/bundle/zencoding-vim/autoload/zencoding/lang/sass.vim
  14. +122 −0 .vim/bundle/zencoding-vim/autoload/zencoding/lang/scss.vim
  15. +269 −0 .vim/bundle/zencoding-vim/autoload/zencoding/lang/slim.vim
  16. +230 −0 .vim/bundle/zencoding-vim/autoload/zencoding/util.vim
  17. +46 −1 .vim/bundle/zencoding-vim/doc/zencoding.txt
  18. +13 −10 .vim/bundle/zencoding-vim/plugin/zencoding.vim
  19. +640 −498 .vim/bundle/zencoding-vim/unittest.vim
  20. +15 −1 .vim/bundle/zencoding-vim/zencoding.vim.vimup
  21. +1 −0  .vimrc
  22. +9 −9 .vimrc.view
View
7 .bashrc
@@ -144,17 +144,18 @@ alias gst='git st'
alias gsu='git su'
alias gundo='git undo'
+# delete files matching pattern in all subfolders recursively
function delrec() {
find . -name "$1" -print0 | xargs -0 rm -rfv ;
}
-alias delf='delrec' # delete files matching pattern in all subfolders recursively
+alias delf='delrec'
-# reverse
+# reverse of cat
tacf () {
awk '1 { last = NR; line[last] = $0; } END { for (i = last; i > 0; i--) { print line[i]; } }'
}
-
alias tac='tacf'
+export -f tacf
# paths
alias print-path='echo -e ${PATH//:/\\n}'
View
2  .gitconfig
@@ -43,7 +43,7 @@
st = status
su = stash ; stash push
undo = reset --hard HEAD~
- alias = !cat ~/.gitconfig | awk '/^[ \t]{2}[a-z]+[ \t]{2,4}=/'
+ ;alias = !cat ~/.gitconfig | awk '/^[ \t]{2}[a-z]+[ \t]{2,4}=/' | sort
[core]
editor = mvim -f
View
26 .gitconfig.view
@@ -29,7 +29,7 @@ setlocal dictionary=
setlocal nodiff
setlocal equalprg=
setlocal errorformat=
-setlocal expandtab
+setlocal noexpandtab
if &filetype != 'gitconfig'
setlocal filetype=gitconfig
endif
@@ -47,8 +47,8 @@ setlocal formatexpr=
setlocal formatoptions=croql
setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s*
setlocal grepprg=
-setlocal iminsert=0
-setlocal imsearch=0
+setlocal iminsert=2
+setlocal imsearch=2
setlocal include=
setlocal includeexpr=
setlocal indentexpr=GetGitconfigIndent()
@@ -58,7 +58,7 @@ setlocal iskeyword=@,48-57,192-255,-
setlocal keywordprg=
setlocal linebreak
setlocal nolisp
-setlocal nolist
+setlocal list
setlocal macmeta
setlocal makeprg=
setlocal matchpairs=(:),{:},[:]
@@ -67,7 +67,7 @@ setlocal modifiable
setlocal nrformats=octal,hex
setlocal number
setlocal numberwidth=4
-setlocal omnifunc=zencoding#CompleteTag
+setlocal omnifunc=javascriptcomplete#CompleteJS
setlocal path=
setlocal nopreserveindent
setlocal nopreviewwindow
@@ -77,10 +77,10 @@ setlocal norelativenumber
setlocal norightleft
setlocal rightleftcmd=search
setlocal noscrollbind
-setlocal shiftwidth=2
+setlocal shiftwidth=4
setlocal noshortname
-setlocal nosmartindent
-setlocal softtabstop=2
+setlocal smartindent
+setlocal softtabstop=4
setlocal nospell
setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+
setlocal spellfile=
@@ -92,7 +92,7 @@ setlocal synmaxcol=3000
if &syntax != 'gitconfig'
setlocal syntax=gitconfig
endif
-setlocal tabstop=2
+setlocal tabstop=4
setlocal tags=
setlocal textwidth=0
setlocal thesaurus=
@@ -102,13 +102,13 @@ setlocal nowinfixwidth
setlocal nowrap
setlocal wrapmargin=0
silent! normal! zE
-let s:l = 1 - ((0 * winheight(0) + 30) / 60)
+let s:l = 46 - ((28 * winheight(0) + 16) / 33)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
-1
-normal! 0
-lcd /apps/blogmon/lib
+46
+normal! 038l
+lcd /gree/MLB
let &so = s:so_save | let &siso = s:siso_save
doautoall SessionLoadPost
" vim: set ft=vim :
View
9 .vim/bundle/neocomplcache/doc/neocomplcache.txt
@@ -1115,9 +1115,10 @@ include_complete.vim *include_complete*
not need to prepare a tags file and a dictionary file.
But it is necessary for 'path' and 'include',
'includeexpr' to be set adequately.
- Note: If vimproc is installed, neocomplcache will cache. But
- if not installed, auto caching feature is disabled. Please
- execute |:NeoComplCacheCachingInclude| manually.
+
+ Note: If you have vimproc installed, neocomplcache will cache
+ automatically. Otherwise it won't; please execute
+ |:NeoComplCacheCachingInclude| manually.
vim_complete.vim *vim_complete*
This source analyzes context and start Omni completion of
@@ -1489,7 +1490,7 @@ ChangeLog neocomplcache 7.1:
- Fixed neocomplcache#complete_common_string().
2012-08-25
-- Deleted obsolute changelog.
+- Deleted obsolete changelog.
2012-08-24
- Added FAQ item.
View
2  .vim/bundle/snipmate.vim/snippets/javascript.snippets
@@ -116,3 +116,5 @@ snippet /
*/
snippet todo
// TODO: ${1}
+snippet exp
+ module.exports = ${1:exp};${2}
View
55 .vim/bundle/zencoding-vim/README.mkd
@@ -1,12 +1,10 @@
-ZenCoding-vim
-====
+# ZenCoding-vim
+
[zencoding-vim](http://mattn.github.com/zencoding-vim) is vim script support for expanding abbreviation like zen-coding.
-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
unzip zencoding-vim.zip
@@ -29,8 +27,7 @@ or:
cp autoload/zencoding.vim ~/.vim/autoload/
-Quick Tutorial
----
+## Quick Tutorial
Open or create New File:
@@ -53,10 +50,44 @@ Then type "<c-y>," (Ctrl + y + ','), you should see:
</body>
</html>
-[More
-Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL)
+[More Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL)
+
+## Project Authors
-Project Authors
----
[Yasuhiro Matsumoto](http://mattn.kaoriya.net/)
+
+## Links
+
+### zen-coding official site:
+
+> <http://code.google.com/p/zen-coding/>
+
+### zencoding.vim:
+
+> <http://mattn.github.com/zencoding-vim>
+
+### development repository:
+
+> <https://github.com/mattn/zencoding-vim>
+
+### my blog posts about zencoding-vim:
+
+> <http://mattn.kaoriya.net/software/vim/20100222103327.htm>
+
+> <http://mattn.kaoriya.net/software/vim/20100306021632.htm>
+
+### japanese blog posts about zencoding-vim:
+
+> <http://d.hatena.ne.jp/idesaku/20100424/1272092255>
+
+> <http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding>
+
+> <http://d.hatena.ne.jp/sakurako_s/20110126/1295988873>
+
+> <http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html>
+
+### tutorial traslated in chinese:
+
+> <http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html>
+
View
0  .vim/bundle/zencoding-vim/TODO
No changes.
View
1,294 .vim/bundle/zencoding-vim/autoload/zencoding.vim
@@ -1,29 +1,56 @@
"=============================================================================
" zencoding.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
-" Last Change: 06-May-2012.
+" Last Change: 24-Jul-2012.
let s:save_cpo = &cpo
set cpo&vim
-function! s:zen_getExpandos(type, key)
- let expandos = s:zen_getResource(a:type, 'expandos', {})
+function! zencoding#getExpandos(type, key)
+ let expandos = zencoding#getResource(a:type, 'expandos', {})
if has_key(expandos, a:key)
return expandos[a:key]
endif
return a:key
endfunction
-function! s:zen_useFilter(filters, filter)
+function! zencoding#splitFilterArg(filters)
for f in a:filters
- if f == a:filter
+ if f =~ '^/'
+ return f[1:]
+ endif
+ endfor
+ return ''
+endfunction
+
+function! zencoding#useFilter(filters, filter)
+ for f in a:filters
+ if a:filter == '/' && f =~ '^/'
+ return 1
+ elseif f == a:filter
return 1
endif
endfor
return 0
endfunction
-function! s:zen_isExtends(type, extend)
+function! zencoding#getIndentation(...)
+ if a:0 > 0
+ let type = a:1
+ else
+ let type = zencoding#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
+ else
+ let indent = (&l:expandtab || &l:tabstop != &l:shiftwidth) ? repeat(' ', &l:shiftwidth) : "\t"
+ endif
+ return indent
+endfunction
+
+function! zencoding#isExtends(type, extend)
if a:type == a:extend
return 1
endif
@@ -47,285 +74,14 @@ function! s:zen_isExtends(type, extend)
return 0
endfunction
-function! s:zen_parseIntoTree(abbr, type)
+function! zencoding#parseIntoTree(abbr, type)
let abbr = a:abbr
let type = a:type
- if !has_key(s:zen_settings, type)
- let type = 'html'
- endif
- if len(type) == 0 | let type = 'html' | endif
-
- if has_key(s:zen_settings[type], 'indentation')
- let indent = s:zen_settings[type].indentation
- else
- let indent = s:zen_settings.indentation
- endif
-
- if s:zen_isExtends(type, "html")
- " try 'foo' to (foo-x)
- let rabbr = s:zen_getExpandos(type, abbr)
- if rabbr == abbr
- " try 'foo+(' to (foo-x)
- let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".s:zen_getExpandos(type, submatch(1)).")".submatch(2)', 'i')
- endif
- let abbr = rabbr
- let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|'
- \ .'{.\{-}}[ \t\r\n}]*\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|'
- \ .'#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|'
- \ .'\%(\.{[{}a-zA-Z0-9_\-\$]\+\|'
- \ .'\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\+\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)'
- else
- let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\+\-]*\|'
- \ .'{\+.\{-}}[ \t\r\n}]*\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|'
- \ .'#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|'
- \ .'\%(\.{[{}a-zA-Z0-9_\-\$]\+\|'
- \ .'\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\+\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)'
- endif
- let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
- let parent = root
- let last = root
- let pos = []
- while len(abbr)
- " parse line
- let match = matchstr(abbr, mx)
- let str = substitute(match, mx, '\0', 'ig')
- let operator = substitute(match, mx, '\1', 'ig')
- let block_start = substitute(match, mx, '\2', 'ig')
- let tag_name = substitute(match, mx, '\3', 'ig')
- let attributes = substitute(match, mx, '\4', 'ig')
- let value = substitute(match, mx, '\5', 'ig')
- let multiplier = 0 + substitute(match, mx, '\6', 'ig')
- let block_end = substitute(match, mx, '\7', 'ig')
- let important = 0
- if len(str) == 0
- break
- endif
- if tag_name =~ '^#'
- let attributes = tag_name . attributes
- let tag_name = 'div'
- endif
- if tag_name =~ '.!$'
- let tag_name = tag_name[:-2]
- let important = 1
- endif
- if tag_name =~ '^\.'
- let attributes = tag_name . attributes
- let tag_name = 'div'
- endif
- if multiplier <= 0 | let multiplier = 1 | endif
-
- " make default node
- let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
- let current.name = tag_name
-
- let current.important = important
-
- " aliases
- let aliases = s:zen_getResource(type, 'aliases', {})
- if has_key(aliases, tag_name)
- let current.name = aliases[tag_name]
- endif
-
- let use_pipe_for_cursor = s:zen_getResource(type, 'use_pipe_for_cursor', 1)
-
- " snippets
- let snippets = s:zen_getResource(type, 'snippets', {})
- if !empty(snippets) && has_key(snippets, tag_name)
- let snippet = snippets[tag_name]
- if use_pipe_for_cursor
- let snippet = substitute(snippet, '|', '${cursor}', 'g')
- endif
- let lines = split(snippet, "\n")
- call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", indent, "g")')
- let current.snippet = join(lines, "\n")
- let current.name = ''
- endif
-
- " default_attributes
- let default_attributes = s:zen_getResource(type, 'default_attributes', {})
- if !empty(default_attributes)
- for pat in [current.name, tag_name]
- if has_key(default_attributes, pat)
- if type(default_attributes[pat]) == 4
- let a = default_attributes[pat]
- if use_pipe_for_cursor
- for k in keys(a)
- let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
- endfor
- else
- for k in keys(a)
- let current.attr[k] = a[k]
- endfor
- endif
- else
- for a in default_attributes[pat]
- if use_pipe_for_cursor
- for k in keys(a)
- let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
- endfor
- else
- for k in keys(a)
- let current.attr[k] = a[k]
- endfor
- endif
- endfor
- endif
- if has_key(s:zen_settings.html.default_attributes, current.name)
- let current.name = substitute(current.name, ':.*$', '', '')
- endif
- break
- endif
- endfor
- endif
-
- " parse attributes
- if len(attributes)
- let attr = attributes
- while len(attr)
- let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
- if len(item) == 0
- break
- endif
- if item[0] == '#'
- let current.attr.id = item[1:]
- endif
- if item[0] == '.'
- let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
- endif
- if item[0] == '['
- let atts = item[1:-2]
- while len(atts)
- let amat = matchstr(atts, '\(\w\+\%(="[^"]*"\|=''[^'']*''\|[^ ''"\]]*\)\{0,1}\)')
- if len(amat) == 0
- break
- endif
- let key = split(amat, '=')[0]
- let val = amat[len(key)+1:]
- if val =~ '^["'']'
- let val = val[1:-2]
- endif
- let current.attr[key] = val
- let atts = atts[stridx(atts, amat) + len(amat):]
- endwhile
- endif
- let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
- endwhile
- endif
-
- " parse text
- if tag_name =~ '^{.*}$'
- let current.name = ''
- let current.value = tag_name
- else
- let current.value = value
- endif
- let current.multiplier = multiplier
-
- " parse step inside/outside
- if !empty(last)
- if operator =~ '>'
- unlet! parent
- let parent = last
- let current.parent = last
- let current.pos = last.pos + 1
- else
- let current.parent = parent
- let current.pos = last.pos
- endif
- else
- let current.parent = parent
- let current.pos = 1
- endif
- if operator =~ '<'
- for c in range(len(operator))
- let tmp = parent.parent
- if empty(tmp)
- break
- endif
- let parent = tmp
- endfor
- endif
-
- call add(parent.child, current)
- let last = current
-
- " parse block
- if block_start =~ '('
- if operator =~ '>'
- let last.pos += 1
- endif
- for n in range(len(block_start))
- let pos += [last.pos]
- endfor
- endif
- if block_end =~ ')'
- for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',')
- if n == ')'
- if len(pos) > 0 && last.pos >= pos[-1]
- for c in range(last.pos - pos[-1])
- let tmp = parent.parent
- if !has_key(tmp, 'parent')
- break
- endif
- let parent = tmp
- endfor
- if operator =~ '>'
- call remove(pos, -1)
- endif
- let last = parent
- let last.pos += 1
- endif
- elseif len(n)
- let cl = last.child
- let cls = []
- for c in range(n[1:])
- let cls += cl
- endfor
- let last.child = cls
- endif
- endfor
- endif
- let abbr = abbr[stridx(abbr, match) + len(match):]
-
- if g:zencoding_debug > 1
- echomsg "str=".str
- echomsg "block_start=".block_start
- echomsg "tag_name=".tag_name
- echomsg "operator=".operator
- echomsg "attributes=".attributes
- echomsg "value=".value
- echomsg "multiplier=".multiplier
- echomsg "block_end=".block_end
- echomsg "abbr=".abbr
- echomsg "pos=".string(pos)
- echomsg "---"
- endif
- endwhile
- return root
-endfunction
-
-function! s:zen_parseTag(tag)
- let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
- let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
- let match = matchstr(a:tag, mx)
- let current.name = substitute(match, mx, '\1', 'i')
- let attrs = substitute(match, mx, '\2', 'i')
- let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
- while len(attrs) > 0
- let match = matchstr(attrs, mx)
- if len(match) == 0
- break
- endif
- let attr_match = matchlist(match, mx)
- let name = attr_match[1]
- let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
- let current.attr[name] = value
- let attrs = attrs[stridx(attrs, match) + len(match):]
- endwhile
- return current
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#parseIntoTree(abbr, type)
endfunction
-function! s:zen_mergeConfig(lhs, rhs)
+function! s:mergeConfig(lhs, rhs)
if type(a:lhs) == 3 && type(a:rhs) == 3
let a:lhs += a:rhs
if len(a:lhs)
@@ -343,7 +99,7 @@ function! s:zen_mergeConfig(lhs, rhs)
let a:lhs[key] += a:rhs[key]
elseif type(a:rhs[key]) == 4
if has_key(a:lhs, key)
- call s:zen_mergeConfig(a:lhs[key], a:rhs[key])
+ call s:mergeConfig(a:lhs[key], a:rhs[key])
else
let a:lhs[key] = a:rhs[key]
endif
@@ -354,183 +110,13 @@ function! s:zen_mergeConfig(lhs, rhs)
endif
endfunction
-function! s:zen_toString_haml(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 = a:indent
- let str = ""
-
- let comment_indent = ''
- let comment = ''
- let current_name = current.name
- let current_name = substitute(current.name, '\$$', itemno+1, '')
- if len(current.name) > 0
- let str .= '%' . current_name
- let tmp = ''
- for attr in keys(current.attr)
- let val = current.attr[attr]
- while val =~ '\$\([^#{]\|$\)'
- let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
- endwhile
- let attr = substitute(attr, '\$$', itemno+1, '')
- if attr == 'id'
- let str .= '#' . val
- elseif attr == 'class'
- let str .= '.' . substitute(val, ' ', '.', 'g')
- else
- if len(tmp) > 0 | let tmp .= ',' | endif
- let tmp .= ' :' . attr . ' => "' . val . '"'
- endif
- endfor
- if len(tmp)
- let str .= '{' . tmp . ' }'
- endif
- if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
- let str .= "/"
- endif
-
- let inner = ''
- if len(current.value) > 0
- let lines = split(current.value[1:-2], "\n")
- let str .= " " . lines[0]
- for line in lines[1:]
- let str .= " |\n" . line
- endfor
- endif
- if len(current.child) == 1 && len(current.child[0].name) == 0
- let lines = split(current.child[0].value[1:-2], "\n")
- let str .= " " . lines[0]
- for line in lines[1:]
- let str .= " |\n" . line
- endfor
- elseif len(current.child) > 0
- for child in current.child
- let inner .= s:zen_toString(child, type, inline, filters)
- endfor
- let inner = substitute(inner, "\n", "\n ", 'g')
- let inner = substitute(inner, "\n $", "", 'g')
- let str .= "\n " . inner
- endif
- endif
- let str .= "\n"
- return str
-endfunction
-
-function! s:zen_toString_css(settings, current, type, inline, filters, itemno, indent)
- return ''
-endfunction
-
-function! s:zen_toString_html(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 = a:indent
- let str = ""
-
- let comment_indent = ''
- let comment = ''
- if s:zen_useFilter(filters, 'c')
- let comment_indent = substitute(str, '^.*\(\s*\)$', '\1', '')
- endif
- let current_name = current.name
- let current_name = substitute(current.name, '\$$', itemno+1, '')
- let tmp = '<' . current_name
- for attr in keys(current.attr)
- if current_name =~ '^\(xsl:with-param\|xsl:variable\)$' && s:zen_useFilter(filters, 'xsl') && len(current.child) && attr == 'select'
- continue
- endif
- let val = current.attr[attr]
- while val =~ '\$\([^#{]\|$\)'
- let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
- endwhile
- let attr = substitute(attr, '\$$', itemno+1, '')
- let tmp .= ' ' . attr . '="' . val . '"'
- if s:zen_useFilter(filters, 'c')
- if attr == 'id' | let comment .= '#' . val | endif
- if attr == 'class' | let comment .= '.' . val | endif
- endif
- endfor
- if len(comment) > 0
- let tmp = "<!-- " . comment . " -->" . (inline ? "" : "\n") . comment_indent . tmp
- endif
- let str .= tmp
- let inner = current.value[1:-2]
- if stridx(','.settings.html.inline_elements.',', ','.current_name.',') != -1
- let child_inline = 1
- else
- let child_inline = 0
- endif
- for child in current.child
- let html = s:zen_toString(child, type, child_inline, filters)
- if child.name == 'br'
- let inner = substitute(inner, '\n\s*$', '', '')
- endif
- let inner .= html
- endfor
- if len(current.child) == 1 && current.child[0].name == ''
- if stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
- let str .= ">" . inner . "</" . current_name . ">\n"
- else
- let str .= ">" . inner . "</" . current_name . ">"
- endif
- elseif len(current.child)
- if inline == 0
- if stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
- if inner =~ "\n$"
- let inner = substitute(inner, "\n", "\n" . indent, 'g')
- let inner = substitute(inner, indent . "$", "", 'g')
- let str .= ">\n" . indent . inner . "</" . current_name . ">\n"
- else
- let str .= ">\n" . indent . inner . indent . "\n</" . current_name . ">\n"
- endif
- else
- let str .= ">" . inner . "</" . current_name . ">\n"
- endif
- else
- let str .= ">" . inner . "</" . current_name . ">"
- endif
- else
- if inline == 0
- if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
- let str .= " />\n"
- else
- if stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1 && len(current.child)
- let str .= ">\n" . inner . '${cursor}</' . current_name . ">\n"
- else
- let str .= ">" . inner . '${cursor}</' . current_name . ">\n"
- endif
- endif
- else
- if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
- let str .= " />"
- else
- let str .= ">" . inner . '${cursor}</' . current_name . ">"
- endif
- endif
- endif
- if len(comment) > 0
- let str .= "<!-- /" . comment . " -->" . (inline ? "" : "\n") . comment_indent
- endif
- return str
-endfunction
-
-function! s:zen_toString(...)
+function! zencoding#toString(...)
let current = a:1
if a:0 > 1
let type = a:2
else
let type = &ft
endif
-" if !has_key(s:zen_settings, type)
-" let type = 'html'
-" endif
if len(type) == 0 | let type = 'html' | endif
if a:0 > 2
let inline = a:3
@@ -546,26 +132,24 @@ function! s:zen_toString(...)
else
let filters = ['html']
endif
-
- if has_key(s:zen_settings, type) && has_key(s:zen_settings[type], 'indentation')
- let indent = s:zen_settings[type].indentation
+ if a:0 > 4
+ let group_itemno = a:5
else
- let indent = s:zen_settings.indentation
+ let group_itemno = 0
endif
+
+ let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
+ let indent = zencoding#getIndentation(type)
let itemno = 0
let str = ''
- let use_pipe_for_cursor = s:zen_getResource(type, 'use_pipe_for_cursor', 1)
+ let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
while itemno < current.multiplier
if len(current.name)
- let inner = ''
- if exists('*g:zen_toString_'.type)
- let inner = function('g:zen_toString_'.type)(s:zen_settings, current, type, inline, filters, itemno, indent)
- elseif s:zen_isExtends(type, "css")
- let inner = s:zen_toString_css(s:zen_settings, current, type, inline, filters, itemno, indent)
- elseif s:zen_useFilter(filters, 'haml')
- let inner = s:zen_toString_haml(s:zen_settings, current, type, inline, filters, itemno, indent)
+ if group_itemno != 0
+ let inner = zencoding#lang#{rtype}#toString(s:zen_settings, current, type, inline, filters, group_itemno, indent)
else
- let inner = s:zen_toString_html(s:zen_settings, current, type, inline, filters, itemno, indent)
+ let inner = zencoding#lang#{rtype}#toString(s:zen_settings, current, type, inline, filters, itemno, indent)
endif
if current.multiplier > 1
let inner = substitute(inner, '\$#', '$line'.(itemno+1).'$', 'g')
@@ -574,7 +158,7 @@ function! s:zen_toString(...)
else
let snippet = current.snippet
if len(current.snippet) == 0
- let snippets = s:zen_getResource(type, 'snippets', {})
+ let snippets = zencoding#getResource(type, 'snippets', {})
if !empty(snippets) && has_key(snippets, 'zensnippet')
let snippet = snippets['zensnippet']
endif
@@ -585,59 +169,47 @@ function! s:zen_toString(...)
let tmp = substitute(tmp, '|', '${cursor}', 'g')
endif
let tmp = substitute(tmp, '\${zenname}', current.name, 'g')
- if s:zen_isExtends(type, "css") && s:zen_useFilter(filters, 'fc')
- let tmp = substitute(tmp, '^\([^:]\+\):\([^;]*;\)', '\1: \2', '')
- if current.important
- let tmp = substitute(tmp, ';', ' !important;', '')
- endif
- endif
- for attr in keys(current.attr)
- let val = current.attr[attr]
- let tmp = substitute(tmp, '\${' . attr . '}', val, 'g')
- endfor
- let str .= tmp
+ 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)
else
if len(current.name)
let str .= current.name
endif
if len(current.value)
- let str .= current.value[1:-2]
+ let text = current.value[1:-2]
+ if dollar_expr
+ let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
+ let text = substitute(text, '\${nr}', "\n", 'g')
+ let text = substitute(text, '\\\$', '$', 'g')
+ endif
+ let str .= text
endif
endif
let inner = ''
if len(current.child)
for n in current.child
- let inner .= s:zen_toString(n, type, inline, filters)
+ let inner .= zencoding#toString(n, type, inline, filters, group_itemno)
endfor
- let inner = substitute(inner, "\n", "\n" . indent, 'g')
endif
+ let spaces = matchstr(str, '\s*\ze\${child}')
+ let inner = substitute(inner, "\n", "\n" . spaces, 'g')
let str = substitute(str, '\${child}', inner, '')
endif
let itemno = itemno + 1
endwhile
- if s:zen_useFilter(filters, 'e')
- let str = substitute(str, '&', '\&amp;', 'g')
- let str = substitute(str, '<', '\&lt;', 'g')
- let str = substitute(str, '>', '\&gt;', 'g')
- endif
return str
endfunction
-function! s:zen_getResource(type, name, default)
+function! zencoding#getSettings()
+ return s:zen_settings
+endfunction
+
+function! zencoding#getResource(type, name, default)
if !has_key(s:zen_settings, a:type)
return a:default
endif
let ret = a:default
- if has_key(s:zen_settings[a:type], a:name)
- let v = s:zen_settings[a:type][a:name]
- if type(ret) == 3 || type(ret) == 4
- call s:zen_mergeConfig(ret, s:zen_settings[a:type][a:name])
- else
- let ret = s:zen_settings[a:type][a:name]
- endif
- endif
-
if has_key(s:zen_settings[a:type], 'extends')
let extends = s:zen_settings[a:type].extends
if type(extends) == 1
@@ -647,37 +219,52 @@ function! s:zen_getResource(type, name, default)
endif
for ext in extends
if has_key(s:zen_settings, ext) && has_key(s:zen_settings[ext], a:name)
- call s:zen_mergeConfig(ret, s:zen_settings[ext][a:name])
+ call s:mergeConfig(ret, s:zen_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 type(ret) == 3 || type(ret) == 4
+ call s:mergeConfig(ret, s:zen_settings[a:type][a:name])
+ else
+ let ret = s:zen_settings[a:type][a:name]
+ endif
+ endif
+
return ret
endfunction
-function! s:zen_getFileType()
+function! zencoding#getFileType()
let type = &ft
if type == 'xslt' | let type = 'xsl' | endif
if type == 'htmldjango' | let type = 'html' | endif
if type == 'html.django_template' | let type = 'html' | endif
- if type == 'scss' | let type = 'css' | endif
- if synIDattr(synID(line("."), col("."), 1), "name") =~ '^css'
- let type = 'css'
- endif
- if synIDattr(synID(line("."), col("."), 1), "name") =~ '^html'
- let type = 'html'
- endif
- if synIDattr(synID(line("."), col("."), 1), "name") =~ '^javaScript'
- let type = 'javascript'
+ if len(type) == 0 && zencoding#lang#exists(&ft)
+ let type = &ft
endif
- if len(type) == 0 && synIDattr(synID(line("."), col("."), 1), "name") =~ '^xml'
- let type = 'xml'
+ if type == 'html'
+ let type = synIDattr(synID(line("."), col("."), 1), "name")
+ if type =~ '^css\w'
+ let type = 'css'
+ endif
+ if type =~ '^html\w'
+ let type = 'html'
+ endif
+ if type =~ '^javaScript'
+ let type = 'javascript'
+ endif
+ if len(type) == 0 && type =~ '^xml'
+ let type = 'xml'
+ endif
endif
if len(type) == 0 | let type = 'html' | endif
return type
endfunction
-function! zencoding#expandAbbr(mode) range
- let type = s:zen_getFileType()
+function! zencoding#expandAbbr(mode, abbr) range
+ let type = zencoding#getFileType()
let expand = ''
let filters = ['html']
let line = ''
@@ -693,9 +280,9 @@ function! zencoding#expandAbbr(mode) range
if len(leader) == 0
return
endif
- let mx = '|\(\%(html\|haml\|e\|c\|fc\|xsl\|t\)\s*,\{0,1}\s*\)*$'
+ let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
if leader =~ mx
- let filters = split(matchstr(leader, mx)[1:], '\s*,\s*')
+ let filters = map(split(matchstr(leader, mx)[1:], '\s*[^\\]\zs,\s*'), 'substitute(v:val, "\\\\\\\\zs.\\\\ze", "&", "g")')
let leader = substitute(leader, mx, '', '')
endif
if leader =~ '\*'
@@ -703,27 +290,44 @@ function! zencoding#expandAbbr(mode) range
if query !~ '}\s*$'
let query .= '>{$#}'
endif
- let items = s:zen_parseIntoTree(query, type).child
+ if zencoding#useFilter(filters, '/')
+ let spl = zencoding#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
for item in items
- let expand .= s:zen_toString(item, type, 0, filters)
+ let expand .= zencoding#toString(item, type, 0, filters)
endfor
+ if zencoding#useFilter(filters, 'e')
+ let expand = substitute(expand, '&', '\&amp;', 'g')
+ let expand = substitute(expand, '<', '\&lt;', 'g')
+ let expand = substitute(expand, '>', '\&gt;', 'g')
+ endif
let line = getline(a:firstline)
let part = substitute(line, '^\s*', '', '')
for n in range(a:firstline, a:lastline)
let lline = getline(n)
let lpart = substitute(lline, '^\s\+', '', '')
- if s:zen_useFilter(filters, 't')
+ if zencoding#useFilter(filters, 't')
let lpart = substitute(lpart, '^[0-9.-]\+\s\+', '', '')
let lpart = substitute(lpart, '\s\+$', '', '')
endif
- let expand = substitute(expand, '\$line'.(n-a:firstline+1).'\$', lpart, 'g')
+ if zencoding#useFilter(filters, '/')
+ for column in split(lpart, spl)
+ let expand = substitute(expand, '\$column\$', '\=column', '')
+ endfor
+ else
+ let expand = substitute(expand, '\$line'.(n-a:firstline+1).'\$', '\=lpart', 'g')
+ endif
endfor
let expand = substitute(expand, '\$line\d*\$', '', 'g')
+ let expand = substitute(expand, '\$column\$', '', 'g')
let content = join(getline(a:firstline, a:lastline), "\n")
if stridx(expand, '$#') < len(expand)-2
let expand = substitute(expand, '^\(.*\)\$#\s*$', '\1', '')
endif
- let expand = substitute(expand, '\$#', content, 'g')
+ let expand = substitute(expand, '\$#', '\=content', 'g')
else
let str = ''
if visualmode() ==# 'V'
@@ -738,19 +342,35 @@ function! zencoding#expandAbbr(mode) range
endif
endfor
let leader .= (str =~ "\n" ? ">{\n" : "{") . str . "}"
- let items = s:zen_parseIntoTree(leader, type).child
+ let items = zencoding#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 = s:zen_parseIntoTree(leader . "{".str."}", type).child
+ let items = zencoding#parseIntoTree(leader . "{".str."}", type).child
endif
for item in items
- let expand .= s:zen_toString(item, type, 0, filters)
+ let expand .= zencoding#toString(item, type, 0, filters)
endfor
+ if zencoding#useFilter(filters, 'e')
+ let expand = substitute(expand, '&', '\&amp;', 'g')
+ let expand = substitute(expand, '<', '\&lt;', 'g')
+ let expand = substitute(expand, '>', '\&gt;', 'g')
+ endif
+ endif
+ elseif a:mode == 4
+ let line = getline('.')
+ let spaces = matchstr(line, '^\s*')
+ if line !~ '^\s*$'
+ put =spaces.a:abbr
+ else
+ call setline('.', spaces.a:abbr)
endif
+ normal! $
+ call zencoding#expandAbbr(0, "")
+ return
else
let line = getline('.')
if col('.') < len(line)
@@ -760,25 +380,25 @@ function! zencoding#expandAbbr(mode) range
let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$')
else
let part = matchstr(line, '\(\S.*\)$')
- if s:zen_isExtends(type, "html")
- while part =~ '<.\{-}>'
- let part = substitute(part, '^.*<.\{-}>', '', '')
- endwhile
- elseif s:zen_isExtends(type, "css")
- let part = substitute(part, '^.*[;{]\s*', '', '')
- endif
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ let part = zencoding#lang#{rtype}#findTokens(part)
endif
let rest = getline('.')[len(line):]
let str = part
- let mx = '|\(\%(html\|haml\|e\|c\|fc\|xsl\|t\)\s*,\{0,1}\s*\)*$'
+ let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
if str =~ mx
let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
let str = substitute(str, mx, '', '')
endif
- let items = s:zen_parseIntoTree(str, type).child
+ let items = zencoding#parseIntoTree(str, type).child
for item in items
- let expand .= s:zen_toString(item, type, 0, filters)
+ let expand .= zencoding#toString(item, type, 0, filters)
endfor
+ if zencoding#useFilter(filters, 'e')
+ let expand = substitute(expand, '&', '\&amp;', 'g')
+ let expand = substitute(expand, '<', '\&lt;', 'g')
+ let expand = substitute(expand, '>', '\&gt;', 'g')
+ endif
let expand = substitute(expand, '\$line\([0-9]\+\)\$', '\=submatch(1)', 'g')
endif
if len(expand)
@@ -805,10 +425,12 @@ function! zencoding#expandAbbr(mode) range
endif
let expand = substitute(expand, '\${cursor}', '$cursor$', '')
let expand = substitute(expand, '\${cursor}', '', 'g')
- silent! normal! gvc
+ silent! normal! gv
+ let col = col("'<")
+ silent! normal! c
let line = getline('.')
- let lhs = matchstr(line, '.*\%'.col('.').'c.')
- let rhs = matchstr(line, '\%>'.col('.').'c.*')
+ let lhs = matchstr(line, '.*\%<'.col.'c.')
+ let rhs = matchstr(line, '\%>'.(col-1).'c.*')
let expand = lhs.expand.rhs
let lines = split(expand, '\n')
call setline(line('.'), lines[0])
@@ -838,6 +460,7 @@ function! zencoding#expandAbbr(mode) range
if search('\$cursor\$', 'e')
let oldselection = &selection
let &selection = 'inclusive'
+ silent! foldopen
silent! exe "normal! v7h\"_s"
let &selection = oldselection
endif
@@ -847,177 +470,39 @@ function! zencoding#expandAbbr(mode) range
endfunction
function! zencoding#moveNextPrev(flag)
- if search('><\/\|\(""\)\|^\s*$', a:flag ? 'Wpb' : 'Wp') == 3
- startinsert!
- else
- silent! normal! l
- startinsert
- endif
+ let type = zencoding#getFileType()
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#moveNextPrev(a:flag)
endfunction
function! zencoding#imageSize()
- let img_region = s:search_region('<img\s', '>')
- if !s:region_is_valid(img_region) || !s:cursor_in_region(img_region)
- return
- endif
- let content = s:get_content(img_region)
- if content !~ '^<img[^><]\+>$'
- return
- endif
- let current = s:zen_parseTag(content)
- let fn = current.attr.src
- if fn !~ '^\(/\|http\)'
- let fn = simplify(expand('%:h') . '/' . fn)
- endif
- let [type, width, height] = ['', -1, -1]
-
- 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')
- endif
-
- if hex =~ '^89504e470d0a1a0a'
- let type = 'png'
- let width = eval('0x'.hex[32:39])
- let height = eval('0x'.hex[40:47])
- endif
- if hex =~ '^ffd8'
- let pos = match(hex, 'ffc[02]')
- let type = 'jpg'
- let height = eval('0x'.hex[pos+10:pos+11])*256 + eval('0x'.hex[pos+12:pos+13])
- let width = eval('0x'.hex[pos+14:pos+15])*256 + eval('0x'.hex[pos+16:pos+17])
- endif
- if hex =~ '^47494638'
- let type = 'gif'
- let width = eval('0x'.hex[14:15].hex[12:13])
- let height = eval('0x'.hex[18:19].hex[16:17])
- endif
+ let type = zencoding#getFileType()
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#imageSize()
+endfunction
- if width == -1 && height == -1
- return
- endif
- let current.attr.width = width
- let current.attr.height = height
- let html = s:zen_toString(current, 'html', 1)
- call s:change_content(img_region, html)
+function! zencoding#encodeImage()
+ let type = zencoding#getFileType()
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#encodeImage()
endfunction
function! zencoding#toggleComment()
- if s:zen_getFileType() == 'css'
- let line = getline('.')
- let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
- if line =~ mx
- let space = substitute(matchstr(line, mx), mx, '\1', '')
- let line = substitute(matchstr(line, mx), mx, '\2', '')
- let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
- else
- let mx = '^\(\s*\)\(.*\)\s*$'
- let line = substitute(line, mx, '\1/* \2 */', '')
- endif
- call setline('.', line)
- return
- endif
+ let type = zencoding#getFileType()
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#toggleComment()
+endfunction
- let orgpos = getpos('.')
- let curpos = getpos('.')
- let mx = '<\%#[^>]*>'
- while 1
- let block = s:search_region('<!--', '-->')
- if s:region_is_valid(block)
- let block[1][1] += 2
- let content = s:get_content(block)
- let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
- call s:change_content(block, content)
- silent! call setpos('.', orgpos)
- return
- endif
- let block = s:search_region('<[^>]', '>')
- if !s:region_is_valid(block)
- let pos1 = searchpos('<', 'bcW')
- if pos1[0] == 0 && pos1[1] == 0
- return
- endif
- let curpos = getpos('.')
- continue
- endif
- let pos1 = block[0]
- let pos2 = block[1]
- let content = s:get_content(block)
- let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
- if tag_name[0] == '/'
- call setpos('.', [0, pos1[0], pos1[1], 0])
- let pos2 = searchpairpos('<'. tag_name[1:] . '>', '', '</' . tag_name[1:] . '>', 'bnW')
- let pos1 = searchpos('>', 'cneW')
- let block = [pos2, pos1]
- elseif tag_name =~ '/$'
- if !s:point_in_region(orgpos[1:2], block)
- " it's broken tree
- call setpos('.', orgpos)
- let block = s:search_region('>', '<')
- let content = '><!-- ' . s:get_content(block)[1:-2] . ' --><'
- call s:change_content(block, content)
- silent! call setpos('.', orgpos)
- return
- endif
- else
- call setpos('.', [0, pos2[0], pos2[1], 0])
- let pos2 = searchpairpos('<'. tag_name . '>', '', '</' . tag_name . '>', 'nW')
- call setpos('.', [0, pos2[0], pos2[1], 0])
- let pos2 = searchpos('>', 'cneW')
- let block = [pos1, pos2]
- endif
- if !s:region_is_valid(block)
- silent! call setpos('.', orgpos)
- return
- endif
- if s:point_in_region(curpos[1:2], block)
- let content = '<!-- ' . s:get_content(block) . ' -->'
- call s:change_content(block, content)
- silent! call setpos('.', orgpos)
- return
- endif
- endwhile
+function! zencoding#balanceTag(flag) range
+ let type = zencoding#getFileType()
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#balanceTag(a:flag)
endfunction
function! zencoding#splitJoinTag()
- let curpos = getpos('.')
- while 1
- let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
- let pos1 = searchpos(mx, 'bcnW')
- let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
- let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
- let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
- if content[-2:] == '/>' && s:cursor_in_region(block)
- let content = content[:-3] . "></" . tag_name . '>'
- call s:change_content(block, content)
- call setpos('.', [0, block[0][0], block[0][1], 0])
- return
- else
- if tag_name[0] == '/'
- let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
- call setpos('.', [0, pos1[0], pos1[1], 0])
- let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
- else
- let pos2 = searchpos('</' . tag_name . '>', 'cneW')
- endif
- let block = [pos1, pos2]
- let content = s:get_content(block)
- if s:point_in_region(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
- let content = matchstr(content, mx)[:-2] . '/>'
- call s:change_content(block, content)
- call setpos('.', [0, block[0][0], block[0][1], 0])
- return
- else
- if block[0][0] > 0
- call setpos('.', [0, block[0][0]-1, block[0][1], 0])
- else
- call setpos('.', curpos)
- return
- endif
- endif
- endif
- endwhile
+ let type = zencoding#getFileType()
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#splitJoinTag()
endfunction
function! zencoding#mergeLines() range
@@ -1028,121 +513,9 @@ function! zencoding#mergeLines() range
endfunction
function! zencoding#removeTag()
- let curpos = getpos('.')
- while 1
- let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
- let pos1 = searchpos(mx, 'bcnW')
- let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
- let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '')
- let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
- if content[-2:] == '/>' && s:cursor_in_region(block)
- call s:change_content(block, '')
- call setpos('.', [0, block[0][0], block[0][1], 0])
- return
- else
- if tag_name[0] == '/'
- let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
- call setpos('.', [0, pos1[0], pos1[1], 0])
- let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
- else
- let pos2 = searchpos('</' . tag_name . '>', 'cneW')
- endif
- let block = [pos1, pos2]
- let content = s:get_content(block)
- if s:point_in_region(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
- call s:change_content(block, '')
- call setpos('.', [0, block[0][0], block[0][1], 0])
- return
- else
- if block[0][0] > 0
- call setpos('.', [0, block[0][0]-1, block[0][1], 0])
- else
- call setpos('.', curpos)
- return
- endif
- endif
- endif
- endwhile
-endfunction
-
-function! zencoding#balanceTag(flag) range
- let vblock = s:get_visualblock()
- if a:flag == -2 || a:flag == 2
- let curpos = [0, line("'<"), col("'<"), 0]
- else
- let curpos = getpos('.')
- endif
- while 1
- let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
- let pos1 = searchpos(mx, (a:flag == -2 ? 'nW' : 'bcnW'))
- 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 !s:region_is_valid(block)
- break
- endif
- if content[-2:] == '/>' && s:point_in_region(curpos[1:2], block)
- call s:select_region(block)
- return
- else
- if tag_name[0] == '/'
- let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', a:flag == -2 ? 'nW' : 'bcnW')
- if pos1[0] == 0
- break
- endif
- call setpos('.', [0, pos1[0], pos1[1], 0])
- let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
- else
- let pos2 = searchpos('</' . tag_name . '>', 'cneW')
- endif
- let block = [pos1, pos2]
- if !s:region_is_valid(block)
- break
- endif
- let content = s:get_content(block)
- if a:flag == -2
- let check = s:region_in_region(vblock, block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
- else
- let check = s:point_in_region(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
- endif
- if check
- if a:flag < 0
- let l = getline(pos1[0])
- let content = matchstr(l[pos1[1]-1:], mx)
- if pos1[1] + len(content) > len(l)
- let pos1[0] += 1
- else
- let pos1[1] += len(content)
- endif
- let pos2 = searchpos('\(\n\|.\)</' . tag_name . '>', 'cnW')
- else
- let pos2 = searchpos('</' . tag_name . '>', 'cneW')
- endif
- let block = [pos1, pos2]
- call s:select_region(block)
- return
- else
- if s:region_is_valid(block)
- if a:flag == -2
- if setpos('.', [0, block[0][0]+1, block[0][1], 0]) == -1
- break
- endif
- else
- if setpos('.', [0, block[0][0]-1, block[0][1], 0]) == -1
- break
- endif
- endif
- else
- break
- endif
- endif
- endif
- endwhile
- if a:flag == -2 || a:flag == 2
- silent! exe "normal! gv"
- else
- call setpos('.', curpos)
- endif
+ let type = zencoding#getFileType()
+ let rtype = zencoding#lang#exists(type) ? type : 'html'
+ return zencoding#lang#{rtype}#removeTag()
endfunction
function! zencoding#anchorizeURL(flag)
@@ -1150,249 +523,72 @@ function! zencoding#anchorizeURL(flag)
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 !s:cursor_in_region(block)
+ if !zencoding#util#cursorInRegion(block)
return
endif
let mx = '.*<title[^>]*>\s*\zs\([^<]\+\)\ze\s*<\/title[^>]*>.*'
- let content = s:get_content_from_url(url, 0)
- if len(matchstr(content, mx)) == 0
- let content = s:get_content_from_url(url, 1)
- endif
+ let content = zencoding#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'
if a:flag == 0
- let a = s:zen_parseTag('<a>')
+ let a = zencoding#lang#html#parseTag('<a>')
let a.attr.href = url
let a.value = '{' . title . '}'
- let expand = s:zen_toString(a, 'html', 0, [])
+ let expand = zencoding#toString(a, rtype, 0, [])
let expand = substitute(expand, '\${cursor}', '', 'g')
else
- let body = s:get_text_from_html(content)
+ let body = zencoding#util#getTextFromHTML(content)
let body = '{' . substitute(body, '^\(.\{0,100}\).*', '\1', '') . '...}'
- let blockquote = s:zen_parseTag('<blockquote class="quote">')
- let a = s:zen_parseTag('<a>')
+ let blockquote = zencoding#lang#html#parseTag('<blockquote class="quote">')
+ let a = zencoding#lang#html#parseTag('<a>')
let a.attr.href = url
let a.value = '{' . title . '}'
call add(blockquote.child, a)
- call add(blockquote.child, s:zen_parseTag('<br/>'))
- let p = s:zen_parseTag('<p>')
+ call add(blockquote.child, zencoding#lang#html#parseTag('<br/>'))
+ let p = zencoding#lang#html#parseTag('<p>')
let p.value = body
call add(blockquote.child, p)
- let cite = s:zen_parseTag('<cite>')
+ let cite = zencoding#lang#html#parseTag('<cite>')
let cite.value = '{' . url . '}'
call add(blockquote.child, cite)
- let expand = s:zen_toString(blockquote, 'html', 0, [])
+ let expand = zencoding#toString(blockquote, rtype, 0, [])
let expand = substitute(expand, '\${cursor}', '', 'g')
- let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '')
- let expand = substitute(expand, "\n", "\n" . indent, 'g')
endif
- call s:change_content(block, expand)
+ let indent = substitute(getline('.'), '^\(\s*\).*', '\1', '')
+ let expand = substitute(expand, "\n", "\n" . indent, 'g')
+ call zencoding#util#setContent(block, expand)
endfunction
-"==============================================================================
-" html utils
-"==============================================================================
-function! s:get_content_from_url(url, utf8)
- silent! new
- if a:utf8
- silent! exec '0r ++enc=utf8 !'.g:zencoding_curl_command.' "'.substitute(a:url, '#.*', '', '').'"'
- else
- silent! exec '0r!'.g:zencoding_curl_command.' "'.substitute(a:url, '#.*', '', '').'"'
+function! zencoding#codePretty() range
+ let type = input('FileType: ', &ft, 'filetype')
+ if len(type) == 0
+ return
endif
- let ret = join(getline(1, '$'), "\n")
+ let block = zencoding#util#getVisualBlock()
+ let content = zencoding#util#getContent(block)
+ silent! 1new
+ let &l:filetype = type
+ call setline(1, split(content, "\n"))
+ let old_lazyredraw = &lazyredraw
+ set lazyredraw
+ silent! TOhtml
+ let &lazyredraw = old_lazyredraw
+ let content = join(getline(1, '$'), "\n")
silent! bw!
- return ret
-endfunction
-
-function! s:get_text_from_html(buf)
- let threshold_len = 100
- let threshold_per = 0.1
- let buf = a:buf
-
- let buf = strpart(buf, stridx(buf, '</head>'))
- let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g')
- let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g')
- let res = ''
- let max = 0
- let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
- let m = split(buf, mx)
- for str in m
- let c = split(str, '<[^>]*?>')
- let str = substitute(str, '<[^>]\{-}>', ' ', 'g')
- let str = substitute(str, '&gt;', '>', 'g')
- let str = substitute(str, '&lt;', '<', 'g')
- let str = substitute(str, '&quot;', '"', 'g')
- let str = substitute(str, '&apos;', "'", 'g')
- let str = substitute(str, '&nbsp;', ' ', 'g')
- let str = substitute(str, '&yen;', '\&#65509;', 'g')
- let str = substitute(str, '&amp;', '\&', 'g')
- let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '')
- let str = substitute(str, '\s\+', ' ', 'g')
- let l = len(str)
- if l > threshold_len
- let per = (l+0.0) / len(c)
- if max < l && per > threshold_per
- let max = l
- let res = str
- endif
- endif
- endfor
- let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
- return res
-endfunction
-"==============================================================================
-
-"==============================================================================
-" region utils
-"==============================================================================
-" delete_content : delete content in region
-" if region make from between '<foo>' and '</foo>'
-" --------------------
-" begin:<foo>
-" </foo>:end
-" --------------------
-" this function make the content as following
-" --------------------
-" begin::end
-" --------------------
-function! s:delete_content(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])
- call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
-endfunction
-
-" change_content : change content in region
-" if region make from between '<foo>' and '</foo>'
-" --------------------
-" begin:<foo>
-" </foo>:end
-" --------------------
-" and content is
-" --------------------
-" foo
-" bar
-" baz
-" --------------------
-" this function make the content as following
-" --------------------
-" begin:foo
-" bar
-" baz:end
-" --------------------
-function! s:change_content(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])
- silent! exe "delete ".(a:region[1][0] - a:region[0][0])
- if len(newlines) == 0
- let tmp = ''
- if a:region[0][1] > 1
- let tmp = oldlines[0][:a:region[0][1]-2]
- endif
- if a:region[1][1] >= 1
- let tmp .= oldlines[-1][a:region[1][1]:]
- endif
- call setline(line('.'), tmp)
- elseif len(newlines) == 1
- if a:region[0][1] > 1
- let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
- endif
- if a:region[1][1] >= 1
- let newlines[0] .= oldlines[-1][a:region[1][1]:]
- endif
- call setline(line('.'), newlines[0])
- else
- if a:region[0][1] > 1
- let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
- endif
- if a:region[1][1] >= 1
- let newlines[-1] .= oldlines[-1][a:region[1][1]:]
- endif
- call setline(line('.'), newlines[0])
- call append(line('.'), newlines[1:])
- endif
-endfunction
-
-" select_region : select region
-" this function make a selection of region
-function! s:select_region(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])
-endfunction
-
-" point_in_region : check point is in the region
-" this function return 0 or 1
-function! s:point_in_region(point, region)
- if !s:region_is_valid(a:region) | return 0 | endif
- if a:region[0][0] > a:point[0] | return 0 | endif
- if a:region[1][0] < a:point[0] | return 0 | endif
- if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
- if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
- return 1
-endfunction
-
-" cursor_in_region : check cursor is in the region
-" this function return 0 or 1
-function! s:cursor_in_region(region)
- if !s:region_is_valid(a:region) | return 0 | endif
- let cur = getpos('.')[1:2]
- return s:point_in_region(cur, a:region)
-endfunction
-
-" region_is_valid : check region is valid
-" this function return 0 or 1
-function! s:region_is_valid(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! s:search_region(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! s:get_content(region)
- if !s:region_is_valid(a:region)
- return ''
- endif
- let lines = getline(a:region[0][0], a:region[1][0])
- if a:region[0][0] == a:region[1][0]
- let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1]
- else
- let lines[0] = lines[0][a:region[0][1]-1:]
- let lines[-1] = lines[-1][:a:region[1][1]-1]
- endif
- return join(lines, "\n")
-endfunction
-
-" region_in_region : check region is in the region
-" this function return 0 or 1
-function! s:region_in_region(outer, inner)
- if !s:region_is_valid(a:inner) || !s:region_is_valid(a:outer)
- return 0
- endif
- return s:point_in_region(a:inner[0], a:outer) && s:point_in_region(a:inner[1], a:outer)
-endfunction
-
-" get_visualblock : get region of visual block
-" this function return region of visual block
-function! s:get_visualblock()
- return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
+ silent! bw!
+ let content = matchstr(content, '<body[^>]*>[\s\n]*\zs.*\ze</body>')
+ call zencoding#util#setContent(block, content)
endfunction
-"==============================================================================
function! zencoding#ExpandWord(abbr, type, orig)
- let mx = '|\(\%(html\|haml\|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 type = a:type
@@ -1405,11 +601,16 @@ function! zencoding#ExpandWord(abbr, type, orig)
else
let filters = ['html']
endif
- let items = s:zen_parseIntoTree(str, a:type).child
+ let items = zencoding#parseIntoTree(str, a:type).child
let expand = ''
for item in items
- let expand .= s:zen_toString(item, a:type, 0, filters)
+ let expand .= zencoding#toString(item, a:type, 0, filters)
endfor
+ if zencoding#useFilter(filters, 'e')
+ let expand = substitute(expand, '&', '\&amp;', 'g')
+ let expand = substitute(expand, '<', '\&lt;', 'g')
+ let expand = substitute(expand, '>', '\&gt;', 'g')
+ endif
if a:orig == 0
let expand = substitute(expand, '\${lang}', s:zen_settings.lang, 'g')
let expand = substitute(expand, '\${charset}', s:zen_settings.charset, 'g')
@@ -1418,6 +619,14 @@ function! zencoding#ExpandWord(abbr, type, orig)
return expand
endfunction
+function! zencoding#getSnippets(type)
+ let type = a:type
+ if len(type) == 0 || !has_key(s:zen_settings, type)
+ let type = 'html'
+ endif
+ return zencoding#getResource(type, 'snippets', {})
+endfunction
+
function! zencoding#CompleteTag(findstart, base)
if a:findstart
let line = getline('.')
@@ -1427,16 +636,16 @@ function! zencoding#CompleteTag(findstart, base)
endwhile
return start
else
- let type = s:zen_getFileType()
+ let type = zencoding#getFileType()
let res = []
- let snippets = s:zen_getResource(type, 'snippets', {})
+ let snippets = zencoding#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 = s:zen_getResource(type, 'aliases', {})
+ let aliases = zencoding#getResource(type, 'aliases', {})
for item in values(aliases)
if stridx(item, a:base) != -1
call add(res, substitute(item, '\${cursor}\||', '', 'g'))
@@ -1448,7 +657,6 @@ endfunction
unlet! s:zen_settings
let s:zen_settings = {
-\ 'indentation': "\t",
\ 'lang': "en",
\ 'charset': "UTF-8",
\ 'css': {
@@ -1932,6 +1140,9 @@ let s:zen_settings = {
\ 'sass': {
\ 'extends': 'css',
\ },
+\ 'scss': {
+\ 'extends': 'css',
+\ },
\ 'html': {
\ 'snippets': {
\ 'cc:ie6': "<!--[if lte IE 6]>\n\t${child}|\n<![endif]-->",
@@ -2127,8 +1338,8 @@ let s:zen_settings = {
\ 'optg': 'optgroup>option'
\ },
\ 'empty_elements': 'area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed,keygen,command',
-\ 'block_elements': 'address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,link,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul,h1,h2,h3,h4,h5,h6,style',
-\ 'inline_elements': 'a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,small,span,strike,strong,sub,sup,textarea,tt,u,var',
+\ 'block_elements': 'address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,link,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul,h1,h2,h3,h4,h5,h6',
+\ 'inline_elements': 'a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'
\ },
\ 'xsl': {
\ 'extends': 'html',
@@ -2169,7 +1380,30 @@ let s:zen_settings = {
\ }
\ },
\ 'haml': {
-\ 'extends': 'html'
+\ 'indentation': ' ',
+\ 'extends': 'html',
+\ 'snippets': {
+\ 'html:5': "!!! 5\n"
+\ ."%html{:lang => \"${lang}\"}\n"
+\ ."\t%head\n"
+\ ."\t\t%meta{:charset => \"${charset}\"}\n"
+\ ."\t\t%title\n"
+\ ."\t%body\n"
+\ ."\t\t${child}|\n"
+\ },
+\ },
+\ 'slim': {
+\ 'indentation': ' ',
+\ 'extends': 'html',
+\ 'snippets': {
+\ 'html:5': "doctype 5\n"
+\ ."html lang=\"${lang}\"\n"
+\ ."\thead\n"
+\ ."\t\tmeta charset=\"${charset}\"\n"
+\ ."\t\ttitle\n"
+\ ."\tbody\n"
+\ ."\t\t${child}|\n"
+\ },
\ },
\ 'xhtml': {
\ 'extends': 'html'
@@ -2189,7 +1423,7 @@ let s:zen_settings = {
\}
if exists('g:user_zen_settings')
- call s:zen_mergeConfig(s:zen_settings, g:user_zen_settings)
+ call s:mergeConfig(s:zen_settings, g:user_zen_settings)
endif
let &cpo = s:save_cpo
View
11 .vim/bundle/zencoding-vim/autoload/zencoding/lang.vim
@@ -0,0 +1,11 @@
+let s:exists = {}
+function zencoding#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
+ return s:exists[a:type]
+endfunction
+
View
157 .vim/bundle/zencoding-vim/autoload/zencoding/lang/css.vim
@@ -0,0 +1,157 @@
+function! zencoding#lang#css#findTokens(str)
+ return substitute(a:str, '^.*[;{]\s*', '', '')
+endfunction
+
+function! zencoding#lang#css#parseIntoTree(abbr, type)
+ let abbr = a:abbr
+ let type = a:type
+
+ let settings = zencoding#getSettings()
+ let indent = zencoding#getIndentation(type)
+
+ let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
+
+ let tag_name = abbr
+ if tag_name =~ '.!$'
+ let tag_name = tag_name[:-2]
+ let important = 1
+ else
+ let important = 0
+ endif
+ " make default node
+ let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': important }
+ let current.name = tag_name
+
+ " aliases
+ let aliases = zencoding#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)
+
+ " snippets
+ let snippets = zencoding#getResource(type, 'snippets', {})
+ if !empty(snippets) && has_key(snippets, tag_name)
+ let snippet = snippets[tag_name]
+ if use_pipe_for_cursor
+ let snippet = substitute(snippet, '|', '${cursor}', 'g')
+ endif
+ let lines = split(snippet, "\n")
+ call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
+ let current.snippet = join(lines, "\n")
+ let current.name = ''
+ endif
+ let current.pos = 0
+ call add(root.child, current)
+ return root
+endfunction
+
+function! zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
+ let current = a:current
+ let value = current.value[1:-2]
+ let value = substitute(value, '^\([^:]\+\):\([^;]*;\)', '\1: \2', '')
+ if current.important
+ let value = substitute(value, ';', ' !important;', '')
+ endif
+ return value
+endfunction
+
+function! zencoding#lang#css#imageSize()
+endfunction
+
+function! zencoding#lang#css#encodeImage()
+endfunction
+
+function! zencoding#lang#css#parseTag(tag)
+ return {}
+endfunction
+
+function! zencoding#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 content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
+ call zencoding#util#setContent(block, content)
+ else
+ let node = expand('<cword>')
+ if len(node)
+ exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
+ endif
+ endif
+ else
+ if line =~ mx
+ let space = substitute(matchstr(line, mx), mx, '\1', '')
+ let line = substitute(matchstr(line, mx), mx, '\2', '')
+ let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
+ else
+ let mx = '^\(\s*\)\(.*\)\s*$'
+ let line = substitute(line, mx, '\1/* \2 */', '')
+ endif
+ call setline('.', line)
+ endif
+endfunction
+
+function! zencoding#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)
+ if a:flag > 0
+ let block = zencoding#util#searchRegion('^', ';')
+ if zencoding#util#regionIsValid(block)
+ call zencoding#util#selectRegion(block)
+ return
+ endif
+ endif
+ else
+ if a:flag > 0
+ let content = zencoding#util#getContent(block)
+ if content !~ '^{.*}$'
+ let block = zencoding#util#searchRegion('{', '}')
+ if zencoding#util#regionIsValid(block)
+ call zencoding#util#selectRegion(block)
+ return
+ endif
+ endif
+ else
+ let pos = searchpos('.*;', 'nW')
+ if pos[0] != 0
+ call setpos('.', [0, pos[0], pos[1], 0])
+ let block = zencoding#util#searchRegion('^', ';')
+ if zencoding#util#regionIsValid(block)
+ call zencoding#util#selectRegion(block)
+ return
+ endif
+ endif
+ endif
+ endif
+ if a:flag == -2 || a:flag == 2
+ silent! exe "normal! gv"
+ else
+ call setpos('.', curpos)
+ endif
+endfunction
+
+function! zencoding#lang#css#moveNextPrev(flag)
+ let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
+ if pos == 2
+ startinsert!
+ else
+ silent! normal! l
+ startinsert
+ endif
+endfunction
+
+function! zencoding#lang#css#splitJoinTag()
+ " nothing to do
+endfunction
+
+function! zencoding#lang#css#removeTag()
+ " nothing to do
+endfunction
View
303 .vim/bundle/zencoding-vim/autoload/zencoding/lang/haml.vim
@@ -0,0 +1,303 @@
+function! zencoding#lang#haml#findTokens(str)
+ return zencoding#lang#html#findTokens(a:str)
+endfunction
+
+function! zencoding#lang#haml#parseIntoTree(abbr, type)
+ return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
+endfunction
+
+function! zencoding#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 = a:indent
+ let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
+ let str = ""
+
+ let comment_indent = ''
+ let comment = ''
+ let current_name = current.name
+ if dollar_expr
+ let current_name = substitute(current.name, '\$$', itemno+1, '')
+ endif
+ if len(current.name) > 0
+ let str .= '%' . current_name
+ let tmp = ''
+ for attr in keys(current.attr)
+ 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')
+ endwhile
+ let attr = substitute(attr, '\$$', itemno+1, '')
+ endif
+ let valtmp = substitute(val, '\${cursor}', '', '')
+ if attr == 'id' && len(valtmp) > 0
+ let str .= '#' . val
+ elseif attr == 'class' && len(valtmp) > 0
+ let str .= '.' . substitute(val, ' ', '.', 'g')
+ else
+ if len(tmp) > 0 | let tmp .= ',' | endif
+ let val = substitute(val, '\${cursor}', '', '')
+ let tmp .= ' :' . attr . ' => "' . val . '"'
+ endif
+ endfor
+ if len(tmp)
+ let str .= '{' . tmp . ' }'
+ endif
+ if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
+ let str .= "/"
+ endif
+
+ let inner = ''
+ if len(current.value) > 0
+ let text = current.value[1:-2]
+ if dollar_expr
+ let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
+ let text = substitute(text, '\${nr}', "\n", 'g')
+ let text = substitute(text, '\\\$', '$', 'g')
+ endif
+ let lines = split(text, "\n")
+ if len(lines) == 1
+ let str .= " " . text
+ else
+ for line in lines
+ let str .= "\n" . indent . line . " |"
+ endfor
+ endif
+ elseif len(current.child) == 0
+ let str .= '${cursor}'
+ endif
+ if len(current.child) == 1 && len(current.child[0].name) == 0
+ let text = current.child[0].value[1:-2]
+ if dollar_expr
+ let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
+ let text = substitute(text, '\${nr}', "\n", 'g')
+ let text = substitute(text, '\\\$', '$', 'g')
+ endif
+ let lines = split(text, "\n")
+ if len(lines) == 1
+ let str .= " " . text
+ else
+ for line in lines
+ let str .= "\n" . indent . line . " |"
+ endfor
+ endif
+ elseif len(current.child) > 0
+ for child in current.child
+ let inner .= zencoding#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 .= "\n" . indent . inner
+ endif
+ else
+ let str = current.value[1:-2]
+ if dollar_expr
+ let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
+ let str = substitute(str, '\${nr}', "\n", 'g')
+ let str = substitute(str, '\\\$', '$', 'g')
+ endif
+ endif
+ let str .= "\n"
+ return str
+endfunction
+
+function! zencoding#lang#haml#imageSize()
+ let line = getline('.')
+ let current = zencoding#lang#haml#parseTag(line)
+ if empty(current) || !has_key(current.attr, 'src')
+ return
+ endif
+ let fn = current.attr.src
+ if fn =~ '^\s*$'
+ return
+ elseif fn !~ '^\(/\|http\)'
+ let fn = simplify(expand('%:h') . '/' . fn)