-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtest_add_component.lua
More file actions
211 lines (188 loc) · 5.67 KB
/
test_add_component.lua
File metadata and controls
211 lines (188 loc) · 5.67 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
---@diagnostic disable: undefined-field, undefined-global
local windline = require('windline')
local helper = require('windline.helpers')
local sep = helper.separators
local b_components = require('windline.components.basic')
local state = _G.WindLine.state
local HSL = require('wlanimation.utils')
local hl_list = {
Black = { 'white', 'black' },
White = { 'black', 'white' },
Normal = { 'NormalFg', 'NormalBg' },
Inactive = { 'InactiveFg', 'InactiveBg' },
Active = { 'ActiveFg', 'ActiveBg' },
}
local basic = {}
local airline_colors = {}
airline_colors.a = {
NormalSep = { 'magenta_a', 'magenta_b' },
InsertSep = { 'green_a', 'green_b' },
VisualSep = { 'yellow_a', 'yellow_b' },
ReplaceSep = { 'blue_a', 'blue_b' },
CommandSep = { 'red_a', 'red_b' },
Normal = { 'black', 'magenta_a' },
Insert = { 'black', 'green_a' },
Visual = { 'black', 'yellow_a' },
Replace = { 'black', 'blue_a' },
Command = { 'black', 'red_a' },
}
basic.divider = { b_components.divider, hl_list.Normal }
basic.section_a = {
name = 'section_a',
hl_colors = airline_colors.a,
text = function()
return {
{ ' ' .. state.mode[1] .. ' ', state.mode[2] },
}
end,
}
basic.section_z = {
name = 'section_z',
hl_colors = airline_colors.a,
text = function()
return {
{ ' ', state.mode[2] },
{ b_components.progress, '' },
{ ' ', '' },
{ b_components.line_col, '' },
}
end,
}
local language = 'EN'
basic.language = {
text = function()
return {
{ 'LANG: ', '' },
{
language,
'',
windline.make_click('change_language', function()
language = language == 'EN' and 'US' or 'EN'
end),
},
}
end,
}
local default = {
filetypes = { 'default' },
active = {
basic.section_a,
basic.divider,
basic.section_z,
basic.language,
},
inactive = {},
}
windline.setup({
colors_name = function(colors)
colors.magenta_a = colors.magenta
colors.magenta_b = HSL.rgb_to_hsl(colors.magenta):shade(0.5):to_rgb()
colors.magenta_c = HSL.rgb_to_hsl(colors.magenta):shade(0.7):to_rgb()
colors.yellow_a = colors.yellow
colors.yellow_b = HSL.rgb_to_hsl(colors.yellow):shade(0.5):to_rgb()
colors.yellow_c = HSL.rgb_to_hsl(colors.yellow):shade(0.7):to_rgb()
colors.blue_a = colors.blue
colors.blue_b = HSL.rgb_to_hsl(colors.blue):shade(0.5):to_rgb()
colors.blue_c = HSL.rgb_to_hsl(colors.blue):shade(0.7):to_rgb()
colors.green_a = colors.green
colors.green_b = HSL.rgb_to_hsl(colors.green):shade(0.5):to_rgb()
colors.green_c = HSL.rgb_to_hsl(colors.green):shade(0.7):to_rgb()
colors.red_a = colors.red
colors.red_b = HSL.rgb_to_hsl(colors.red):shade(0.5):to_rgb()
colors.red_c = HSL.rgb_to_hsl(colors.red):shade(0.7):to_rgb()
return colors
end,
statuslines = {
default,
},
})
local animation = require('wlanimation')
local effects = require('wlanimation.effects')
WindLine.test_add_comp = function()
animation.stop_all()
local green_anim = {}
windline.add_component({
name = 'test',
hl_colors = {
wave_green1 = { 'black', 'green_a' },
wave_green2 = { 'green_a', 'green_b' },
wave_green3 = { 'green_b', 'green_c' },
wave_green4 = { 'green_c', 'black' },
default = { 'black', 'black' },
},
text = function()
return {
{ ' ', 'default' },
{ sep.slant_right .. ' ', 'wave_green1' },
{ sep.slant_right .. ' ', 'wave_green2' },
{ sep.slant_right .. ' ', 'wave_green3' },
{ sep.slant_right .. ' ', 'wave_green4' },
{ ' ', 'default' },
}
end,
}, {
filetype = 'default',
position = 'right',
colors_name = function(colors)
colors.green_a = colors.NormalBg
colors.green_b = HSL.rgb_to_hsl(colors.NormalBg):shade(0.5):to_rgb()
colors.green_c = HSL.rgb_to_hsl(colors.NormalBg):shade(0.7):to_rgb()
return colors
end,
})
local colors = windline.get_colors()
green_anim = HSL.rgb_to_hsl(colors.green):shades(10, 8)
animation.animation({
data = {
{ 'green_a', effects.list_color(green_anim, 3) },
{ 'green_b', effects.list_color(green_anim, 2) },
{ 'green_c', effects.list_color(green_anim, 1) },
},
timeout = nil,
delay = 200,
interval = 150,
})
end
WindLine.test_remove_comp = function()
animation.stop_all()
windline.remove_component({ name = 'test', filetype = 'default' })
end
vim.api.nvim_set_keymap(
'n',
'<leader>x',
'<cmd>lua WindLine.test_add_comp()<cr>',
{}
)
vim.api.nvim_set_keymap(
'n',
'<leader>z',
'<cmd>lua WindLine.test_remove_comp()<cr>',
{}
)
-- test add_component auto
WindLine.test_remove_auto = function()
windline.remove_auto_component({ name = 'autocmd_md', autocmd = true })
end
WindLine.test_add_auto = function()
windline.add_autocmd_component({
text = function()
return 'auto cmd on markdown'
end,
}, {
filetype = 'markdown',
position = 'right',
name = 'autocmd_md',
})
end
vim.api.nvim_set_keymap(
'n',
'<leader>aa',
'<cmd>lua WindLine.test_add_auto()<cr>',
{}
)
vim.api.nvim_set_keymap(
'n',
'<leader>ar',
'<cmd>lua WindLine.test_remove_auto()<cr>',
{}
)