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
|
local conditions = require "lvim.core.lualine.conditions"
local colors = require "lvim.core.lualine.colors"
local function diff_source()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end
local statusline_hl = vim.api.nvim_get_hl_by_name("StatusLine", true)
local cursorline_hl = vim.api.nvim_get_hl_by_name("CursorLine", true)
local normal_hl = vim.api.nvim_get_hl_by_name("Normal", true)
vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = cursorline_hl.background })
vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.foreground, bg = cursorline_hl.background })
vim.api.nvim_set_hl(0, "SLProgress", { fg = "#ECBE7B", bg = statusline_hl.background })
local location_color = nil
local branch = ""
if lvim.colorscheme == "tokyonight" then
location_color = "SLBranchName"
branch = "%#SLGitIcon#" .. "" .. "%*" .. "%#SLBranchName#"
end
return {
mode = {
function()
return " "
end,
padding = { left = 0, right = 0 },
color = {},
cond = nil,
},
branch = {
"b:gitsigns_head",
icon = branch,
color = { gui = "bold" },
},
filename = {
"filename",
color = {},
cond = nil,
},
diff = {
"diff",
source = diff_source,
symbols = { added = " ", modified = " ", removed = " " },
padding = { left = 2, right = 1 },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.yellow },
removed = { fg = colors.red },
},
cond = nil,
},
python_env = {
function()
local utils = require "lvim.core.lualine.utils"
if vim.bo.filetype == "python" then
local venv = os.getenv "CONDA_DEFAULT_ENV" or os.getenv "VIRTUAL_ENV"
if venv then
return string.format(" (%s)", utils.env_cleanup(venv))
end
end
return ""
end,
color = { fg = colors.green },
cond = conditions.hide_in_width,
},
diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = { error = " ", warn = " ", info = " ", hint = " " },
-- cond = conditions.hide_in_width,
},
treesitter = {
function()
return ""
end,
color = function()
local buf = vim.api.nvim_get_current_buf()
local ts = vim.treesitter.highlighter.active[buf]
return { fg = ts and not vim.tbl_isempty(ts) and colors.green or colors.red }
end,
cond = conditions.hide_in_width,
},
lsp = {
function(msg)
msg = msg or "LS Inactive"
local buf_clients = vim.lsp.buf_get_clients()
if next(buf_clients) == nil then
-- TODO: clean up this if statement
if type(msg) == "boolean" or #msg == 0 then
return "LS Inactive"
end
return msg
end
local buf_ft = vim.bo.filetype
local buf_client_names = {}
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local formatters = require "lvim.lsp.null-ls.formatters"
local supported_formatters = formatters.list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local linters = require "lvim.lsp.null-ls.linters"
local supported_linters = linters.list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
local unique_client_names = vim.fn.uniq(buf_client_names)
return "[" .. table.concat(unique_client_names, ", ") .. "]"
end,
color = { gui = "bold" },
cond = conditions.hide_in_width,
},
location = { "location", color = location_color },
progress = {
"progress",
fmt = function()
return "%P/%L"
end,
color = {},
},
spaces = {
function()
if not vim.api.nvim_buf_get_option(0, "expandtab") then
return "Tab size: " .. vim.api.nvim_buf_get_option(0, "tabstop") .. " "
end
local size = vim.api.nvim_buf_get_option(0, "shiftwidth")
if size == 0 then
size = vim.api.nvim_buf_get_option(0, "tabstop")
end
return "Spaces: " .. size .. " "
end,
cond = conditions.hide_in_width,
color = {},
},
encoding = {
"o:encoding",
fmt = string.upper,
color = {},
cond = conditions.hide_in_width,
},
filetype = { "filetype", cond = conditions.hide_in_width, padding = { left = 1, right = 2 } },
scrollbar = {
function()
local current_line = vim.fn.line "."
local total_lines = vim.fn.line "$"
local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
return chars[index]
end,
padding = { left = 0, right = 0 },
color = "SLProgress",
cond = nil,
},
}
|