-
Notifications
You must be signed in to change notification settings - Fork 7
/
evilline.lua
477 lines (428 loc) · 10.6 KB
/
evilline.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
local gl = require('galaxyline')
local gps = require('nvim-gps')
local gls = gl.section
local extension = require('galaxyline.provider_extensions')
local dap = require('dap')
gl.short_line_list = {
'LuaTree',
'NvimTree',
'vista',
'dbui',
'startify',
'term',
'nerdtree',
'fugitive',
'fugitiveblame',
'plug',
'plugins'
}
VistaPlugin = extension.vista_nearest
local ProgFileTypes = {'lua', 'python', 'typescript', 'typescriptreact', 'react', 'javascript', 'javascriptreact', 'rust', 'go', 'html'}
-- for checking value in table
local function has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
local function get_color()
if vim.o.background == 'light' then
return "#fff"
end
return "#353644"
end
local function get_color_bg()
if vim.o.background == 'light' then
return "#fff"
end
return "#282c34"
end
-- then change in colors line_bg = get_color_bg
local colors = {
bg = "#282c34",
line_bg = "#353644",
fg = '#8FBCBB',
fg_green = '#65a380',
yellow = '#fabd2f',
cyan = '#008080',
darkblue = '#081633',
green = '#afd700',
orange = '#FF8800',
purple = '#5d4d7a',
magenta = '#c678dd',
blue = '#51afef';
red = '#ec5f67'
}
local function file_readonly(readonly_icon)
if vim.bo.filetype == 'help' then
return ''
end
local icon = readonly_icon or ''
if vim.bo.readonly == true then
return " " .. icon .. " "
end
return ''
end
-- get current file name
local function get_current_file_name()
-- local file = vim.fn.expand('%:t')
local file = vim.fn.expand('%:f')
if vim.fn.empty(file) == 1 then return '' end
if string.len(file_readonly(readonly_icon)) ~= 0 then
return file .. file_readonly(readonly_icon)
end
local icon = modified_icon or ''
if vim.bo.modifiable then
if vim.bo.modified then
return file .. ' ' .. icon .. ' '
end
end
return file .. ' '
end
local function lsp_status(status)
shorter_stat = ''
for match in string.gmatch(status, "[^%s]+") do
err_warn = string.find(match, "^[WE]%d+", 0)
if not err_warn then
shorter_stat = shorter_stat .. ' ' .. match
end
end
return shorter_stat
end
local function get_coc_lsp()
local status = vim.fn['coc#status']()
if not status or status == '' then
return ''
end
return lsp_status(status)
end
local function get_debug_status()
local status = dap.status()
if not status or status == '' then
return ''
end
return ' ' .. status
end
function get_diagnostic_info()
if vim.fn.exists('*coc#rpc#start_server') == 1 then
return get_coc_lsp()
end
return ''
end
local function get_current_func()
local has_func, func_name = pcall(vim.api.nvim_buf_get_var,0,'coc_current_function')
if not has_func then return end
return func_name
end
function get_function_info()
if vim.fn.exists('*coc#rpc#start_server') == 1 then
return get_current_func()
end
return ''
end
local function trailing_whitespace()
local trail = vim.fn.search("\\s$", "nw")
if trail ~= 0 then
return ' '
else
return nil
end
end
-- current_func_status with treesitter
-- local function get_current_func_from_treesitter()
-- local opts = {
-- indicator_size = 100,
-- type_patterns = {'class', 'function', 'method', },
-- transform_fn = function(line) return line:gsub('%s*[%[%(%{]*%s*$', '') end,
-- separator = ' ',
-- }
-- local status = vim.fn['nvim_treesitter#statusline'](opts)
-- if not status or status == '' then
-- return ''
-- end
-- return status
-- end
-- local function get_current_context()
-- if vim.fn.exists('nvim_treesitter#statusline') == 1 then
-- return get_current_func_from_treesitter()
-- end
-- return ''
-- end
CocStatus = get_diagnostic_info
DebugInfo = get_debug_status
CocFunc = get_current_func
-- TreesitterContext = get_current_func_from_treesitter
TrailingWhiteSpace = trailing_whitespace
function has_file_type()
local f_type = vim.bo.filetype
if not f_type or f_type == '' then
return false
end
return true
end
function has_file_prog_filetype()
local f_type = vim.bo.filetype
if not f_type or f_type == '' then
return false
end
if has_value(ProgFileTypes, f_type) then
return true
end
return false
end
local buffer_not_empty = function()
if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then
return true
end
return false
end
gls.left[1] = {
FirstElement = {
provider = function() return ' ' end,
highlight = {colors.blue,colors.line_bg}
},
}
gls.left[2] = {
ViMode = {
provider = function()
-- auto change color() according the vim mode
local alias = {
n = 'NORMAL',
i = 'INSERT',
c= 'COMMAND',
V= 'VISUAL',
[''] = 'VISUAL',
v ='VISUAL',
c = 'COMMAND-LINE',
['r?'] = ':CONFIRM',
rm = '--MORE',
R = 'REPLACE',
Rv = 'VIRTUAL',
s = 'SELECT',
S = 'SELECT',
['r'] = 'HIT-ENTER',
[''] = 'SELECT',
t = 'TERMINAL',
['!'] = 'SHELL',
}
local mode_color = {
n = colors.green,
i = colors.blue,v=colors.magenta,[''] = colors.blue,V=colors.blue,
c = colors.red,no = colors.magenta,s = colors.orange,S=colors.orange,
[''] = colors.orange,ic = colors.yellow,R = colors.purple,Rv = colors.purple,
cv = colors.red,ce=colors.red, r = colors.cyan,rm = colors.cyan, ['r?'] = colors.cyan,
['!'] = colors.green,t = colors.green,
c = colors.purple,
['r?'] = colors.red,
['r'] = colors.red,
rm = colors.red,
R = colors.yellow,
Rv = colors.magenta,
}
local vim_mode = vim.fn.mode()
vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color[vim_mode])
return alias[vim_mode] .. ' '
end,
highlight = {colors.red,colors.line_bg,'bold'},
},
}
gls.left[3] ={
FileIcon = {
provider = 'FileIcon',
condition = buffer_not_empty,
highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color,colors.line_bg},
},
}
gls.left[4] = {
FileName = {
provider = {get_current_file_name,'FileSize'},
condition = buffer_not_empty,
highlight = {colors.fg,colors.line_bg,'bold'}
}
}
gls.left[5] = {
GitIcon = {
provider = function() return ' ' end,
condition = require('galaxyline.provider_vcs').check_git_workspace,
highlight = {colors.yellow,colors.line_bg},
}
}
gls.left[6] = {
GitBranch = {
provider = 'GitBranch',
condition = require('galaxyline.provider_vcs').check_git_workspace,
highlight = {colors.yellow,colors.line_bg,'bold'},
}
}
local checkwidth = function()
local squeeze_width = vim.fn.winwidth(0) / 2
if squeeze_width > 40 then
return true
end
return false
end
gls.left[13] = {
Space = {
provider = function () return '' end
}
}
gls.left[7] = {
DiffAdd = {
provider = 'DiffAdd',
condition = checkwidth,
icon = ' ',
highlight = {colors.green,colors.line_bg},
}
}
gls.left[8] = {
DiffModified = {
provider = 'DiffModified',
condition = checkwidth,
icon = ' ',
highlight = {colors.orange,colors.line_bg},
}
}
gls.left[9] = {
DiffRemove = {
provider = 'DiffRemove',
condition = checkwidth,
icon = ' ',
highlight = {colors.red,colors.line_bg},
}
}
gls.left[10] = {
LeftEnd = {
provider = function() return '' end,
separator = '',
separator_highlight = {colors.bg,colors.line_bg},
highlight = {colors.line_bg,colors.line_bg}
}
}
gls.left[11] = {
TrailingWhiteSpace = {
provider = TrailingWhiteSpace,
icon = ' ',
highlight = {colors.yellow,colors.bg},
}
}
gls.left[12] = {
DiagnosticError = {
provider = 'DiagnosticError',
icon = ' ',
highlight = {colors.red,colors.bg}
}
}
gls.left[13] = {
Space = {
provider = function () return '' end
}
}
gls.left[14] = {
DiagnosticWarn = {
provider = 'DiagnosticWarn',
icon = ' ',
highlight = {colors.yellow,colors.bg},
}
}
gls.left[15] = {
CocStatus = {
provider = CocStatus,
highlight = {colors.green,colors.bg},
icon = ' '
}
}
-- gls.left[16] = {
-- CocFunc = {
-- provider = CocFunc,
-- icon = ' ',
-- highlight = {colors.yellow,colors.bg},
-- }
-- }
-- gls.left[17] = {
-- TreesitterContext = {
-- provider = TreesitterContext,
-- condition = has_file_prog_filetype,
-- icon = ' λ ',
-- highlight = {colors.yellow,colors.bg},
-- }
-- }
gls.left[17] = {
nvimGPS = {
provider = function()
return gps.get_location()
end,
condition = function()
return gps.is_available()
end,
icon = ' ',
highlight = {colors.yellow,colors.bg},
}
}
gls.right[1]= {
FileFormat = {
provider = 'FileFormat',
separator = ' ',
separator_highlight = {colors.bg,colors.line_bg},
highlight = {colors.fg,colors.line_bg,'bold'},
}
}
gls.right[2] = {
Debug = {
provider = DebugInfo,
separator = ' ',
separator_highlight = {colors.blue,colors.line_bg},
separator_highlight = {colors.bg,colors.line_bg},
highlight = {colors.red,colors.line_bg,'bold'},
}
}
gls.right[4] = {
LineInfo = {
provider = 'LineColumn',
separator = ' | ',
separator_highlight = {colors.blue,colors.line_bg},
highlight = {colors.fg,colors.line_bg},
},
}
gls.right[5] = {
PerCent = {
provider = 'LinePercent',
separator = ' ',
separator_highlight = {colors.line_bg,colors.line_bg},
highlight = {colors.cyan,colors.darkblue,'bold'},
}
}
-- gls.right[4] = {
-- ScrollBar = {
-- provider = 'ScrollBar',
-- highlight = {colors.blue,colors.purple},
-- }
-- }
--
-- gls.right[3] = {
-- Vista = {
-- provider = VistaPlugin,
-- separator = ' ',
-- separator_highlight = {colors.bg,colors.line_bg},
-- highlight = {colors.fg,colors.line_bg,'bold'},
-- }
-- }
gls.short_line_left[1] = {
BufferType = {
provider = 'FileTypeName',
separator = '',
condition = has_file_type,
separator_highlight = {colors.purple,colors.bg},
highlight = {colors.fg,colors.purple}
}
}
gls.short_line_right[1] = {
BufferIcon = {
provider= 'BufferIcon',
separator = '',
condition = has_file_type,
separator_highlight = {colors.purple,colors.bg},
highlight = {colors.fg,colors.purple}
}
}