-
Notifications
You must be signed in to change notification settings - Fork 0
/
lualine.lua
164 lines (154 loc) · 3.84 KB
/
lualine.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
local M = {
"nvim-lualine/lualine.nvim",
dependencies = { "SmiteshP/nvim-navic" },
}
local clients_lsp = function()
local clients = vim.lsp.get_clients({ bufnr = 0 })
if next(clients) == nil then
return ""
end
local c = {}
for _, client in pairs(clients) do
if not (client.name == "null-ls") then
table.insert(c, client.name)
end
end
return "\u{f085} " .. table.concat(c, "|")
end
function M.config()
local sl_hl = vim.api.nvim_get_hl_by_name("StatusLine", true)
vim.api.nvim_set_hl(0, "Copilot", { fg = "#6CC644", bg = sl_hl.background })
local icons = require("user.lspicons")
local diff = {
"diff",
colored = true,
symbols = { added = icons.git.LineAdded, modified = icons.git.LineModified, removed = icons.git.LineRemoved },
}
local copilot = function()
local buf_clients = vim.lsp.active_clients({ bufnr = 0 })
if #buf_clients == 0 then
return "LSP Inactive"
end
local buf_client_names = {}
local copilot_active = false
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
if client.name == "copilot" then
copilot_active = true
end
end
if copilot_active then
return "%#Copilot#" .. icons.git.Octoface .. "%*"
end
return ""
end
local navic_ok, navic = pcall(require, "nvim-navic")
local git_blame_ok, git_blame = pcall(require, "gitblame")
local arrow_ok, arrow = pcall(require, "arrow.statusline")
require("lualine").setup({
options = {
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
ignore_focus = { "NvimTree", "noice", "qf" },
globalstatus = true,
globalwinbar = true,
disabled_filetypes = {
"help",
"qf",
"nofile",
"NvimTree",
"terminal",
"fugitiveblame",
"fugitive",
"fzf",
"lazy",
"mason",
"trouble",
},
},
sections = {
lualine_a = {
"mode",
{
function()
if not arrow_ok then return nil end
return arrow.text_for_statusline_with_icons()
end,
cond = function()
if not arrow_ok then return nil end
return arrow.is_on_arrow_file() ~= nil
end,
},
{
function()
local rec = vim.fn.reg_recording()
if rec == "" then
return ""
else
return "Recording @" .. rec
end
end,
},
},
lualine_b = { { "branch", icon = icons.git.Branch }, diff },
lualine_c = {},
lualine_x = {
{
function()
if not git_blame_ok then return nil end
return git_blame.get_current_blame_text()
end,
cond = function()
if not git_blame_ok then return false end
return git_blame.is_blame_text_available
end
},
"diagnostics",
clients_lsp,
copilot,
},
lualine_y = {
{
"fileformat",
icons_enabled = true,
symbols = {
unix = icons.misc.Unix,
dos = icons.misc.Dos,
mac = icons.misc.Mac,
},
},
"filetype",
},
},
inactive_sections = {
lualine_a = {},
lualine_b = { "filename" },
lualine_x = { "filetype" },
},
extensions = { "quickfix", "man", "fugitive", "fzf", "lazy", "mason" },
disabled_filetypes = {
statusline = { "NvimTree", "terminal", "glow" },
winbar = { "NvimTree", "terminal", "glow" },
},
winbar = {
lualine_a = {
{
function()
if not navic_ok then return nil end
return navic.get_location()
end,
cond = function()
if not navic_ok then return false end
return navic.is_available()
end,
color = "WarningMsg",
},
},
},
inactive_winbar = {},
})
end
return M