This commit is contained in:
sheoak
2014-08-04 15:07:09 +02:00
6 changed files with 32 additions and 10 deletions

View File

@@ -20,8 +20,8 @@ To install using pathogen.vim:
To install using [Vundle](https://github.com/gmarik/vundle): To install using [Vundle](https://github.com/gmarik/vundle):
# add this line to your .vimrc file " add this line to your .vimrc file
Bundle "mattn/emmet-vim" Plugin 'mattn/emmet-vim'
To checkout the source from repository: To checkout the source from repository:

View File

@@ -1671,6 +1671,7 @@ let s:emmet_settings = {
\ ."\t%body\n" \ ."\t%body\n"
\ ."\t\t${child}|\n", \ ."\t\t${child}|\n",
\ }, \ },
\ 'attribute_style': 'hash',
\ }, \ },
\ 'slim': { \ 'slim': {
\ 'indentation': ' ', \ 'indentation': ' ',

View File

@@ -19,7 +19,7 @@ function! emmet#lang#css#parseIntoTree(abbr, type)
" emmet " emmet
let tokens = split(abbr, '+\ze[^+)!]') let tokens = split(abbr, '+\ze[^+)!]')
let block = emmet#util#searchRegion("{", "}") 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 = emmet#newNode()
let current.snippet = abbr . " {\n" . indent . "${cursor}\n}" let current.snippet = abbr . " {\n" . indent . "${cursor}\n}"
let current.name = '' let current.name = ''

View File

@@ -15,6 +15,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
let itemno = a:itemno let itemno = a:itemno
let indent = emmet#getIndentation(type) let indent = emmet#getIndentation(type)
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash')
let str = "" let str = ""
let comment_indent = '' let comment_indent = ''
@@ -32,7 +33,11 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
endif endif
let Val = current.attr[attr] let Val = current.attr[attr]
if type(Val) == 2 && Val == function('emmet#types#true') if type(Val) == 2 && Val == function('emmet#types#true')
if attribute_style == 'hash'
let tmp .= ' :' . attr . ' => true' let tmp .= ' :' . attr . ' => true'
elseif attribute_style == 'html'
let tmp .= attr . '=true'
end
else else
if dollar_expr if dollar_expr
while Val =~ '\$\([^#{]\|$\)' while Val =~ '\$\([^#{]\|$\)'
@@ -46,14 +51,28 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
elseif attr == 'class' && len(valtmp) > 0 elseif attr == 'class' && len(valtmp) > 0
let str .= '.' . substitute(Val, ' ', '.', 'g') let str .= '.' . substitute(Val, ' ', '.', 'g')
else 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 Val = substitute(Val, '\${cursor}', '', '')
if attribute_style == 'hash'
let tmp .= ' :' . attr . ' => "' . Val . '"' let tmp .= ' :' . attr . ' => "' . Val . '"'
elseif attribute_style == 'html'
let tmp .= attr . '="' . Val . '"'
end
endif endif
endif endif
endfor endfor
if len(tmp) if len(tmp)
if attribute_style == 'hash'
let str .= '{' . tmp . ' }' let str .= '{' . tmp . ' }'
elseif attribute_style == 'html'
let str .= '(' . tmp . ')'
end
endif endif
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0 if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
let str .= "/" let str .= "/"

View File

@@ -213,6 +213,8 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
endif endif
if len(ks) > 0 if len(ks) > 0
let current.attr[ks[0]] = atts let current.attr[ks[0]] = atts
else
let current.attr[atts] = ""
endif endif
else else
while len(atts) while len(atts)

View File

@@ -560,7 +560,7 @@ finish
'tests': [ 'tests': [
{ {
'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$", 'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"96\" height=\"96\">", 'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"113\" height=\"113\">",
}, },
{ {
'query': "img[src=/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$", 'query': "img[src=/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
@@ -568,7 +568,7 @@ finish
}, },
{ {
'query': "img[src=http://mattn.kaoriya.net/images/logo.png width=foo height=bar]$$$$\\<c-y>,\\<c-y>i$$$$", 'query': "img[src=http://mattn.kaoriya.net/images/logo.png width=foo height=bar]$$$$\\<c-y>,\\<c-y>i$$$$",
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"96\" height=\"96\">", 'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"113\" height=\"113\">",
}, },
], ],
}, },