splitJoinTag for haml & slim.

This commit is contained in:
mattn
2012-06-04 22:58:01 +09:00
parent 85b6ed4349
commit 9835978968
4 changed files with 58 additions and 3 deletions

View File

@@ -140,3 +140,7 @@ endfunction
function! zencoding#lang#css#splitJoinTag()
" nothing to do
endfunction
function! zencoding#lang#css#removeTag()
" nothing to do
endfunction

View File

@@ -198,6 +198,34 @@ function! zencoding#lang#haml#moveNextPrev(flag)
endfunction
function! zencoding#lang#haml#splitJoinTag()
let n = line('.')
while n > 0
if getline(n) =~ '^\s*\ze%[a-z]'
let line = getline(n)
call setline(n, matchstr(line, '^\s*%\w\+\s*{[^}]*}'))
let sn = n
let n += 1
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
if getline(n) =~ '^\s*|'
while n < line('$')
let l = len(matchstr(getline(n), '^\s*'))
if l <= ml
break
endif
exe n "delete"
let n += 1
endwhile
call setpos('.', [0, sn, 1, 0])
else
let spaces = matchstr(getline(sn), '^\s*')
call append(sn, spaces . ' | ')
call setpos('.', [0, sn+1, 1, 0])
startinsert!
endif
break
endif
let n -= 1
endwhile
endfunction
function! zencoding#lang#haml#removeTag()

View File

@@ -187,7 +187,30 @@ function! zencoding#lang#slim#moveNextPrev(flag)
endfunction
function! zencoding#lang#slim#splitJoinTag()
" TODO
let n = line('.')
while n > 0
if getline(n) =~ '^\s*\ze[a-z]'
let sn = n
let n += 1
if getline(n) =~ '^\s*|'
while n < line('$')
if getline(n) !~ '^\s*|'
break
endif
exe n "delete"
let n += 1
endwhile
call setpos('.', [0, sn, 1, 0])
else
let spaces = matchstr(getline(sn), '^\s*')
call append(sn, spaces . ' | ')
call setpos('.', [0, sn+1, 1, 0])
startinsert!
endif
break
endif
let n -= 1
endwhile
endfunction
function! zencoding#lang#slim#removeTag()