-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlualine-config.lua
More file actions
201 lines (181 loc) · 6.09 KB
/
lualine-config.lua
File metadata and controls
201 lines (181 loc) · 6.09 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
local M = {
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-colorscheme' },
event = 'VimEnter',
}
M.opts = function()
local icons = require('config').defaults.icons
local utils = require('config.fn-utils')
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand('%:p:h')
local gitdir = vim.fn.finddir('.git', filepath .. ';')
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
check_lsp_started = function()
return next(vim.lsp.get_clients()) ~= nil
end,
check_session_exist = function()
return utils.is_loaded('resession.nvim') and require('resession').get_current() ~= nil
end,
check_cmp_visible = function()
return utils.is_loaded('blink.cmp') and require('blink.cmp').is_visible()
end,
check_hbac_loaded = function()
return utils.is_loaded('hbac.nvim') ~= nil
end,
}
local mode = {
'mode',
fmt = function(mode_string)
return string.format('%-7s', mode_string)
end,
}
local session_status = {
function()
return vim.fn.fnamemodify(require('resession').get_current(), ':t')
end,
icon = icons.lualine.session,
cond = conditions.check_session_exist
}
local branch = {
'branch',
icons_enabled = true,
icon = icons.lualine.git,
}
local path = {
function()
if vim.bo.buftype ~= '' then return '' end
local path = vim.fs.normalize(vim.fn.expand('%:.:h'))
return (#path > 0) and path or ''
end,
color = 'BlinkCmpGhostText',
}
-- local diff = {
-- function()
-- local gitsigns = vim.b.gitsigns_status_dict
-- if not gitsigns then return '' end
--
-- local diff_icon = '▪'
-- local parts = {}
--
-- if gitsigns.added and gitsigns.added > 0 then
-- table.insert(parts, '%#GitSignsAdd#' .. diff_icon)
-- end
-- if gitsigns.changed and gitsigns.changed > 0 then
-- table.insert(parts, '%#GitSignsChange#' .. diff_icon)
-- end
-- if gitsigns.removed and gitsigns.removed > 0 then
-- table.insert(parts, '%#GitSignsDelete#' .. diff_icon)
-- end
--
-- if #parts > 0 then
-- return table.concat(parts) .. ' '
-- end
-- return ''
-- end,
-- }
local blink_info = { source_name = '', kind = 0 }
local blink_kinds = {}
local cmp_kind = {
function()
blink_kinds = require('blink.cmp.types').CompletionItemKind
return '⌊' .. blink_info.source_name .. '⌉'
end,
color = function()
return ('BlinkCmpKind' .. ((blink_kinds[blink_info.kind]) or ''))
end,
-- padding = { right = 8 },
cond = conditions.check_cmp_visible
}
local cmp_label = {
function()
local info = require('blink.cmp').get_selected_item()
blink_info.kind = info.kind
blink_info.source_name = info.source_name
return info.label
end,
padding = { right = 0 },
cond = conditions.check_cmp_visible
}
local diagnostics = {
function()
local severities = {
{ name = 'errors', level = vim.diagnostic.severity.ERROR, hl = '%#DiagnosticError#' },
{ name = 'warnings', level = vim.diagnostic.severity.WARN, hl = '%#DiagnosticWarn#' },
{ name = 'info', level = vim.diagnostic.severity.INFO, hl = '%#DiagnosticInfo#' },
{ name = 'hints', level = vim.diagnostic.severity.HINT, hl = '%#DiagnosticHint#' },
}
local icon = '▪'
local total = 0
local output = {}
for _, sev in ipairs(severities) do
local count = #vim.diagnostic.get(0, { severity = sev.level })
total = total + count
if count > 0 then
table.insert(output, sev.hl .. icon)
end
end
if vim.bo.modifiable and total > 0 then
return table.concat(output) .. ' '
end
return ''
end,
}
local searchcount = {
'searchcount',
padding = { left = 2 },
color = 'OkMsg',
icon = icons.lualine.search,
}
local lsp_status = {
'lsp_status',
padding = { left = 1, right = 2 },
icon = icons.lualine.lsp,
symbols = { done = '' },
cond = conditions.check_lsp_started
}
local location = {
function()
return '%3l:%-2c'
end,
icon = icons.lualine.location
}
local hbac = {
function()
local cur_buf = vim.api.nvim_get_current_buf()
local _, pinned = pcall(require('hbac.state').is_pinned, cur_buf)
return pinned and 'pinned buffer' or ''
end,
padding = { left = 1, right = 2 },
color = 'WarningMsg',
-- icon = icons.lualine.pinned,
cond = conditions.check_hbac_loaded
}
return {
options = {
theme = require('plugins.colorscheme').lualine,
icons_enabled = true,
section_separators = ' ',
component_separators = ' ',
always_divide_middle = true,
},
sections = {
lualine_a = { mode },
lualine_b = { session_status, branch },
lualine_c = { path, searchcount, '%=', cmp_label, cmp_kind },
lualine_x = { diagnostics },
lualine_y = { hbac, lsp_status },
lualine_z = { location },
},
tabline = {},
extensions = { 'lazy', 'mason', 'oil' }
}
end
return M