forked from windwp/windline.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvscode.lua
229 lines (209 loc) · 6.26 KB
/
vscode.lua
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
local windline = require('windline')
local b_components = require('windline.components.basic')
local vim_components = require('windline.components.vim')
local git_rev_components = require('windline.components.git_rev')
local state = _G.WindLine.state
local utils = require('windline.utils')
local lsp_comps = require('windline.components.lsp')
local git_comps = require('windline.components.git')
local hl_list = {
Inactive = { 'InactiveFg', 'InactiveBg' },
Active = { 'ActiveFg', 'ActiveBg' },
default = { 'StatusFg', 'StatusBg' },
}
local basic = {}
local medium_width = 100
local large_width = 140
basic.divider = { b_components.divider, '' }
-- stylua: ignore
utils.change_mode_name({
['n'] = { ' -- Normal -- ' , 'Normal' } ,
['no'] = { ' -- Visual -- ' , 'Visual' } ,
['nov'] = { ' -- Visual -- ' , 'Visual' } ,
['noV'] = { ' -- Visual -- ' , 'Visual' } ,
['no'] = { ' -- Visual -- ' , 'Visual' } ,
['niI'] = { ' -- Normal -- ' , 'Normal' } ,
['niR'] = { ' -- Normal -- ' , 'Normal' } ,
['niV'] = { ' -- Normal -- ' , 'Normal' } ,
['v'] = { ' -- Visual -- ' , 'Visual' } ,
['V'] = { ' -- Visual -- ' , 'Visual' } ,
[''] = { ' -- Visual -- ' , 'Visual' } ,
['s'] = { ' -- Visual -- ' , 'Visual' } ,
['S'] = { ' -- Visual -- ' , 'Visual' } ,
[''] = { ' -- Visual -- ' , 'Visual' } ,
['i'] = { ' -- Insert -- ' , 'Insert' } ,
['ic'] = { ' -- Insert -- ' , 'Insert' } ,
['ix'] = { ' -- Insert -- ' , 'Insert' } ,
['R'] = { ' -- Replace -- ' , 'Replace' } ,
['Rc'] = { ' -- Replace -- ' , 'Replace' } ,
['Rv'] = { ' -- Normal -- ' , 'Normal' } ,
['Rx'] = { ' -- Normal -- ' , 'Normal' } ,
['c'] = { ' -- Commmand -- ' , 'Command' } ,
['cv'] = { ' -- Commmand -- ' , 'Command' } ,
['ce'] = { ' -- Commmand -- ' , 'Command' } ,
['r'] = { ' -- Replace -- ' , 'Replace' } ,
['rm'] = { ' -- Normal -- ' , 'Normal' } ,
['r?'] = { ' -- Normal -- ' , 'Normal' } ,
['!'] = { ' -- Normal -- ' , 'Normal' } ,
['t'] = { ' -- Normal -- ' , 'Command' } ,
['nt'] = { ' -- Terminal -- ' , 'Command' } ,
})
basic.vi_mode = {
name = 'vi_mode',
hl_colors = hl_list.default,
text = function()
return state.mode[1]
end,
}
basic.lsp_diagnos = {
name = 'diagnostic',
hl_colors = hl_list.default,
width = large_width,
text = function(bufnr)
if lsp_comps.check_lsp(bufnr) then
-- stylua: ignore
return {
{ lsp_comps.lsp_error({ format = ' %s', show_zero = true }), '' },
{ lsp_comps.lsp_warning({ format = ' %s', show_zero = true }), '' },
}
end
return ''
end,
}
basic.file = {
name = 'file_name',
text = function()
return {
{ b_components.cache_file_name('', 'unique'), '' },
{ b_components.file_modified(' ') },
}
end,
}
local line_col = function()
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
return string.format(' Ln %3s, Col %-2s ', row, col + 1)
end
local spaces = function()
return 'Spaces: ' .. vim.api.nvim_buf_get_option(0, 'shiftwidth') .. ' '
end
local line_format = function()
local format_icons = {
unix = 'LF',
dos = 'CRLF',
mac = 'LF',
}
return function()
return format_icons[vim.bo.fileformat] or vim.bo.fileformat
end
end
basic.line_col_right = {
hl_colors = hl_list.default,
text = function(_, _, width)
if
vim.api.nvim_buf_get_option(0, 'filetype') == ''
and vim.fn.wordcount().bytes < 1
then
return ''
end
if width > medium_width then
return {
{ line_col },
{ spaces },
{ b_components.file_encoding() },
{ ' ' },
{ line_format() },
{ ' ' },
}
end
return {
{ line_col, '' },
}
end,
}
basic.lsp_name = {
width = medium_width,
name = 'lsp_name',
text = function(bufnr)
if lsp_comps.check_lsp(bufnr) then
return {
{ lsp_comps.lsp_name() },
}
end
return {
{ b_components.cache_file_type({ icon = true, default = '' }) },
}
end,
}
basic.git_branch = {
name = 'git_branch',
hl_colors = hl_list.default,
width = medium_width,
text = function(bufnr)
if git_comps.is_git(bufnr) then
return {
{ git_comps.git_branch(), hl_list.default, large_width },
{
git_rev_components.git_rev(),
hl_list.default,
large_width,
},
}
end
return ''
end,
}
local explorer = {
filetypes = { 'fern', 'NvimTree', 'lir' },
active = {
{ ' ', hl_list.Inactive },
{ b_components.divider },
{ b_components.file_name('') },
},
always_active = true,
show_last_status = true,
}
local default = {
filetypes = { 'default' },
active = {
basic.git_branch,
basic.lsp_diagnos,
basic.vi_mode,
{ vim_components.search_count() },
basic.divider,
{ ' ' },
basic.file,
basic.line_col_right,
{ ' ' },
basic.lsp_name,
},
inactive = {
{ b_components.full_file_name, hl_list.Inactive },
basic.file_name_inactive,
basic.divider,
basic.divider,
{ b_components.line_col, hl_list.Inactive },
{ b_components.progress, hl_list.Inactive },
},
}
local M = {}
M.setup = function()
windline.setup({
colors_name = function(colors)
colors.StatusFg = colors.ActiveFg
colors.StatusBg = colors.ActiveBg
return colors
end,
statuslines = {
default,
explorer,
},
})
end
M.setup()
M.change_color = function(bgcolor, fgcolor)
local colors = windline.get_colors()
colors.StatusFg = fgcolor or colors.StatusFg
colors.StatusBg = bgcolor or colors.StatusBg
windline.on_colorscheme(colors)
end
return M