From ca6296fb7fc1400822edf89c8b0c54be544dfa20 Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 17 Jul 2014 09:23:16 +0900 Subject: [PATCH 01/11] parenthesis for haml #216 --- autoload/emmet.vim | 1 + autoload/emmet/lang/haml.vim | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/emmet.vim b/autoload/emmet.vim index 5733e45..32cdf7e 100644 --- a/autoload/emmet.vim +++ b/autoload/emmet.vim @@ -1671,6 +1671,7 @@ let s:emmet_settings = { \ ."\t%body\n" \ ."\t\t${child}|\n", \ }, +\ 'parenthesis': '{}', \ }, \ 'slim': { \ 'indentation': ' ', diff --git a/autoload/emmet/lang/haml.vim b/autoload/emmet/lang/haml.vim index 9e1a418..35c709e 100644 --- a/autoload/emmet/lang/haml.vim +++ b/autoload/emmet/lang/haml.vim @@ -15,6 +15,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite let itemno = a:itemno let indent = emmet#getIndentation(type) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) + let parenthesis = emmet#getResource('haml', 'parenthesis', '()') let str = "" let comment_indent = '' @@ -33,7 +34,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite let Val = current.attr[attr] if type(Val) == 2 && Val == function('emmet#types#true') let tmp .= ' :' . attr . ' => true' - else + else if dollar_expr while Val =~ '\$\([^#{]\|$\)' let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') @@ -53,7 +54,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite endif endfor if len(tmp) - let str .= '{' . tmp . ' }' + let str .= parenthesis[0] . tmp . ' '. parenthesis[1] endif if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0 let str .= "/" From 761adcc4bead8140c87099128fea71458d481aa6 Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 17 Jul 2014 09:35:04 +0900 Subject: [PATCH 02/11] Fix typo --- autoload/emmet.vim | 2 +- autoload/emmet/lang/haml.vim | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/emmet.vim b/autoload/emmet.vim index 32cdf7e..6326f86 100644 --- a/autoload/emmet.vim +++ b/autoload/emmet.vim @@ -1671,7 +1671,7 @@ let s:emmet_settings = { \ ."\t%body\n" \ ."\t\t${child}|\n", \ }, -\ 'parenthesis': '{}', +\ 'parentheses': '{}', \ }, \ 'slim': { \ 'indentation': ' ', diff --git a/autoload/emmet/lang/haml.vim b/autoload/emmet/lang/haml.vim index 35c709e..36e9d27 100644 --- a/autoload/emmet/lang/haml.vim +++ b/autoload/emmet/lang/haml.vim @@ -15,7 +15,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite let itemno = a:itemno let indent = emmet#getIndentation(type) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) - let parenthesis = emmet#getResource('haml', 'parenthesis', '()') + let parentheses = emmet#getResource('haml', 'parentheses', '()') let str = "" let comment_indent = '' @@ -54,7 +54,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite endif endfor if len(tmp) - let str .= parenthesis[0] . tmp . ' '. parenthesis[1] + let str .= parentheses[0] . tmp . ' '. parentheses[1] endif if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0 let str .= "/" From 437cd920044185b956d6ff6b8e9f4abbc1744bbd Mon Sep 17 00:00:00 2001 From: Conrad Decker Date: Thu, 17 Jul 2014 09:40:35 -0400 Subject: [PATCH 03/11] Changed 'parenthesis' setting to 'attribute_style' setting to allow for choice between 'hash' and 'html' Updated output to correctly display html-style attributes or hash-style attributes. 'attribute_style' setting defaults to hash but can be updated by the user to use html style attributes --- autoload/emmet.vim | 2 +- autoload/emmet/lang/haml.vim | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/autoload/emmet.vim b/autoload/emmet.vim index 6326f86..03fb698 100644 --- a/autoload/emmet.vim +++ b/autoload/emmet.vim @@ -1671,7 +1671,7 @@ let s:emmet_settings = { \ ."\t%body\n" \ ."\t\t${child}|\n", \ }, -\ 'parentheses': '{}', +\ 'attribute_style': 'hash', \ }, \ 'slim': { \ 'indentation': ' ', diff --git a/autoload/emmet/lang/haml.vim b/autoload/emmet/lang/haml.vim index 36e9d27..f0c5e88 100644 --- a/autoload/emmet/lang/haml.vim +++ b/autoload/emmet/lang/haml.vim @@ -15,7 +15,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite let itemno = a:itemno let indent = emmet#getIndentation(type) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) - let parentheses = emmet#getResource('haml', 'parentheses', '()') + let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash') let str = "" let comment_indent = '' @@ -33,7 +33,11 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite endif let Val = current.attr[attr] if type(Val) == 2 && Val == function('emmet#types#true') - let tmp .= ' :' . attr . ' => true' + if attribute_style == 'hash' + let tmp .= ' :' . attr . ' => true' + elseif attribute_style == 'html' + let tmp .= attr . '=true' + end else if dollar_expr while Val =~ '\$\([^#{]\|$\)' @@ -47,14 +51,28 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite elseif attr == 'class' && len(valtmp) > 0 let str .= '.' . substitute(Val, ' ', '.', 'g') else - if len(tmp) > 0 | let tmp .= ',' | endif + if len(tmp) > 0 + if attribute_style == 'hash' + let tmp .= ',' + elseif attribute_style == 'html' + let tmp .= ' ' + endif + endif let Val = substitute(Val, '\${cursor}', '', '') - let tmp .= ' :' . attr . ' => "' . Val . '"' + if attribute_style == 'hash' + let tmp .= ' :' . attr . ' => "' . Val . '"' + elseif attribute_style == 'html' + let tmp .= attr . '="' . Val . '"' + end endif endif endfor if len(tmp) - let str .= parentheses[0] . tmp . ' '. parentheses[1] + if attribute_style == 'hash' + let str .= '{' . tmp . ' }' + elseif attribute_style == 'html' + let str .= '(' . tmp . ')' + end endif if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0 let str .= "/" From 08eb534c42f2da7905beeadb8ea94b75701f404d Mon Sep 17 00:00:00 2001 From: gilgamesh Date: Thu, 17 Jul 2014 16:47:41 -0300 Subject: [PATCH 04/11] Small fix related to VIM Tip #436 http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U Suppose you do the following: div.foo.bar.baz, This will be expanded to
Then you realize that you wanted yyy instead of baz. You press ESC and u and notice that you don't have your original string in the undo log (div.foo.bar.baz). This patch fixes this behaviour. --- plugin/emmet.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/emmet.vim b/plugin/emmet.vim index 46ca45a..7f597cd 100644 --- a/plugin/emmet.vim +++ b/plugin/emmet.vim @@ -147,7 +147,7 @@ function! s:install_plugin(mode, buffer) let key = g:user_emmet_leader_key . item.key endif if len(maparg(key, item.mode)) == 0 - exe item.mode . 'map ' . buffer . ' ' . key . ' (' . item.plug . ')' + exe item.mode . 'map ' . buffer . ' ' . key . ' u(' . item.plug . ')' endif endfor endfunction From 0f45689b81fed573b09c06b236ca56e061f535c5 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 18 Jul 2014 13:13:54 +0900 Subject: [PATCH 05/11] Set attributes. fix #218 --- autoload/emmet/lang/html.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim index 6c08eea..5442ee3 100644 --- a/autoload/emmet/lang/html.vim +++ b/autoload/emmet/lang/html.vim @@ -213,6 +213,8 @@ function! emmet#lang#html#parseIntoTree(abbr, type) endif if len(ks) > 0 let current.attr[ks[0]] = atts + else + let current.attr[atts] = function('emmet#types#true') endif else while len(atts) From 23aea8c21a08a1e07de4e0efd9b6cfd1ca50815d Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 18 Jul 2014 20:14:08 +0900 Subject: [PATCH 06/11] Revert 08eb534c42f2da7905beeadb8ea94b75701f404d, because test is failing --- plugin/emmet.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/emmet.vim b/plugin/emmet.vim index 7f597cd..46ca45a 100644 --- a/plugin/emmet.vim +++ b/plugin/emmet.vim @@ -147,7 +147,7 @@ function! s:install_plugin(mode, buffer) let key = g:user_emmet_leader_key . item.key endif if len(maparg(key, item.mode)) == 0 - exe item.mode . 'map ' . buffer . ' ' . key . ' u(' . item.plug . ')' + exe item.mode . 'map ' . buffer . ' ' . key . ' (' . item.plug . ')' endif endfor endfunction From dcf247fb5cd81c694a9032936f49e0f8010729a8 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 18 Jul 2014 20:15:22 +0900 Subject: [PATCH 07/11] Fix test --- unittest.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittest.vim b/unittest.vim index 20d74ed..1498f5c 100644 --- a/unittest.vim +++ b/unittest.vim @@ -560,7 +560,7 @@ finish 'tests': [ { 'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\,\\i$$$$", - 'result': "\"\"", + 'result': "\"\"", }, { 'query': "img[src=/logo.png]$$$$\\,\\i$$$$", @@ -568,7 +568,7 @@ finish }, { 'query': "img[src=http://mattn.kaoriya.net/images/logo.png width=foo height=bar]$$$$\\,\\i$$$$", - 'result': "\"\"", + 'result': "\"\"", }, ], }, From 2b94508a466988216e1d405accdd515dea79f316 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 18 Jul 2014 20:29:28 +0900 Subject: [PATCH 08/11] div[foo bar] should be expanded into
. close #218 --- autoload/emmet/lang/html.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim index 5442ee3..e6a8d92 100644 --- a/autoload/emmet/lang/html.vim +++ b/autoload/emmet/lang/html.vim @@ -214,7 +214,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type) if len(ks) > 0 let current.attr[ks[0]] = atts else - let current.attr[atts] = function('emmet#types#true') + let current.attr[atts] = "" endif else while len(atts) From 92fa2e568fe7f5ae614e78737405f19bbdaded64 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Thu, 24 Jul 2014 08:13:18 +0200 Subject: [PATCH 09/11] Fix Vundle instructions - Fix syntax to work in .vimrc - The Bundle command is being renamed to Plugin (although Bundle still works for now) --- README.mkd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.mkd b/README.mkd index b0079e4..d459236 100644 --- a/README.mkd +++ b/README.mkd @@ -20,8 +20,8 @@ To install using pathogen.vim: To install using [Vundle](https://github.com/gmarik/vundle): - # add this line to your .vimrc file - Bundle "mattn/emmet-vim" + " add this line to your .vimrc file + Plugin 'mattn/emmet-vim' To checkout the source from repository: From bd6060ba919179b2cde232ab8faabb4c7d5a2ca5 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 4 Aug 2014 11:46:05 +0900 Subject: [PATCH 10/11] Workaround for sass, fixes #222 --- autoload/emmet/lang/css.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/emmet/lang/css.vim b/autoload/emmet/lang/css.vim index 461b9fa..794cc6c 100644 --- a/autoload/emmet/lang/css.vim +++ b/autoload/emmet/lang/css.vim @@ -19,7 +19,8 @@ function! emmet#lang#css#parseIntoTree(abbr, type) " emmet let tokens = split(abbr, '+\ze[^+)!]') let block = emmet#util#searchRegion("{", "}") - if abbr !~ '^@' && emmet#getBaseType(type) == 'css' && block[0] == [0,0] && block[1] == [0,0] + let g:hoge = type + if abbr !~ '^@' && emmet#getBaseType(type) == 'css' && type != 'sass' && block[0] == [0,0] && block[1] == [0,0] let current = emmet#newNode() let current.snippet = abbr . " {\n" . indent . "${cursor}\n}" let current.name = '' From 39d8f88ccd5a43bedff5303af54f96f184794936 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 4 Aug 2014 12:21:02 +0900 Subject: [PATCH 11/11] Remove debug code --- autoload/emmet/lang/css.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/emmet/lang/css.vim b/autoload/emmet/lang/css.vim index 794cc6c..36bbc77 100644 --- a/autoload/emmet/lang/css.vim +++ b/autoload/emmet/lang/css.vim @@ -19,7 +19,6 @@ function! emmet#lang#css#parseIntoTree(abbr, type) " emmet let tokens = split(abbr, '+\ze[^+)!]') let block = emmet#util#searchRegion("{", "}") - let g:hoge = type if abbr !~ '^@' && emmet#getBaseType(type) == 'css' && type != 'sass' && block[0] == [0,0] && block[1] == [0,0] let current = emmet#newNode() let current.snippet = abbr . " {\n" . indent . "${cursor}\n}"