2022-01-21 06:49:49 -05:00
|
|
|
|
local present, feline = pcall(require, "feline")
|
2022-04-27 11:42:28 -04:00
|
|
|
|
|
2022-01-21 06:49:49 -05:00
|
|
|
|
if not present then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2022-05-06 10:44:57 -04:00
|
|
|
|
local colors = require("base46").get_colors "base_30"
|
2022-05-02 14:43:38 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local lsp = require "feline.providers.lsp"
|
|
|
|
|
local lsp_severity = vim.diagnostic.severity
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local icon_styles = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
default = {
|
|
|
|
|
left = "",
|
|
|
|
|
right = " ",
|
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
|
|
|
|
arrow = {
|
|
|
|
|
left = "",
|
|
|
|
|
right = "",
|
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
block = {
|
|
|
|
|
left = " ",
|
|
|
|
|
right = " ",
|
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
round = {
|
|
|
|
|
left = "",
|
|
|
|
|
right = "",
|
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
slant = {
|
|
|
|
|
left = " ",
|
|
|
|
|
right = " ",
|
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
2021-08-19 02:29:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-29 18:27:12 -04:00
|
|
|
|
local separator = require("core.utils").load_config().plugins.options.statusline.separator_style
|
|
|
|
|
local separator_style = icon_styles[separator]
|
2021-08-19 02:29:42 -04:00
|
|
|
|
|
2021-08-26 01:18:13 -04:00
|
|
|
|
-- Initialize the components table
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local components = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
active = {},
|
2021-07-15 11:43:17 -04:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local main_icon = {
|
|
|
|
|
provider = separator_style.main_icon,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.statusline_bg,
|
|
|
|
|
bg = colors.nord_blue,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
|
2022-01-21 06:49:49 -05:00
|
|
|
|
right_sep = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
str = separator_style.right,
|
2022-01-21 06:49:49 -05:00
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.nord_blue,
|
|
|
|
|
bg = colors.lightbg,
|
2022-01-21 06:49:49 -05:00
|
|
|
|
},
|
|
|
|
|
},
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local file_name = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
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,
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.white,
|
|
|
|
|
bg = colors.lightbg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
|
2022-01-21 06:49:49 -05:00
|
|
|
|
right_sep = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
str = separator_style.right,
|
|
|
|
|
hl = { fg = colors.lightbg, bg = colors.lightbg2 },
|
2022-01-21 06:49:49 -05:00
|
|
|
|
},
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local dir_name = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = function()
|
|
|
|
|
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
|
|
|
|
return " " .. dir_name .. " "
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.lightbg2,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
right_sep = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
str = separator_style.right,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hi = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.lightbg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local diff = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
add = {
|
|
|
|
|
provider = "git_diff_added",
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
change = {
|
|
|
|
|
provider = "git_diff_changed",
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
2022-01-21 23:49:32 -05:00
|
|
|
|
icon = " ",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
remove = {
|
|
|
|
|
provider = "git_diff_removed",
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local git_branch = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = "git_branch",
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
icon = " ",
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local diagnostic = {
|
2022-01-26 09:47:44 -05:00
|
|
|
|
error = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = "diagnostic_errors",
|
|
|
|
|
enabled = function()
|
2022-04-27 11:42:28 -04:00
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.ERROR)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
hl = { fg = colors.red },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
warning = {
|
|
|
|
|
provider = "diagnostic_warnings",
|
|
|
|
|
enabled = function()
|
2022-04-27 11:42:28 -04:00
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.WARN)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-04-27 11:42:28 -04:00
|
|
|
|
hl = { fg = colors.yellow },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
hint = {
|
|
|
|
|
provider = "diagnostic_hints",
|
|
|
|
|
enabled = function()
|
2022-04-27 11:42:28 -04:00
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.HINT)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-04-27 11:42:28 -04:00
|
|
|
|
hl = { fg = colors.grey_fg2 },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
info = {
|
|
|
|
|
provider = "diagnostic_info",
|
|
|
|
|
enabled = function()
|
2022-04-27 11:42:28 -04:00
|
|
|
|
return lsp.diagnostics_exist(lsp_severity.INFO)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-04-27 11:42:28 -04:00
|
|
|
|
hl = { fg = colors.green },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local lsp_progress = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
end,
|
2022-04-27 11:42:28 -04:00
|
|
|
|
hl = { fg = colors.green },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local lsp_icon = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = function()
|
|
|
|
|
if next(vim.lsp.buf_get_clients()) ~= nil then
|
|
|
|
|
return " LSP"
|
|
|
|
|
else
|
|
|
|
|
return ""
|
|
|
|
|
end
|
|
|
|
|
end,
|
2022-04-27 11:42:28 -04:00
|
|
|
|
hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local mode_colors = {
|
|
|
|
|
["n"] = { "NORMAL", colors.red },
|
|
|
|
|
["no"] = { "N-PENDING", colors.red },
|
|
|
|
|
["i"] = { "INSERT", colors.dark_purple },
|
|
|
|
|
["ic"] = { "INSERT", colors.dark_purple },
|
|
|
|
|
["t"] = { "TERMINAL", colors.green },
|
|
|
|
|
["v"] = { "VISUAL", colors.cyan },
|
|
|
|
|
["V"] = { "V-LINE", colors.cyan },
|
|
|
|
|
[""] = { "V-BLOCK", colors.cyan },
|
|
|
|
|
["R"] = { "REPLACE", colors.orange },
|
|
|
|
|
["Rv"] = { "V-REPLACE", colors.orange },
|
|
|
|
|
["s"] = { "SELECT", colors.nord_blue },
|
|
|
|
|
["S"] = { "S-LINE", colors.nord_blue },
|
|
|
|
|
[""] = { "S-BLOCK", colors.nord_blue },
|
|
|
|
|
["c"] = { "COMMAND", colors.pink },
|
|
|
|
|
["cv"] = { "COMMAND", colors.pink },
|
|
|
|
|
["ce"] = { "COMMAND", colors.pink },
|
|
|
|
|
["r"] = { "PROMPT", colors.teal },
|
|
|
|
|
["rm"] = { "MORE", colors.teal },
|
|
|
|
|
["r?"] = { "CONFIRM", colors.teal },
|
|
|
|
|
["!"] = { "SHELL", colors.green },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local chad_mode_hl = function()
|
2022-01-11 01:12:02 -05:00
|
|
|
|
return {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
bg = colors.one_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
2022-01-10 23:39:37 -05:00
|
|
|
|
end
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local empty_space = {
|
|
|
|
|
provider = " " .. separator_style.left,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.one_bg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
}
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-01-11 01:12:02 -05:00
|
|
|
|
-- this matches the vi mode color
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local empty_spaceColored = {
|
|
|
|
|
provider = separator_style.left,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hl = function()
|
|
|
|
|
return {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
bg = colors.one_bg2,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local mode_icon = {
|
|
|
|
|
provider = separator_style.vi_mode_icon,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hl = function()
|
|
|
|
|
return {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.statusline_bg,
|
|
|
|
|
bg = mode_colors[vim.fn.mode()][2],
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local empty_space2 = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = function()
|
2022-04-27 11:42:28 -04:00
|
|
|
|
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-04-27 11:42:28 -04:00
|
|
|
|
hl = chad_mode_hl,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
2021-08-14 13:05:10 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local separator_right = {
|
|
|
|
|
provider = separator_style.left,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.grey,
|
|
|
|
|
bg = colors.one_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
}
|
2021-08-13 02:42:43 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local separator_right2 = {
|
|
|
|
|
provider = separator_style.left,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.green,
|
|
|
|
|
bg = colors.grey,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
}
|
2021-08-19 08:05:24 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local position_icon = {
|
|
|
|
|
provider = separator_style.position_icon,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.black,
|
|
|
|
|
bg = colors.green,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
}
|
2021-08-13 02:42:43 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
local current_line = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = function()
|
|
|
|
|
local current_line = vim.fn.line "."
|
|
|
|
|
local total_line = vim.fn.line "$"
|
|
|
|
|
|
|
|
|
|
if current_line == 1 then
|
|
|
|
|
return " Top "
|
|
|
|
|
elseif current_line == vim.fn.line "$" then
|
|
|
|
|
return " Bot "
|
|
|
|
|
end
|
|
|
|
|
local result, _ = math.modf((current_line / total_line) * 100)
|
|
|
|
|
return " " .. result .. "%% "
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
hl = {
|
2022-04-27 11:42:28 -04:00
|
|
|
|
fg = colors.green,
|
|
|
|
|
bg = colors.one_bg,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
}
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-01-11 01:12:02 -05:00
|
|
|
|
local function add_table(a, b)
|
|
|
|
|
table.insert(a, b)
|
|
|
|
|
end
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
-- components are divided in 3 sections
|
|
|
|
|
local left = {}
|
|
|
|
|
local middle = {}
|
|
|
|
|
local right = {}
|
|
|
|
|
|
|
|
|
|
-- left
|
|
|
|
|
add_table(left, main_icon)
|
|
|
|
|
add_table(left, file_name)
|
|
|
|
|
add_table(left, dir_name)
|
|
|
|
|
add_table(left, diff.add)
|
|
|
|
|
add_table(left, diff.change)
|
|
|
|
|
add_table(left, diff.remove)
|
|
|
|
|
add_table(left, diagnostic.error)
|
|
|
|
|
add_table(left, diagnostic.warning)
|
|
|
|
|
add_table(left, diagnostic.hint)
|
|
|
|
|
add_table(left, diagnostic.info)
|
|
|
|
|
|
|
|
|
|
add_table(middle, lsp_progress)
|
|
|
|
|
|
|
|
|
|
-- right
|
|
|
|
|
add_table(right, lsp_icon)
|
|
|
|
|
add_table(right, git_branch)
|
|
|
|
|
add_table(right, empty_space)
|
|
|
|
|
add_table(right, empty_spaceColored)
|
|
|
|
|
add_table(right, mode_icon)
|
|
|
|
|
add_table(right, empty_space2)
|
|
|
|
|
add_table(right, separator_right)
|
|
|
|
|
add_table(right, separator_right2)
|
|
|
|
|
add_table(right, position_icon)
|
|
|
|
|
add_table(right, current_line)
|
|
|
|
|
|
|
|
|
|
components.active[1] = left
|
|
|
|
|
components.active[2] = middle
|
|
|
|
|
components.active[3] = right
|
|
|
|
|
|
|
|
|
|
feline.setup {
|
|
|
|
|
theme = {
|
|
|
|
|
bg = colors.statusline_bg,
|
|
|
|
|
fg = colors.fg,
|
|
|
|
|
},
|
|
|
|
|
components = components,
|
|
|
|
|
}
|