1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
function! emmet#lang#scss#findTokens(str) abort
return emmet#lang#css#findTokens(a:str)
endfunction
function! emmet#lang#scss#parseIntoTree(abbr, type) abort
if a:abbr =~# '>'
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
else
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
endif
endfunction
function! emmet#lang#scss#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 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')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
if attr ==# 'id'
let str .= '#' . val
elseif attr ==# 'class'
let str .= '.' . val
else
let tmp .= attr . ': ' . val . ';'
endif
endfor
if len(tmp) > 0
let str .= " {\n"
for line in split(tmp, "\n")
let str .= indent . line . "\n"
endfor
else
let str .= " {\n"
endif
let inner = ''
for child in current.child
let inner .= emmet#toString(child, type, inline, filters, itemno)
endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
let str .= indent . inner . "${cursor}\n}\n"
else
return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
endif
return str
endfunction
function! emmet#lang#scss#imageSize() abort
call emmet#lang#css#imageSize()
endfunction
function! emmet#lang#scss#imageEncode() abort
return emmet#lang#css#imageEncode()
endfunction
function! emmet#lang#scss#parseTag(tag) abort
return emmet#lang#css#parseTag(a:tag)
endfunction
function! emmet#lang#scss#toggleComment() abort
call emmet#lang#css#toggleComment()
endfunction
function! emmet#lang#scss#balanceTag(flag) range abort
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
call setpos('.', curpos)
else
let curpos = emmet#util#getcurpos()
endif
if a:flag < 0
let ret = searchpair('}', '', '.\zs{')
else
let ret = searchpair('{', '', '}', 'bW')
endif
if ret > 0
let pos1 = emmet#util#getcurpos()[1:2]
if a:flag < 0
let pos2 = searchpairpos('{', '', '}')
else
let pos2 = searchpairpos('{', '', '}')
endif
let block = [pos1, pos2]
if emmet#util#regionIsValid(block)
call emmet#util#selectRegion(block)
return
endif
endif
if a:flag == -2 || a:flag == 2
silent! exe 'normal! gv'
else
call setpos('.', curpos)
endif
endfunction
function! emmet#lang#scss#moveNextPrevItem(flag) abort
return emmet#lang#scss#moveNextPrev(a:flag)
endfunction
function! emmet#lang#scss#moveNextPrev(flag) abort
call emmet#lang#css#moveNextPrev(a:flag)
endfunction
function! emmet#lang#scss#splitJoinTag() abort
call emmet#lang#css#splitJoinTag()
endfunction
function! emmet#lang#scss#removeTag() abort
call emmet#lang#css#removeTag()
endfunction
function! emmet#lang#scss#mergeLines() abort
call emmet#lang#css#mergeLines()
endfunction
|