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: diff --git a/autoload/emmet.vim b/autoload/emmet.vim index 5733e45..03fb698 100644 --- a/autoload/emmet.vim +++ b/autoload/emmet.vim @@ -1671,6 +1671,7 @@ let s:emmet_settings = { \ ."\t%body\n" \ ."\t\t${child}|\n", \ }, +\ 'attribute_style': 'hash', \ }, \ 'slim': { \ 'indentation': ' ', diff --git a/autoload/emmet/lang/css.vim b/autoload/emmet/lang/css.vim index 461b9fa..36bbc77 100644 --- a/autoload/emmet/lang/css.vim +++ b/autoload/emmet/lang/css.vim @@ -19,7 +19,7 @@ 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] + 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 = '' diff --git a/autoload/emmet/lang/haml.vim b/autoload/emmet/lang/haml.vim index 9e1a418..f0c5e88 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 attribute_style = emmet#getResource('haml', 'attribute_style', 'hash') let str = "" let comment_indent = '' @@ -32,8 +33,12 @@ 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' - else + if attribute_style == 'hash' + let tmp .= ' :' . attr . ' => true' + elseif attribute_style == 'html' + let tmp .= attr . '=true' + end + else if dollar_expr while Val =~ '\$\([^#{]\|$\)' let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') @@ -46,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 .= '{' . tmp . ' }' + 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 .= "/" diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim index 6c08eea..e6a8d92 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] = "" endif else while len(atts) 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': "\"\"", }, ], },