-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlualine.lua
More file actions
246 lines (237 loc) · 6.94 KB
/
lualine.lua
File metadata and controls
246 lines (237 loc) · 6.94 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
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
return {
"nvim-lualine/lualine.nvim",
opts = function(_, opts)
local auto = require("lualine.themes.auto")
local colors = {
rosewater = "#f2d5cf",
flamingo = "#eebebe",
pink = "#f4b8e4",
mauve = "#ca9ee6",
red = "#e78284",
maroon = "#ea999c",
peach = "#ef9f76",
yellow = "#e5c890",
green = "#a6d189",
teal = "#81c8be",
sky = "#99d1db",
sapphire = "#85c1dc",
blue = "#8caaee",
lavender = "#babbf1",
text = "#c6d0f5",
subtext1 = "#b5bfe2",
subtext0 = "#a5adce",
overlay2 = "#949cbb",
overlay1 = "#838ba7",
overlay0 = "#737994",
surface2 = "#626880",
surface1 = "#51576d",
surface0 = "#414559",
base = "#303446",
mantle = "#292c3c",
crust = "#232634",
}
local function separator()
return {
function()
return "│"
end,
color = { fg = colors.surface0, bg = "NONE", gui = "bold" },
padding = { left = 1, right = 1 },
}
end
local function custom_branch()
local gitsigns = vim.b.gitsigns_head
local fugitive = vim.fn.exists("*FugitiveHead") == 1 and vim.fn.FugitiveHead() or ""
local branch = gitsigns or fugitive
if branch == nil or branch == "" then
return ""
else
return " " .. branch
end
end
local modes = { "normal", "insert", "visual", "replace", "command", "inactive", "terminal" }
for _, mode in ipairs(modes) do
if auto[mode] and auto[mode].c then
auto[mode].c.bg = "NONE"
end
end
opts.options = vim.tbl_deep_extend("force", opts.options or {}, {
theme = auto,
component_separators = "",
section_separators = "",
globalstatus = true,
disabled_filetypes = { statusline = {}, winbar = {} },
})
opts.sections = {
lualine_a = {
{
"mode",
fmt = function(str)
return str:sub(1, 1)
end,
color = function()
local mode = vim.fn.mode()
if mode == "\22" then
return { fg = "none", bg = colors.red, gui = "bold" }
elseif mode == "V" then
return { fg = colors.red, bg = "none", gui = "underline,bold" }
else
return { fg = colors.red, bg = "none", gui = "bold" }
end
end,
padding = { left = 0, right = 0 },
},
},
lualine_b = {
separator(),
{
custom_branch,
color = { fg = colors.green, bg = "none", gui = "bold" },
padding = { left = 0, right = 0 },
},
{
"diff",
colored = true,
diff_color = {
added = { fg = colors.teal, bg = "none", gui = "bold" },
modified = { fg = colors.yellow, bg = "none", gui = "bold" },
removed = { fg = colors.red, bg = "none", gui = "bold" },
},
symbols = { added = "+", modified = "~", removed = "-" },
source = nil,
padding = { left = 1, right = 0 },
},
},
lualine_c = {
separator(),
{
"filetype",
icon_only = true,
colored = false,
color = { fg = colors.blue, bg = "none", gui = "bold" },
padding = { left = 0, right = 1 },
},
{
"filename",
file_status = true,
path = 0,
shorting_target = 20,
symbols = {
modified = "[+]",
readonly = "[-]",
unnamed = "[?]",
newfile = "[!]",
},
color = { fg = colors.blue, bg = "none", gui = "bold" },
padding = { left = 0, right = 0 },
},
separator(),
{
function()
local bufnr_list = vim.fn.getbufinfo({ buflisted = 1 })
local total = #bufnr_list
local current_bufnr = vim.api.nvim_get_current_buf()
local current_index = 0
for i, buf in ipairs(bufnr_list) do
if buf.bufnr == current_bufnr then
current_index = i
break
end
end
return string.format(" %d/%d", current_index, total)
end,
color = { fg = colors.yellow, bg = "none", gui = "bold" },
padding = { left = 0, right = 0 },
},
},
lualine_x = {
{
"fileformat",
color = { fg = colors.yellow, bg = "none", gui = "bold" },
symbols = {
unix = "",
dos = "",
mac = "",
},
padding = { left = 0, right = 0 },
},
{
"encoding",
color = { fg = colors.yellow, bg = "none", gui = "bold" },
padding = { left = 1, right = 0 },
},
separator(),
{
function()
local size = vim.fn.getfsize(vim.api.nvim_buf_get_name(0))
if size < 0 then
return "-"
else
if size < 1024 then
return size .. "B"
elseif size < 1024 * 1024 then
return string.format("%.1fK", size / 1024)
elseif size < 1024 * 1024 * 1024 then
return string.format("%.1fM", size / (1024 * 1024))
else
return string.format("%.1fG", size / (1024 * 1024 * 1024))
end
end
end,
color = { fg = colors.blue, bg = "none", gui = "bold" },
padding = { left = 0, right = 0 },
},
},
lualine_y = {
separator(),
{
"diagnostics",
sources = { "nvim_diagnostic", "coc" },
sections = { "error", "warn", "info", "hint" },
diagnostics_color = {
error = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })
return { fg = (count == 0) and colors.green or colors.red, bg = "none", gui = "bold" }
end,
warn = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
return { fg = (count == 0) and colors.green or colors.yellow, bg = "none", gui = "bold" }
end,
info = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO })
return { fg = (count == 0) and colors.green or colors.blue, bg = "none", gui = "bold" }
end,
hint = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT })
return { fg = (count == 0) and colors.green or colors.teal, bg = "none", gui = "bold" }
end,
},
symbols = {
error = " ",
warn = " ",
info = " ",
hint = " ",
},
colored = true,
update_in_insert = false,
always_visible = true,
padding = { left = 0, right = 0 },
},
},
lualine_z = {
separator(),
{
"progress",
color = { fg = colors.red, bg = "none", gui = "bold" },
padding = { left = 0, right = 0 },
},
{
"location",
color = { fg = colors.red, bg = "none", gui = "bold" },
padding = { left = 1, right = 0 },
},
},
}
return opts
end,
}