Expand paren when type is css

This commit is contained in:
mattn
2013-09-26 09:57:06 +09:00
parent f8095a65dd
commit bd4c1bfaef
5 changed files with 49 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
"=============================================================================
" emmet.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 09-Sep-2013.
" Last Change: 26-Sep-2013.
let s:save_cpo = &cpo
set cpo&vim
@@ -546,8 +546,13 @@ function! emmet#expandAbbr(mode, abbr) range
let part = matchstr(line, '\(\S.*\)$')
let ftype = emmet#lang#exists(type) ? type : 'html'
let part = emmet#lang#{ftype}#findTokens(part)
let line = line[0: stridx(line, part) + len(part) - 1]
endif
if col('.') == col('$')
let rest = ''
else
let rest = getline('.')[len(line):]
endif
let rest = getline('.')[len(line):]
let str = part
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
if str =~ mx
@@ -618,7 +623,7 @@ function! emmet#expandAbbr(mode, abbr) range
silent! foldopen
endif
silent! exe "normal! v7h\"_s"
if col('.') == col('$') - 1
if col('.') == col('$')
call feedkeys('', 'n')
endif
let &selection = oldselection

View File

@@ -1,5 +1,5 @@
function! emmet#lang#css#findTokens(str)
return substitute(a:str, '^.*[;{]\s*', '', '')
return substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
endfunction
function! emmet#lang#css#parseIntoTree(abbr, type)
@@ -19,7 +19,7 @@ function! emmet#lang#css#parseIntoTree(abbr, type)
" emmet
let tokens = split(abbr, '+\ze[^+)!]')
let block = emmet#util#searchRegion("{", "}")
if block[0] == [0,0] && block[1] == [0,0]
if type == 'css' && block[0] == [0,0] && block[1] == [0,0]
let current = emmet#newNode()
let current.snippet = abbr . " {\n\t${cursor}\n}"
let current.name = ''

View File

@@ -1,5 +1,7 @@
function! emmet#lang#sass#findTokens(str)
return emmet#lang#html#findTokens(a:str)
"let g:hoge = substitute(a:str, '^.*[;{@]\s*', '', '')
"return substitute(a:str, '^.*[;{@]\s*', '', '')
return a:str
endfunction
function! emmet#lang#sass#parseIntoTree(abbr, type)

View File

@@ -109,7 +109,7 @@ endfunction
function! emmet#util#searchRegion(start, end)
let b = searchpairpos(a:start, '', a:end, 'bcnW')
if b == [0, 0]
return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'ncW')]
return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
else
return [b, searchpairpos(a:start, '', a:end. '', 'nW')]
endif