From ab1be77b8689400741fc5bdbf8e48114c25aee1a Mon Sep 17 00:00:00 2001 From: Greg Weng Date: Tue, 22 Jan 2013 11:15:29 +0800 Subject: [PATCH 1/4] Update README.mkd --- README.mkd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.mkd b/README.mkd index 738581d..55926b3 100644 --- a/README.mkd +++ b/README.mkd @@ -1,3 +1,5 @@ +** forked project ** + # ZenCoding-vim [zencoding-vim](http://mattn.github.com/zencoding-vim) is vim script support for expanding abbreviation like zen-coding(emmet). From 2d3a46238b7127d16ecd127023772d72690c34c2 Mon Sep 17 00:00:00 2001 From: Greg Weng Date: Tue, 22 Jan 2013 11:18:44 +0800 Subject: [PATCH 2/4] Optional zencoding functions in different modes. --- plugin/zencoding.vim | 106 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 20 deletions(-) diff --git a/plugin/zencoding.vim b/plugin/zencoding.vim index f9b41a7..4cbaa82 100644 --- a/plugin/zencoding.vim +++ b/plugin/zencoding.vim @@ -1,8 +1,8 @@ "============================================================================= " File: zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 02-Nov-2012. -" Version: 0.80 +" Last Change: 09-Jul-2012. +" Version: 0.74 " WebPage: http://github.com/mattn/zencoding-vim " Description: vim plugins for HTML and CSS hi-speed coding. " SeeAlso: http://code.google.com/p/zen-coding/ @@ -90,36 +90,76 @@ if !exists('g:user_zen_leader_key') let g:user_zen_leader_key = '' endif -function! s:install_plugin() +function! s:install_plugin_i() for item in [ \ {'mode': 'i', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandAbbr', 'func': 'u:call zencoding#expandAbbr(0,"")a'}, - \ {'mode': 'v', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandVisual', 'func': ':call zencoding#expandAbbr(2,"")'}, - \ {'mode': 'n', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandNormal', 'func': ':call zencoding#expandAbbr(3,"")'}, \ {'mode': 'i', 'var': 'user_zen_expandword_key', 'key': ';', 'plug': 'ZenCodingExpandWord', 'func': 'u:call zencoding#expandAbbr(1,"")a'}, - \ {'mode': 'n', 'var': 'user_zen_expandword_key', 'key': ',', 'plug': 'ZenCodingExpandWord', 'func': ':call zencoding#expandAbbr(1,"")'}, \ {'mode': 'i', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardInsert', 'func': ':call zencoding#balanceTag(1)'}, - \ {'mode': 'n', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardNormal', 'func': ':call zencoding#balanceTag(1)'}, - \ {'mode': 'v', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardVisual', 'func': ':call zencoding#balanceTag(2)'}, \ {'mode': 'i', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardInsert', 'func': ':call zencoding#balanceTag(-1)'}, - \ {'mode': 'n', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardNormal', 'func': ':call zencoding#balanceTag(-1)'}, - \ {'mode': 'v', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardVisual', 'func': ':call zencoding#balanceTag(-2)'}, \ {'mode': 'i', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)'}, - \ {'mode': 'n', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)'}, \ {'mode': 'i', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)'}, - \ {'mode': 'n', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)'}, \ {'mode': 'i', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()a'}, - \ {'mode': 'n', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()'}, \ {'mode': 'i', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()a'}, - \ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()'}, - \ {'mode': 'v', 'var': 'user_zen_mergelines_key', 'key': 'm', 'plug': 'ZenCodingMergeLines', 'func': ':call zencoding#mergeLines()'}, \ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagInsert', 'func': ':call zencoding#splitJoinTag()'}, - \ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagNormal', 'func': ':call zencoding#splitJoinTag()'}, \ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()a'}, - \ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()'}, \ {'mode': 'i', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)a'}, - \ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)'}, \ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)a'}, + \] + + if !hasmapto(''.item.plug, item.mode) + exe item.mode . 'noremap ' . item.plug . ' ' . item.func + endif + if !exists('g:' . item.var) + endif + if exists('g:' . item.var) + let key = eval('g:' . item.var) + else + let key = g:user_zen_leader_key . item.key + endif + if len(maparg(key, item.mode)) == 0 + exe item.mode . 'map ' . key . ' ' . item.plug + endif + endfor +endfunction + +function! s:install_plugin_n() + for item in [ + \ {'mode': 'n', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandNormal', 'func': ':call zencoding#expandAbbr(3,"")'}, + \ {'mode': 'n', 'var': 'user_zen_expandword_key', 'key': ',', 'plug': 'ZenCodingExpandWord', 'func': ':call zencoding#expandAbbr(1,"")'}, + \ {'mode': 'n', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardNormal', 'func': ':call zencoding#balanceTag(1)'}, + \ {'mode': 'n', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardNormal', 'func': ':call zencoding#balanceTag(-1)'}, + \ {'mode': 'n', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)'}, + \ {'mode': 'n', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)'}, + \ {'mode': 'n', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()'}, + \ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()'}, + \ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagNormal', 'func': ':call zencoding#splitJoinTag()'}, + \ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()'}, + \ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)'}, \ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)'}, + \] + + if !hasmapto(''.item.plug, item.mode) + exe item.mode . 'noremap ' . item.plug . ' ' . item.func + endif + if !exists('g:' . item.var) + endif + if exists('g:' . item.var) + let key = eval('g:' . item.var) + else + let key = g:user_zen_leader_key . item.key + endif + if len(maparg(key, item.mode)) == 0 + exe item.mode . 'map ' . key . ' ' . item.plug + endif + endfor +endfunction + +function! s:install_plugin_v() + for item in [ + \ {'mode': 'v', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandVisual', 'func': ':call zencoding#expandAbbr(2,"")'}, + \ {'mode': 'v', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardVisual', 'func': ':call zencoding#balanceTag(2)'}, + \ {'mode': 'v', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardVisual', 'func': ':call zencoding#balanceTag(-2)'}, + \ {'mode': 'v', 'var': 'user_zen_mergelines_key', 'key': 'm', 'plug': 'ZenCodingMergeLines', 'func': ':call zencoding#mergeLines()'}, \ {'mode': 'v', 'var': 'user_zen_codepretty_key', 'key': 'c', 'plug': 'ZenCodingCodePretty', 'func': ':call zencoding#codePretty()'}, \] @@ -138,8 +178,34 @@ function! s:install_plugin() endif endfor endfunction -call s:install_plugin() -delfunction s:install_plugin + + +if exists('g:user_zen_mode') + let imode = matchstr(g:user_zen_mode, '[ai]') + let nmode = matchstr(g:user_zen_mode, '[an]') + let vmode = matchstr(g:user_zen_mode, '[av]') + + if !empty(imode) + call s:install_plugin_i() + endif + + if !empty(nmode) + call s:install_plugin_n() + endif + + if !empty(vmode) + call s:install_plugin_v() + endif +else + call s:install_plugin_i() + call s:install_plugin_n() + call s:install_plugin_v() +endif + + +delfunction s:install_plugin_i +delfunction s:install_plugin_n +delfunction s:install_plugin_v command! -nargs=1 Zen call zencoding#expandAbbr(4, ) From 97b753223e03adbe25d4b2f0ace17cb4db0087b8 Mon Sep 17 00:00:00 2001 From: Greg Weng Date: Tue, 22 Jan 2013 11:22:53 +0800 Subject: [PATCH 3/4] Update README.mkd --- README.mkd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.mkd b/README.mkd index 55926b3..3d5a1fc 100644 --- a/README.mkd +++ b/README.mkd @@ -1,5 +1,3 @@ -** forked project ** - # ZenCoding-vim [zencoding-vim](http://mattn.github.com/zencoding-vim) is vim script support for expanding abbreviation like zen-coding(emmet). @@ -55,6 +53,15 @@ Then type "," (Ctrl + y + ','), you should see: [More Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL) +## Enable in differnt mode + +If you don't want enable zencoding in all mode, +you can use set a option in `vimrc`: + + let g:user_zen_mode='n' "only enable normal mode functions. + let g:user_zen_mode='inv' "enable all functions, which is equal to + let g:user_zen_mode='a' "enable all function in all mode. + ## Project Authors [Yasuhiro Matsumoto](http://mattn.kaoriya.net/) From 886264029120c28a0bd0d5f519bf881a98e5039a Mon Sep 17 00:00:00 2001 From: Greg Weng Date: Tue, 22 Jan 2013 11:23:25 +0800 Subject: [PATCH 4/4] Update README.mkd --- README.mkd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.mkd b/README.mkd index 3d5a1fc..e927fb8 100644 --- a/README.mkd +++ b/README.mkd @@ -58,9 +58,9 @@ Then type "," (Ctrl + y + ','), you should see: If you don't want enable zencoding in all mode, you can use set a option in `vimrc`: - let g:user_zen_mode='n' "only enable normal mode functions. - let g:user_zen_mode='inv' "enable all functions, which is equal to - let g:user_zen_mode='a' "enable all function in all mode. + let g:user_zen_mode='n' "only enable normal mode functions. + let g:user_zen_mode='inv' "enable all functions, which is equal to + let g:user_zen_mode='a' "enable all function in all mode. ## Project Authors