|
|
@ -1,7 +1,13 @@
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
|
|
|
|
local lsp = require("feline.providers.lsp")
|
|
|
|
local lsp = require("feline.providers.lsp")
|
|
|
|
local lsp_severity = vim.diagnostic.severity
|
|
|
|
local lsp_severity = vim.diagnostic.severity
|
|
|
|
local b = vim.b
|
|
|
|
local b = vim.b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local clrs = require("catppuccin.palettes.init").get_palette()
|
|
|
|
|
|
|
|
local ucolors = require("catppuccin.utils.colors")
|
|
|
|
|
|
|
|
local latte = require("catppuccin.palettes.latte")
|
|
|
|
|
|
|
|
|
|
|
|
local assets = {
|
|
|
|
local assets = {
|
|
|
|
left_semicircle = "",
|
|
|
|
left_semicircle = "",
|
|
|
|
right_semicircle = "",
|
|
|
|
right_semicircle = "",
|
|
|
@ -26,11 +32,9 @@ local assets = {
|
|
|
|
slim_dot = "•",
|
|
|
|
slim_dot = "•",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local clrs = require("catppuccin.palettes.init").get_palette()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- settings
|
|
|
|
|
|
|
|
local sett = {
|
|
|
|
local sett = {
|
|
|
|
bkg = clrs.surface0,
|
|
|
|
text = ucolors.vary_color({ latte = latte.base }, clrs.surface0),
|
|
|
|
|
|
|
|
bkg = ucolors.vary_color({ latte = latte.crust }, clrs.surface0),
|
|
|
|
diffs = clrs.mauve,
|
|
|
|
diffs = clrs.mauve,
|
|
|
|
extras = clrs.overlay1,
|
|
|
|
extras = clrs.overlay1,
|
|
|
|
curr_file = clrs.maroon,
|
|
|
|
curr_file = clrs.maroon,
|
|
|
@ -60,376 +64,390 @@ local mode_colors = {
|
|
|
|
["!"] = { "SHELL", clrs.green },
|
|
|
|
["!"] = { "SHELL", clrs.green },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local shortline = false
|
|
|
|
function M.setup(opts)
|
|
|
|
|
|
|
|
if opts then
|
|
|
|
local function is_enabled(is_shortline, winid, min_width)
|
|
|
|
opts.assets = opts.assets or {}
|
|
|
|
if is_shortline then
|
|
|
|
opts.sett = opts.sett or {}
|
|
|
|
return true
|
|
|
|
opts.mode_colors = opts.mode_colors or {}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
opts = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
assets = vim.tbl_deep_extend("force", assets, opts.assets)
|
|
|
|
winid = winid or 0
|
|
|
|
sett = vim.tbl_deep_extend("force", sett, opts.sett)
|
|
|
|
return vim.api.nvim_win_get_width(winid) > min_width
|
|
|
|
mode_colors = vim.tbl_deep_extend("force", mode_colors, opts.mode_colors)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Initialize the components table
|
|
|
|
function M.get()
|
|
|
|
local components = {
|
|
|
|
local shortline = false
|
|
|
|
active = {},
|
|
|
|
|
|
|
|
inactive = {},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table.insert(components.active, {}) -- (1) left
|
|
|
|
local components = {
|
|
|
|
table.insert(components.active, {}) -- (2) center
|
|
|
|
active = {},
|
|
|
|
table.insert(components.active, {}) -- (3) right
|
|
|
|
inactive = {},
|
|
|
|
|
|
|
|
}
|
|
|
|
-- global components
|
|
|
|
|
|
|
|
local invi_sep = {
|
|
|
|
|
|
|
|
str = " ",
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.bkg,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- helpers
|
|
|
|
local function is_enabled(is_shortline, winid, min_width)
|
|
|
|
local function any_git_changes()
|
|
|
|
if is_shortline then
|
|
|
|
local gst = b.gitsigns_status_dict -- git stats
|
|
|
|
|
|
|
|
if gst then
|
|
|
|
|
|
|
|
if
|
|
|
|
|
|
|
|
gst["added"] and gst["added"] > 0
|
|
|
|
|
|
|
|
or gst["removed"] and gst["removed"] > 0
|
|
|
|
|
|
|
|
or gst["changed"] and gst["changed"] > 0
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- #################### STATUSLINE ->
|
|
|
|
winid = winid or 0
|
|
|
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > min_width
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- ######## Left
|
|
|
|
table.insert(components.active, {}) -- (1) left
|
|
|
|
|
|
|
|
table.insert(components.active, {}) -- (2) center
|
|
|
|
|
|
|
|
table.insert(components.active, {}) -- (3) right
|
|
|
|
|
|
|
|
|
|
|
|
-- Current vi mode ------>
|
|
|
|
-- global components
|
|
|
|
local vi_mode_hl = function()
|
|
|
|
local invi_sep = {
|
|
|
|
return {
|
|
|
|
str = " ",
|
|
|
|
fg = sett.bkg,
|
|
|
|
hl = {
|
|
|
|
bg = mode_colors[vim.fn.mode()][2],
|
|
|
|
fg = sett.bkg,
|
|
|
|
style = { "bold" },
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[1][1] = {
|
|
|
|
-- helpers
|
|
|
|
provider = assets.vertical_bar_chubby,
|
|
|
|
local function any_git_changes()
|
|
|
|
hl = function()
|
|
|
|
local gst = b.gitsigns_status_dict -- git stats
|
|
|
|
return {
|
|
|
|
if gst then
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
if
|
|
|
|
bg = sett.bkg,
|
|
|
|
gst["added"] and gst["added"] > 0
|
|
|
|
}
|
|
|
|
or gst["removed"] and gst["removed"] > 0
|
|
|
|
end,
|
|
|
|
or gst["changed"] and gst["changed"] > 0
|
|
|
|
}
|
|
|
|
then
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- #################### STATUSLINE ->
|
|
|
|
|
|
|
|
|
|
|
|
components.active[1][2] = {
|
|
|
|
-- ######## Left
|
|
|
|
provider = "",
|
|
|
|
|
|
|
|
hl = function()
|
|
|
|
-- Current vi mode ------>
|
|
|
|
|
|
|
|
local vi_mode_hl = function()
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
fg = sett.bkg,
|
|
|
|
fg = sett.text,
|
|
|
|
bg = mode_colors[vim.fn.mode()][2],
|
|
|
|
bg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
|
|
|
style = "bold",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end,
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[1][3] = {
|
|
|
|
components.active[1][1] = {
|
|
|
|
provider = function()
|
|
|
|
provider = assets.vertical_bar_chubby,
|
|
|
|
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
|
|
|
hl = function()
|
|
|
|
end,
|
|
|
|
return {
|
|
|
|
hl = vi_mode_hl,
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
}
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- there is a dilema: we need to hide Diffs if there is no git info. We can do that, but this will
|
|
|
|
components.active[1][2] = {
|
|
|
|
-- leave the right_semicircle colored with purple, and since we can't change the color conditonally
|
|
|
|
provider = "",
|
|
|
|
-- then the solution is to create two right_semicircles: one with a mauve sett.bkg and the other one normal
|
|
|
|
hl = function()
|
|
|
|
-- sett.bkg; both have the same fg (vi mode). The mauve one appears if there is git info, else the one with
|
|
|
|
return {
|
|
|
|
-- the normal sett.bkg appears. Fixed :)
|
|
|
|
fg = sett.text,
|
|
|
|
|
|
|
|
bg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- enable if git diffs are not available
|
|
|
|
components.active[1][3] = {
|
|
|
|
components.active[1][4] = {
|
|
|
|
provider = function()
|
|
|
|
provider = assets.right_semicircle,
|
|
|
|
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
|
|
|
hl = function()
|
|
|
|
end,
|
|
|
|
return {
|
|
|
|
hl = vi_mode_hl,
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
}
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
enabled = function()
|
|
|
|
|
|
|
|
return not any_git_changes()
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- enable if git diffs are available
|
|
|
|
-- there is a dilema: we need to hide Diffs if ther is no git info. We can do that, but this will
|
|
|
|
components.active[1][5] = {
|
|
|
|
-- leave the right_semicircle colored with purple, and since we can't change the color conditonally
|
|
|
|
provider = assets.right_semicircle,
|
|
|
|
-- then the solution is to create two right_semicircles: one with a mauve sett.bkg and the other one normal
|
|
|
|
hl = function()
|
|
|
|
-- sett.bkg; both have the same fg (vi mode). The mauve one appears if there is git info, else the one with
|
|
|
|
return {
|
|
|
|
-- the normal sett.bkg appears. Fixed :)
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
|
|
|
bg = sett.diffs,
|
|
|
|
-- enable if git diffs are not available
|
|
|
|
}
|
|
|
|
components.active[1][4] = {
|
|
|
|
end,
|
|
|
|
provider = assets.right_semicircle,
|
|
|
|
enabled = function()
|
|
|
|
hl = function()
|
|
|
|
return any_git_changes()
|
|
|
|
return {
|
|
|
|
end,
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
}
|
|
|
|
bg = sett.bkg,
|
|
|
|
-- Current vi mode ------>
|
|
|
|
}
|
|
|
|
|
|
|
|
end,
|
|
|
|
-- Diffs ------>
|
|
|
|
enabled = function()
|
|
|
|
components.active[1][6] = {
|
|
|
|
return not any_git_changes()
|
|
|
|
provider = "git_diff_added",
|
|
|
|
end,
|
|
|
|
hl = {
|
|
|
|
}
|
|
|
|
fg = sett.bkg,
|
|
|
|
|
|
|
|
bg = sett.diffs,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[1][7] = {
|
|
|
|
-- enable if git diffs are available
|
|
|
|
provider = "git_diff_changed",
|
|
|
|
components.active[1][5] = {
|
|
|
|
hl = {
|
|
|
|
provider = assets.right_semicircle,
|
|
|
|
fg = sett.bkg,
|
|
|
|
hl = function()
|
|
|
|
bg = sett.diffs,
|
|
|
|
return {
|
|
|
|
},
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
icon = " ",
|
|
|
|
bg = sett.diffs,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
enabled = function()
|
|
|
|
|
|
|
|
return any_git_changes()
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Current vi mode ------>
|
|
|
|
|
|
|
|
|
|
|
|
components.active[1][8] = {
|
|
|
|
-- Diffs ------>
|
|
|
|
provider = "git_diff_removed",
|
|
|
|
components.active[1][6] = {
|
|
|
|
hl = {
|
|
|
|
provider = "git_diff_added",
|
|
|
|
fg = sett.bkg,
|
|
|
|
hl = {
|
|
|
|
bg = sett.diffs,
|
|
|
|
fg = sett.text,
|
|
|
|
},
|
|
|
|
bg = sett.diffs,
|
|
|
|
icon = " ",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
components.active[1][9] = {
|
|
|
|
components.active[1][7] = {
|
|
|
|
provider = assets.right_semicircle,
|
|
|
|
provider = "git_diff_changed",
|
|
|
|
hl = {
|
|
|
|
hl = {
|
|
|
|
fg = sett.diffs,
|
|
|
|
fg = sett.text,
|
|
|
|
bg = sett.bkg,
|
|
|
|
bg = sett.diffs,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
enabled = function()
|
|
|
|
icon = " ",
|
|
|
|
return any_git_changes()
|
|
|
|
}
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Diffs ------>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Extras ------>
|
|
|
|
components.active[1][8] = {
|
|
|
|
|
|
|
|
provider = "git_diff_removed",
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.text,
|
|
|
|
|
|
|
|
bg = sett.diffs,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- file progess
|
|
|
|
components.active[1][9] = {
|
|
|
|
components.active[1][10] = {
|
|
|
|
provider = assets.right_semicircle,
|
|
|
|
provider = function()
|
|
|
|
hl = {
|
|
|
|
local current_line = vim.fn.line(".")
|
|
|
|
fg = sett.diffs,
|
|
|
|
local total_line = vim.fn.line("$")
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
enabled = function()
|
|
|
|
|
|
|
|
return any_git_changes()
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Diffs ------>
|
|
|
|
|
|
|
|
|
|
|
|
if current_line == 1 then
|
|
|
|
-- Extras ------>
|
|
|
|
return " Top "
|
|
|
|
|
|
|
|
elseif current_line == vim.fn.line("$") then
|
|
|
|
|
|
|
|
return " Bot "
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local result, _ = math.modf((current_line / total_line) * 100)
|
|
|
|
|
|
|
|
return " " .. result .. "%% "
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
-- enabled = shortline or function(winid)
|
|
|
|
|
|
|
|
-- return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
|
|
|
|
-- end,
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.extras,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
left_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- position
|
|
|
|
-- file progess
|
|
|
|
components.active[1][11] = {
|
|
|
|
components.active[1][10] = {
|
|
|
|
provider = "position",
|
|
|
|
provider = function()
|
|
|
|
-- enabled = shortline or function(winid)
|
|
|
|
local current_line = vim.fn.line(".")
|
|
|
|
-- return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
local total_line = vim.fn.line("$")
|
|
|
|
-- end,
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.extras,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
left_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Extras ------>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ######## Left
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ######## Center
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Diagnostics ------>
|
|
|
|
|
|
|
|
-- workspace loader
|
|
|
|
|
|
|
|
components.active[2][1] = {
|
|
|
|
|
|
|
|
provider = function()
|
|
|
|
|
|
|
|
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if Lsp then
|
|
|
|
|
|
|
|
local msg = Lsp.message or ""
|
|
|
|
|
|
|
|
local percentage = Lsp.percentage or 0
|
|
|
|
|
|
|
|
local title = Lsp.title or ""
|
|
|
|
|
|
|
|
local spinners = {
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
local success_icon = {
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
local ms = vim.loop.hrtime() / 1000000
|
|
|
|
|
|
|
|
local frame = math.floor(ms / 120) % #spinners
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if percentage >= 70 then
|
|
|
|
if current_line == 1 then
|
|
|
|
return string.format(" %%<%s %s %s (%s%%%%) ", success_icon[frame + 1], title, msg, percentage)
|
|
|
|
return " Top "
|
|
|
|
|
|
|
|
elseif current_line == vim.fn.line("$") then
|
|
|
|
|
|
|
|
return " Bot "
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local result, _ = math.modf((current_line / total_line) * 100)
|
|
|
|
|
|
|
|
return " " .. result .. "%% "
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
-- enabled = shortline or function(winid)
|
|
|
|
|
|
|
|
-- return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
|
|
|
|
-- end,
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.extras,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
left_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage)
|
|
|
|
-- position
|
|
|
|
end
|
|
|
|
components.active[1][11] = {
|
|
|
|
|
|
|
|
provider = "position",
|
|
|
|
return ""
|
|
|
|
-- enabled = shortline or function(winid)
|
|
|
|
end,
|
|
|
|
-- return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
enabled = is_enabled(shortline, winid, 80),
|
|
|
|
-- end,
|
|
|
|
hl = {
|
|
|
|
hl = {
|
|
|
|
fg = clrs.rosewater,
|
|
|
|
fg = sett.extras,
|
|
|
|
bg = sett.bkg,
|
|
|
|
bg = sett.bkg,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
left_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Extras ------>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ######## Left
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ######## Center
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Diagnostics ------>
|
|
|
|
|
|
|
|
-- workspace loader
|
|
|
|
|
|
|
|
components.active[2][1] = {
|
|
|
|
|
|
|
|
provider = function()
|
|
|
|
|
|
|
|
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if Lsp then
|
|
|
|
|
|
|
|
local msg = Lsp.message or ""
|
|
|
|
|
|
|
|
local percentage = Lsp.percentage or 0
|
|
|
|
|
|
|
|
local title = Lsp.title or ""
|
|
|
|
|
|
|
|
local spinners = {
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
local success_icon = {
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
local ms = vim.loop.hrtime() / 1000000
|
|
|
|
|
|
|
|
local frame = math.floor(ms / 120) % #spinners
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if percentage >= 70 then
|
|
|
|
|
|
|
|
return string.format(" %%<%s %s %s (%s%%%%) ", success_icon[frame + 1], title, msg, percentage)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- genral diagnostics (errors, warnings. info and hints)
|
|
|
|
return ""
|
|
|
|
components.active[2][2] = {
|
|
|
|
end,
|
|
|
|
provider = "diagnostic_errors",
|
|
|
|
enabled = is_enabled(shortline, winid, 80),
|
|
|
|
enabled = function()
|
|
|
|
hl = {
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.ERROR)
|
|
|
|
fg = clrs.rosewater,
|
|
|
|
end,
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
hl = {
|
|
|
|
}
|
|
|
|
fg = clrs.red,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[2][3] = {
|
|
|
|
-- genral diagnostics (errors, warnings. info and hints)
|
|
|
|
provider = "diagnostic_warnings",
|
|
|
|
components.active[2][2] = {
|
|
|
|
enabled = function()
|
|
|
|
provider = "diagnostic_errors",
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.WARN)
|
|
|
|
enabled = function()
|
|
|
|
end,
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.ERROR)
|
|
|
|
hl = {
|
|
|
|
end,
|
|
|
|
fg = clrs.yellow,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[2][4] = {
|
|
|
|
hl = {
|
|
|
|
provider = "diagnostic_info",
|
|
|
|
fg = clrs.red,
|
|
|
|
enabled = function()
|
|
|
|
bg = sett.bkg,
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.INFO)
|
|
|
|
},
|
|
|
|
end,
|
|
|
|
icon = " ",
|
|
|
|
hl = {
|
|
|
|
}
|
|
|
|
fg = clrs.sky,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[2][5] = {
|
|
|
|
components.active[2][3] = {
|
|
|
|
provider = "diagnostic_hints",
|
|
|
|
provider = "diagnostic_warnings",
|
|
|
|
enabled = function()
|
|
|
|
enabled = function()
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.HINT)
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.WARN)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
hl = {
|
|
|
|
hl = {
|
|
|
|
fg = clrs.rosewater,
|
|
|
|
fg = clrs.yellow,
|
|
|
|
bg = sett.bkg,
|
|
|
|
bg = sett.bkg,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
icon = " ",
|
|
|
|
icon = " ",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-- Diagnostics ------>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ######## Center
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ######## Right
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[3][1] = {
|
|
|
|
|
|
|
|
provider = "git_branch",
|
|
|
|
|
|
|
|
enabled = is_enabled(shortline, winid, 70),
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.extras,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
left_sep = invi_sep,
|
|
|
|
|
|
|
|
right_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[3][2] = {
|
|
|
|
components.active[2][4] = {
|
|
|
|
provider = function()
|
|
|
|
provider = "diagnostic_info",
|
|
|
|
if next(vim.lsp.buf_get_clients()) ~= nil then
|
|
|
|
enabled = function()
|
|
|
|
return " "
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.INFO)
|
|
|
|
else
|
|
|
|
end,
|
|
|
|
return ""
|
|
|
|
hl = {
|
|
|
|
end
|
|
|
|
fg = clrs.sky,
|
|
|
|
end,
|
|
|
|
bg = sett.bkg,
|
|
|
|
hl = {
|
|
|
|
},
|
|
|
|
fg = sett.extras,
|
|
|
|
icon = " ",
|
|
|
|
bg = sett.bkg,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
right_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[3][3] = {
|
|
|
|
components.active[2][5] = {
|
|
|
|
provider = function()
|
|
|
|
provider = "diagnostic_hints",
|
|
|
|
local filename = vim.fn.expand("%:t")
|
|
|
|
enabled = function()
|
|
|
|
local extension = vim.fn.expand("%:e")
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.HINT)
|
|
|
|
local icon = require("nvim-web-devicons").get_icon(filename, extension)
|
|
|
|
end,
|
|
|
|
if icon == nil then
|
|
|
|
|
|
|
|
icon = " "
|
|
|
|
|
|
|
|
return icon
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return "%m" .. " " .. icon .. " " .. filename .. " "
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
enabled = is_enabled(shortline, winid, 70),
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.bkg,
|
|
|
|
|
|
|
|
bg = sett.curr_file,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
left_sep = {
|
|
|
|
|
|
|
|
str = assets.left_semicircle,
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
hl = {
|
|
|
|
fg = sett.curr_file,
|
|
|
|
fg = clrs.rosewater,
|
|
|
|
bg = sett.bkg,
|
|
|
|
bg = sett.bkg,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
icon = " ",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Diagnostics ------>
|
|
|
|
|
|
|
|
|
|
|
|
components.active[3][4] = {
|
|
|
|
-- ######## Center
|
|
|
|
provider = function()
|
|
|
|
|
|
|
|
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
|
|
|
|
|
|
|
return " " .. dir_name .. " "
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enabled = is_enabled(shortline, winid, 80),
|
|
|
|
-- ######## Right
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[3][1] = {
|
|
|
|
|
|
|
|
provider = "git_branch",
|
|
|
|
|
|
|
|
enabled = is_enabled(shortline, winid, 70),
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.extras,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon = " ",
|
|
|
|
|
|
|
|
left_sep = invi_sep,
|
|
|
|
|
|
|
|
right_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
components.active[3][2] = {
|
|
|
|
fg = sett.bkg,
|
|
|
|
provider = function()
|
|
|
|
bg = sett.curr_dir,
|
|
|
|
if next(vim.lsp.buf_get_clients()) ~= nil then
|
|
|
|
},
|
|
|
|
return " "
|
|
|
|
left_sep = {
|
|
|
|
else
|
|
|
|
str = assets.left_semicircle,
|
|
|
|
return ""
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
hl = {
|
|
|
|
hl = {
|
|
|
|
fg = sett.curr_dir,
|
|
|
|
fg = sett.extras,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
right_sep = invi_sep,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[3][3] = {
|
|
|
|
|
|
|
|
provider = function()
|
|
|
|
|
|
|
|
local filename = vim.fn.expand("%:t")
|
|
|
|
|
|
|
|
local extension = vim.fn.expand("%:e")
|
|
|
|
|
|
|
|
local icon = require("nvim-web-devicons").get_icon(filename, extension)
|
|
|
|
|
|
|
|
if icon == nil then
|
|
|
|
|
|
|
|
icon = " "
|
|
|
|
|
|
|
|
return icon
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return " " .. icon .. " " .. filename .. " "
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
enabled = is_enabled(shortline, winid, 70),
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.text,
|
|
|
|
bg = sett.curr_file,
|
|
|
|
bg = sett.curr_file,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
left_sep = {
|
|
|
|
}
|
|
|
|
str = assets.left_semicircle,
|
|
|
|
-- ######## Right
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.curr_file,
|
|
|
|
|
|
|
|
bg = sett.bkg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components.active[3][4] = {
|
|
|
|
|
|
|
|
provider = function()
|
|
|
|
|
|
|
|
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
|
|
|
|
|
|
|
return " " .. dir_name .. " "
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
enabled = is_enabled(shortline, winid, 80),
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.text,
|
|
|
|
|
|
|
|
bg = sett.curr_dir,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
left_sep = {
|
|
|
|
|
|
|
|
str = assets.left_semicircle,
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
|
|
|
fg = sett.curr_dir,
|
|
|
|
|
|
|
|
bg = sett.curr_file,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-- ######## Right
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return components
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return components
|
|
|
|
return M
|
|
|
|