mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-09 03:54:47 +08:00
move splitJoinTag into each types.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" zencoding.vim
|
" zencoding.vim
|
||||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||||
" Last Change: 02-Jun-2012.
|
" Last Change: 03-Jun-2012.
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@@ -428,43 +428,9 @@ function! zencoding#balanceTag(flag) range
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#splitJoinTag()
|
function! zencoding#splitJoinTag()
|
||||||
let curpos = getpos('.')
|
let type = zencoding#getFileType()
|
||||||
while 1
|
let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.type.'.vim')) ? type : 'html'
|
||||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
return zencoding#lang#{rtype}#splitJoinTag()
|
||||||
let pos1 = searchpos(mx, 'bcnW')
|
|
||||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
|
||||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
|
||||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
|
||||||
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
|
||||||
let content = content[:-3] . "></" . tag_name . '>'
|
|
||||||
call zencoding#util#setContent(block, content)
|
|
||||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
|
||||||
return
|
|
||||||
else
|
|
||||||
if tag_name[0] == '/'
|
|
||||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
|
||||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
|
||||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
|
||||||
else
|
|
||||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
|
||||||
endif
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
let content = zencoding#util#getContent(block)
|
|
||||||
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
|
||||||
let content = matchstr(content, mx)[:-2] . '/>'
|
|
||||||
call zencoding#util#setContent(block, content)
|
|
||||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
|
||||||
return
|
|
||||||
else
|
|
||||||
if block[0][0] > 0
|
|
||||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
|
||||||
else
|
|
||||||
call setpos('.', curpos)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#mergeLines() range
|
function! zencoding#mergeLines() range
|
||||||
|
|||||||
@@ -141,3 +141,7 @@ function! zencoding#lang#css#moveNextPrev(flag)
|
|||||||
startinsert
|
startinsert
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#lang#css#splitJoinTag()
|
||||||
|
" nothing to do
|
||||||
|
endfunction
|
||||||
|
|||||||
@@ -196,3 +196,7 @@ function! zencoding#lang#haml#moveNextPrev(flag)
|
|||||||
startinsert
|
startinsert
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#lang#haml#splitJoinTag()
|
||||||
|
" TODO
|
||||||
|
endfunction
|
||||||
|
|||||||
@@ -591,3 +591,43 @@ function! zencoding#lang#html#moveNextPrev(flag)
|
|||||||
startinsert
|
startinsert
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#lang#html#splitJoinTag()
|
||||||
|
let curpos = getpos('.')
|
||||||
|
while 1
|
||||||
|
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||||
|
let pos1 = searchpos(mx, 'bcnW')
|
||||||
|
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||||
|
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||||
|
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||||
|
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
||||||
|
let content = content[:-3] . "></" . tag_name . '>'
|
||||||
|
call zencoding#util#setContent(block, content)
|
||||||
|
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||||
|
return
|
||||||
|
else
|
||||||
|
if tag_name[0] == '/'
|
||||||
|
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||||
|
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||||
|
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||||
|
else
|
||||||
|
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||||
|
endif
|
||||||
|
let block = [pos1, pos2]
|
||||||
|
let content = zencoding#util#getContent(block)
|
||||||
|
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||||
|
let content = matchstr(content, mx)[:-2] . '/>'
|
||||||
|
call zencoding#util#setContent(block, content)
|
||||||
|
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||||
|
return
|
||||||
|
else
|
||||||
|
if block[0][0] > 0
|
||||||
|
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||||
|
else
|
||||||
|
call setpos('.', curpos)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
endfunction
|
||||||
|
|||||||
@@ -185,3 +185,7 @@ function! zencoding#lang#slim#moveNextPrev(flag)
|
|||||||
startinsert
|
startinsert
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#lang#slim#splitJoinTag()
|
||||||
|
" TODO
|
||||||
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user