Refactoring

This commit is contained in:
Yasuhiro Matsumoto committed 2026-03-07 11:08:24 +09:00
1 parent e983971449
commit 7c44caa0e6
14 files changed
+2452 -2452

No files matched your search

+80 -80
View File
@@ -7,59 +7,59 @@ function! emmet#lang#sass#parseIntoTree(abbr, type) abort
endfunction
function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort
let settings = a:settings
let current = a:current
let type = a:type
let inline = a:inline
let filters = a:filters
let itemno = a:itemno
let indent = a:indent
let str = ''
let l:settings = a:settings
let l:current = a:current
let l:type = a:type
let l:inline = a:inline
let l:filters = a:filters
let l:itemno = a:itemno
let l:indent = a:indent
let l:str = ''
let current_name = current.name
let current_name = substitute(current.name, '\$$', itemno+1, '')
if len(current.name) > 0
let str .= current_name
let tmp = ''
for attr in keys(current.attr)
let val = current.attr[attr]
while val =~# '\$\([^#{]\|$\)'
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let l:current_name = l:current.name
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
if len(l:current.name) > 0
let l:str .= l:current_name
let l:tmp = ''
for l:attr in keys(l:current.attr)
let l:val = l:current.attr[l:attr]
while l:val =~# '\$\([^#{]\|$\)'
let l:val = substitute(l:val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
if attr ==# 'id'
let str .= '#' . val
elseif attr ==# 'class'
let str .= '.' . val
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
if l:attr ==# 'id'
let l:str .= '#' . l:val
elseif l:attr ==# 'class'
let l:str .= '.' . l:val
else
let tmp .= attr . ': ' . val
let l:tmp .= l:attr . ': ' . l:val
endif
endfor
if len(tmp) > 0
let str .= "\n"
for line in split(tmp, "\n")
let str .= indent . line . "\n"
if len(l:tmp) > 0
let l:str .= "\n"
for l:line in split(l:tmp, "\n")
let l:str .= l:indent . l:line . "\n"
endfor
else
let str .= "\n"
let l:str .= "\n"
endif
let inner = ''
for child in current.child
let tmp = emmet#toString(child, type, inline, filters, itemno, indent)
let tmp = substitute(tmp, "\n", "\n" . escape(indent, '\'), 'g')
let tmp = substitute(tmp, "\n" . escape(indent, '\') . '$', '${cursor}\n', 'g')
let inner .= tmp
let l:inner = ''
for l:child in l:current.child
let l:tmp = emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
let l:tmp = substitute(l:tmp, "\n", "\n" . escape(l:indent, '\'), 'g')
let l:tmp = substitute(l:tmp, "\n" . escape(l:indent, '\') . '$', '${cursor}\n', 'g')
let l:inner .= l:tmp
endfor
if len(inner) > 0
let str .= indent . inner
if len(l:inner) > 0
let l:str .= l:indent . l:inner
endif
else
let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
return text
let l:text = emmet#lang#css#toString(l:settings, l:current, l:type, l:inline, l:filters, l:itemno, l:indent)
let l:text = substitute(l:text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
return l:text
endif
return str
return l:str
endfunction
function! emmet#lang#sass#imageSize() abort
@@ -75,67 +75,67 @@ function! emmet#lang#sass#toggleComment() abort
endfunction
function! emmet#lang#sass#balanceTag(flag) range abort
let block = emmet#util#getVisualBlock()
let l:block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
let l:curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = emmet#util#getcurpos()
let l:curpos = emmet#util#getcurpos()
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
let l:n = l:curpos[1]
let l:ml = len(matchstr(getline(l:n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.')
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
let l:n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l < ml
let ml = l
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l < l:ml
let l:ml = l:l
break
endif
let n -= 1
let l:n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l: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
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l > l:ml
let l:ml = l:l
break
endif
let n += 1
let l:n += 1
endwhile
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
endif
endfunction
@@ -144,10 +144,10 @@ function! emmet#lang#sass#moveNextPrevItem(flag) abort
endfunction
function! emmet#lang#sass#moveNextPrev(flag) abort
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2
let l:pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if l:pos == 2
startinsert!
elseif pos != 0
elseif l:pos != 0
silent! normal! l
startinsert
endif