2021-10-10 21:07:41 +02:00
|
|
|
local conditions = require "lvim.core.lualine.conditions"
|
|
|
|
local colors = require "lvim.core.lualine.colors"
|
2021-08-20 11:16:29 +02:00
|
|
|
|
2021-08-26 09:20:04 +02:00
|
|
|
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
|
|
|
|
|
2022-11-04 17:57:24 +01:00
|
|
|
local location_color = "SLBranchName"
|
|
|
|
local branch = "%#SLGitIcon#" .. lvim.icons.git.Branch .. "%*" .. "%#SLBranchName#"
|
|
|
|
local separator = "%#SLSeparator#" .. lvim.icons.ui.LineMiddle .. "%*"
|
2022-09-20 22:03:27 +02:00
|
|
|
|
2021-08-20 11:16:29 +02:00
|
|
|
return {
|
2021-08-24 08:49:18 +02:00
|
|
|
mode = {
|
2021-08-20 11:16:29 +02:00
|
|
|
function()
|
2022-10-03 05:48:23 +02:00
|
|
|
return " " .. lvim.icons.ui.Target .. " "
|
2021-08-20 11:16:29 +02:00
|
|
|
end,
|
2021-09-15 21:11:21 +02:00
|
|
|
padding = { left = 0, right = 0 },
|
2021-08-24 08:49:18 +02:00
|
|
|
color = {},
|
2021-09-15 21:11:21 +02:00
|
|
|
cond = nil,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
branch = {
|
2021-08-26 09:20:04 +02:00
|
|
|
"b:gitsigns_head",
|
2022-09-20 22:03:27 +02:00
|
|
|
icon = branch,
|
2021-08-24 08:49:18 +02:00
|
|
|
color = { gui = "bold" },
|
|
|
|
},
|
|
|
|
filename = {
|
|
|
|
"filename",
|
|
|
|
color = {},
|
2021-09-15 21:11:21 +02:00
|
|
|
cond = nil,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
diff = {
|
|
|
|
"diff",
|
2021-08-26 09:20:04 +02:00
|
|
|
source = diff_source,
|
2022-10-03 05:48:23 +02:00
|
|
|
symbols = {
|
|
|
|
added = lvim.icons.git.LineAdded .. " ",
|
|
|
|
modified = lvim.icons.git.LineModified .. " ",
|
|
|
|
removed = lvim.icons.git.LineRemoved .. " ",
|
|
|
|
},
|
2022-09-21 20:41:48 +02:00
|
|
|
padding = { left = 2, right = 1 },
|
2021-09-15 21:11:21 +02:00
|
|
|
diff_color = {
|
|
|
|
added = { fg = colors.green },
|
|
|
|
modified = { fg = colors.yellow },
|
|
|
|
removed = { fg = colors.red },
|
|
|
|
},
|
|
|
|
cond = nil,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
python_env = {
|
|
|
|
function()
|
2021-10-10 21:07:41 +02:00
|
|
|
local utils = require "lvim.core.lualine.utils"
|
2021-08-20 11:16:29 +02:00
|
|
|
if vim.bo.filetype == "python" then
|
2022-08-29 14:47:21 +02:00
|
|
|
local venv = os.getenv "CONDA_DEFAULT_ENV" or os.getenv "VIRTUAL_ENV"
|
2021-08-20 11:16:29 +02:00
|
|
|
if venv then
|
2022-10-03 05:48:23 +02:00
|
|
|
local icons = require "nvim-web-devicons"
|
|
|
|
local py_icon, _ = icons.get_icon ".py"
|
|
|
|
return string.format(" " .. py_icon .. " (%s)", utils.env_cleanup(venv))
|
2021-08-20 11:16:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return ""
|
|
|
|
end,
|
2021-08-24 08:49:18 +02:00
|
|
|
color = { fg = colors.green },
|
2021-09-15 21:11:21 +02:00
|
|
|
cond = conditions.hide_in_width,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
"diagnostics",
|
2021-12-11 09:46:36 +01:00
|
|
|
sources = { "nvim_diagnostic" },
|
2022-10-03 05:48:23 +02:00
|
|
|
symbols = {
|
|
|
|
error = lvim.icons.diagnostics.BoldError .. " ",
|
|
|
|
warn = lvim.icons.diagnostics.BoldWarning .. " ",
|
|
|
|
info = lvim.icons.diagnostics.BoldInformation .. " ",
|
|
|
|
hint = lvim.icons.diagnostics.BoldHint .. " ",
|
|
|
|
},
|
2022-09-20 22:03:27 +02:00
|
|
|
-- cond = conditions.hide_in_width,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
treesitter = {
|
|
|
|
function()
|
2022-10-03 05:48:23 +02:00
|
|
|
return lvim.icons.ui.Tree
|
2022-08-09 13:32:35 +02:00
|
|
|
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 }
|
2021-08-20 11:16:29 +02:00
|
|
|
end,
|
2021-09-15 21:11:21 +02:00
|
|
|
cond = conditions.hide_in_width,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
lsp = {
|
|
|
|
function(msg)
|
2021-09-05 16:03:58 +02:00
|
|
|
msg = msg or "LS Inactive"
|
2021-08-20 11:16:29 +02:00
|
|
|
local buf_clients = vim.lsp.buf_get_clients()
|
|
|
|
if next(buf_clients) == nil then
|
2021-09-06 20:23:41 +02:00
|
|
|
-- TODO: clean up this if statement
|
|
|
|
if type(msg) == "boolean" or #msg == 0 then
|
2021-09-05 16:03:58 +02:00
|
|
|
return "LS Inactive"
|
|
|
|
end
|
2021-08-20 11:16:29 +02:00
|
|
|
return msg
|
|
|
|
end
|
|
|
|
local buf_ft = vim.bo.filetype
|
|
|
|
local buf_client_names = {}
|
2022-10-07 06:52:37 +02:00
|
|
|
local copilot_active = false
|
2021-08-20 11:16:29 +02:00
|
|
|
|
|
|
|
-- add client
|
|
|
|
for _, client in pairs(buf_clients) do
|
2022-10-07 06:52:37 +02:00
|
|
|
if client.name ~= "null-ls" and client.name ~= "copilot" then
|
2021-08-20 11:16:29 +02:00
|
|
|
table.insert(buf_client_names, client.name)
|
|
|
|
end
|
2022-10-07 06:52:37 +02:00
|
|
|
|
|
|
|
if client.name == "copilot" then
|
|
|
|
copilot_active = true
|
|
|
|
end
|
2021-08-20 11:16:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- add formatter
|
2021-10-10 21:07:41 +02:00
|
|
|
local formatters = require "lvim.lsp.null-ls.formatters"
|
2022-01-01 14:25:23 +01:00
|
|
|
local supported_formatters = formatters.list_registered(buf_ft)
|
2021-08-20 11:16:29 +02:00
|
|
|
vim.list_extend(buf_client_names, supported_formatters)
|
|
|
|
|
|
|
|
-- add linter
|
2021-10-10 21:07:41 +02:00
|
|
|
local linters = require "lvim.lsp.null-ls.linters"
|
2022-01-01 14:25:23 +01:00
|
|
|
local supported_linters = linters.list_registered(buf_ft)
|
2021-08-20 11:16:29 +02:00
|
|
|
vim.list_extend(buf_client_names, supported_linters)
|
|
|
|
|
2022-06-23 08:02:15 +02:00
|
|
|
local unique_client_names = vim.fn.uniq(buf_client_names)
|
2022-10-07 06:52:37 +02:00
|
|
|
|
|
|
|
local language_servers = "[" .. table.concat(unique_client_names, ", ") .. "]"
|
|
|
|
|
|
|
|
if copilot_active then
|
|
|
|
language_servers = language_servers .. "%#SLCopilot#" .. " " .. lvim.icons.git.Octoface .. "%*"
|
|
|
|
end
|
|
|
|
|
|
|
|
return language_servers
|
2021-08-20 11:16:29 +02:00
|
|
|
end,
|
2022-09-21 23:58:52 +02:00
|
|
|
separator = separator,
|
2021-08-20 11:16:29 +02:00
|
|
|
color = { gui = "bold" },
|
2021-09-15 21:11:21 +02:00
|
|
|
cond = conditions.hide_in_width,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
2022-09-20 22:03:27 +02:00
|
|
|
location = { "location", color = location_color },
|
|
|
|
progress = {
|
|
|
|
"progress",
|
|
|
|
fmt = function()
|
|
|
|
return "%P/%L"
|
|
|
|
end,
|
|
|
|
color = {},
|
|
|
|
},
|
2022-09-21 23:58:52 +02:00
|
|
|
|
2021-08-20 11:16:29 +02:00
|
|
|
spaces = {
|
|
|
|
function()
|
2022-09-21 23:58:52 +02:00
|
|
|
local shiftwidth = vim.api.nvim_buf_get_option(0, "shiftwidth")
|
2022-10-03 05:48:23 +02:00
|
|
|
return lvim.icons.ui.Tab .. " " .. shiftwidth
|
2021-08-20 11:16:29 +02:00
|
|
|
end,
|
2022-09-21 23:58:52 +02:00
|
|
|
separator = separator,
|
|
|
|
padding = 1,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
encoding = {
|
|
|
|
"o:encoding",
|
2021-09-15 21:11:21 +02:00
|
|
|
fmt = string.upper,
|
2021-08-24 08:49:18 +02:00
|
|
|
color = {},
|
2021-09-15 21:11:21 +02:00
|
|
|
cond = conditions.hide_in_width,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
2022-09-21 23:58:52 +02:00
|
|
|
filetype = { "filetype", cond = nil, padding = { left = 1, right = 1 } },
|
2021-08-20 11:16:29 +02:00
|
|
|
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,
|
2021-09-15 21:11:21 +02:00
|
|
|
padding = { left = 0, right = 0 },
|
2022-09-20 22:03:27 +02:00
|
|
|
color = "SLProgress",
|
2021-09-15 21:11:21 +02:00
|
|
|
cond = nil,
|
2021-08-20 11:16:29 +02:00
|
|
|
},
|
|
|
|
}
|