mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-07 19:24:27 +08:00
balanceTag for haml & slim.
This commit is contained in:
@@ -125,6 +125,7 @@ function! zencoding#lang#haml#toggleComment()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#lang#haml#balanceTag(flag) range
|
function! zencoding#lang#haml#balanceTag(flag) range
|
||||||
|
let block = zencoding#util#getVisualBlock()
|
||||||
if a:flag == -2 || a:flag == 2
|
if a:flag == -2 || a:flag == 2
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
let curpos = [0, line("'<"), col("'<"), 0]
|
||||||
else
|
else
|
||||||
@@ -133,26 +134,59 @@ function! zencoding#lang#haml#balanceTag(flag) range
|
|||||||
let n = curpos[1]
|
let n = curpos[1]
|
||||||
let ml = len(matchstr(getline(n), '^\s*'))
|
let ml = len(matchstr(getline(n), '^\s*'))
|
||||||
|
|
||||||
while n > 0
|
if a:flag > 0
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||||
if l > 0 && l < ml
|
let n = line('.')
|
||||||
let ml = l
|
else
|
||||||
break
|
while n > 0
|
||||||
endif
|
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
||||||
let n -= 1
|
if l > 0 && l < ml
|
||||||
endwhile
|
let ml = l
|
||||||
let sn = n
|
break
|
||||||
while n < line('$')
|
endif
|
||||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
let n -= 1
|
||||||
if l > 0 && l <= ml
|
endwhile
|
||||||
let n -= 1
|
endif
|
||||||
break
|
let sn = n
|
||||||
endif
|
if n == 0
|
||||||
let n += 1
|
let ml = 0
|
||||||
endwhile
|
endif
|
||||||
call setpos('.', [0, sn, 1, 0])
|
while n < line('$')
|
||||||
normal! V
|
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||||
call setpos('.', [0, n, 1, 0])
|
if l > 0 && l <= ml
|
||||||
|
let n -= 1
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let n += 1
|
||||||
|
endwhile
|
||||||
|
call setpos('.', [0, n, 1, 0])
|
||||||
|
normal! V
|
||||||
|
call setpos('.', [0, sn, 1, 0])
|
||||||
|
else
|
||||||
|
while n > 0
|
||||||
|
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||||
|
if l > 0 && l > ml
|
||||||
|
let ml = l
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let n += 1
|
||||||
|
endwhile
|
||||||
|
let sn = n
|
||||||
|
if n == 0
|
||||||
|
let ml = 0
|
||||||
|
endif
|
||||||
|
while n < line('$')
|
||||||
|
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||||
|
if l > 0 && l <= ml
|
||||||
|
let n -= 1
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let n += 1
|
||||||
|
endwhile
|
||||||
|
call setpos('.', [0, n, 1, 0])
|
||||||
|
normal! V
|
||||||
|
call setpos('.', [0, sn, 1, 0])
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#lang#haml#moveNextPrev(flag)
|
function! zencoding#lang#haml#moveNextPrev(flag)
|
||||||
|
|||||||
@@ -112,6 +112,68 @@ function! zencoding#lang#slim#toggleComment()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#lang#slim#balanceTag(flag) range
|
function! zencoding#lang#slim#balanceTag(flag) range
|
||||||
|
let block = zencoding#util#getVisualBlock()
|
||||||
|
if a:flag == -2 || a:flag == 2
|
||||||
|
let curpos = [0, line("'<"), col("'<"), 0]
|
||||||
|
else
|
||||||
|
let curpos = getpos('.')
|
||||||
|
endif
|
||||||
|
let n = curpos[1]
|
||||||
|
let ml = len(matchstr(getline(n), '^\s*'))
|
||||||
|
|
||||||
|
if a:flag > 0
|
||||||
|
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||||
|
let n = line('.')
|
||||||
|
else
|
||||||
|
while n > 0
|
||||||
|
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||||
|
if l > 0 && l < ml
|
||||||
|
let ml = l
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let n -= 1
|
||||||
|
endwhile
|
||||||
|
endif
|
||||||
|
let sn = n
|
||||||
|
if n == 0
|
||||||
|
let ml = 0
|
||||||
|
endif
|
||||||
|
while n < line('$')
|
||||||
|
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||||
|
if l > 0 && l <= ml
|
||||||
|
let n -= 1
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let n += 1
|
||||||
|
endwhile
|
||||||
|
call setpos('.', [0, n, 1, 0])
|
||||||
|
normal! V
|
||||||
|
call setpos('.', [0, sn, 1, 0])
|
||||||
|
else
|
||||||
|
while n > 0
|
||||||
|
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||||
|
if l > 0 && l > ml
|
||||||
|
let ml = l
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let n += 1
|
||||||
|
endwhile
|
||||||
|
let sn = n
|
||||||
|
if n == 0
|
||||||
|
let ml = 0
|
||||||
|
endif
|
||||||
|
while n < line('$')
|
||||||
|
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||||
|
if l > 0 && l <= ml
|
||||||
|
let n -= 1
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let n += 1
|
||||||
|
endwhile
|
||||||
|
call setpos('.', [0, n, 1, 0])
|
||||||
|
normal! V
|
||||||
|
call setpos('.', [0, sn, 1, 0])
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#lang#slim#moveNextPrev(flag)
|
function! zencoding#lang#slim#moveNextPrev(flag)
|
||||||
|
|||||||
Reference in New Issue
Block a user