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-07 05:24:35 -04:00
|
|
|
|
local options = {
|
|
|
|
|
colors = require("base46").get_colors "base_30",
|
|
|
|
|
lsp = require "feline.providers.lsp",
|
|
|
|
|
lsp_severity = vim.diagnostic.severity,
|
|
|
|
|
}
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.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-05-10 09:43:48 -04:00
|
|
|
|
options.separator_style = options.icon_styles[nvchad.load_config().plugins.options.statusline.separator_style]
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.main_icon = {
|
|
|
|
|
provider = options.separator_style.main_icon,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "FelineIcon",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
|
2022-01-21 06:49:49 -05:00
|
|
|
|
right_sep = {
|
2022-05-07 05:24:35 -04:00
|
|
|
|
str = options.separator_style.right,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "FelineIconSeparator",
|
2022-01-21 06:49:49 -05:00
|
|
|
|
},
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.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,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
|
|
|
|
|
hl = "FelineFileName",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
|
2022-01-21 06:49:49 -05:00
|
|
|
|
right_sep = {
|
2022-05-07 05:24:35 -04:00
|
|
|
|
str = options.separator_style.right,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "FelineFileName_Separator",
|
2022-01-21 06:49:49 -05:00
|
|
|
|
},
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.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,
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "FelineDirName",
|
|
|
|
|
|
2022-01-11 01:12:02 -05:00
|
|
|
|
right_sep = {
|
2022-05-07 05:24:35 -04:00
|
|
|
|
str = options.separator_style.right,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hi = "FelineDirName_Separator",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
-- Git
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.diff = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
add = {
|
|
|
|
|
provider = "git_diff_added",
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_diffIcons",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
change = {
|
|
|
|
|
provider = "git_diff_changed",
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_diffIcons",
|
|
|
|
|
|
2022-01-21 23:49:32 -05:00
|
|
|
|
icon = " ",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
remove = {
|
|
|
|
|
provider = "git_diff_removed",
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_diffIcons",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.git_branch = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = "git_branch",
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_diffIcons",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
-- lsp
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.diagnostic = {
|
2022-01-26 09:47:44 -05:00
|
|
|
|
error = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = "diagnostic_errors",
|
|
|
|
|
enabled = function()
|
2022-05-07 05:24:35 -04:00
|
|
|
|
return options.lsp.diagnostics_exist(options.lsp_severity.ERROR)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_lspError",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
warning = {
|
|
|
|
|
provider = "diagnostic_warnings",
|
|
|
|
|
enabled = function()
|
2022-05-07 05:24:35 -04:00
|
|
|
|
return options.lsp.diagnostics_exist(options.lsp_severity.WARN)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
|
|
|
|
|
hl = "Feline_lspWarning",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
hint = {
|
|
|
|
|
provider = "diagnostic_hints",
|
|
|
|
|
enabled = function()
|
2022-05-07 05:24:35 -04:00
|
|
|
|
return options.lsp.diagnostics_exist(options.lsp_severity.HINT)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_LspHints",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
info = {
|
|
|
|
|
provider = "diagnostic_info",
|
|
|
|
|
enabled = function()
|
2022-05-07 05:24:35 -04:00
|
|
|
|
return options.lsp.diagnostics_exist(options.lsp_severity.INFO)
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_LspInfo",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
icon = " ",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
options.lsp_icon = {
|
|
|
|
|
provider = function()
|
|
|
|
|
if next(vim.lsp.buf_get_clients()) ~= nil then
|
|
|
|
|
local lsp_name = vim.lsp.get_active_clients()[1].name
|
|
|
|
|
|
|
|
|
|
return " LSP ~ " .. lsp_name .. " "
|
|
|
|
|
else
|
|
|
|
|
return ""
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
hl = "Feline_LspIcon",
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.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 ""
|
2022-05-20 13:43:18 -04:00
|
|
|
|
local spinners = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }
|
2022-01-11 01:12:02 -05:00
|
|
|
|
|
|
|
|
|
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-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_LspProgress",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
-- MODES
|
2022-01-11 01:12:02 -05:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.mode_colors = {
|
2022-05-20 13:43:18 -04:00
|
|
|
|
["n"] = { "NORMAL", "Feline_NormalMode" },
|
|
|
|
|
["no"] = { "N-PENDING", "Feline_NormalMode" },
|
|
|
|
|
["i"] = { "INSERT", "Feline_InsertMode" },
|
|
|
|
|
["ic"] = { "INSERT", "Feline_InsertMode" },
|
|
|
|
|
["t"] = { "TERMINAL", "Feline_TerminalMode" },
|
|
|
|
|
["v"] = { "VISUAL", "Feline_VisualMode" },
|
|
|
|
|
["V"] = { "V-LINE", "Feline_VisualMode" },
|
|
|
|
|
[""] = { "V-BLOCK", "Feline_VisualMode" },
|
|
|
|
|
["R"] = { "REPLACE", "Feline_ReplaceMode" },
|
|
|
|
|
["Rv"] = { "V-REPLACE", "Feline_ReplaceMode" },
|
|
|
|
|
["s"] = { "SELECT", "Feline_SelectMode" },
|
|
|
|
|
["S"] = { "S-LINE", "Feline_SelectMode" },
|
|
|
|
|
[""] = { "S-BLOCK", "Feline_SelectMode" },
|
|
|
|
|
["c"] = { "COMMAND", "Feline_CommandMode" },
|
|
|
|
|
["cv"] = { "COMMAND", "Feline_CommandMode" },
|
|
|
|
|
["ce"] = { "COMMAND", "Feline_CommandMode" },
|
|
|
|
|
["r"] = { "PROMPT", "Feline_ConfirmMode" },
|
|
|
|
|
["rm"] = { "MORE", "Feline_ConfirmMode" },
|
|
|
|
|
["r?"] = { "CONFIRM", "Feline_ConfirmMode" },
|
|
|
|
|
["!"] = { "SHELL", "Feline_TerminalMode" },
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
local fn = vim.fn
|
|
|
|
|
|
|
|
|
|
local function get_color(group, attr)
|
|
|
|
|
return fn.synIDattr(fn.synIDtrans(fn.hlID(group)), attr)
|
2022-01-10 23:39:37 -05:00
|
|
|
|
end
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.empty_space = {
|
|
|
|
|
provider = " " .. options.separator_style.left,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_EmptySpace",
|
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-05-07 05:24:35 -04:00
|
|
|
|
options.empty_spaceColored = {
|
|
|
|
|
provider = options.separator_style.left,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
hl = function()
|
|
|
|
|
return {
|
2022-05-20 13:43:18 -04:00
|
|
|
|
fg = get_color(options.mode_colors[vim.fn.mode()][2], "fg#"),
|
|
|
|
|
bg = get_color("Feline_EmptySpace", "fg#"),
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.mode_icon = {
|
|
|
|
|
provider = options.separator_style.vi_mode_icon,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
|
|
|
|
|
hl = {
|
2022-05-20 20:40:34 -04:00
|
|
|
|
fg = get_color("Feline", "bg#"),
|
2022-05-20 13:43:18 -04:00
|
|
|
|
bg = get_color(options.mode_colors[vim.fn.mode()][2], "fg#"),
|
|
|
|
|
},
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.empty_space2 = {
|
2022-01-11 01:12:02 -05:00
|
|
|
|
provider = function()
|
2022-05-07 05:24:35 -04:00
|
|
|
|
return " " .. options.mode_colors[vim.fn.mode()][1] .. " "
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = function()
|
|
|
|
|
return options.mode_colors[vim.fn.mode()][2]
|
|
|
|
|
end,
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
2021-08-14 13:05:10 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.separator_right = {
|
|
|
|
|
provider = options.separator_style.left,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_EmptySpace",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
2021-08-13 02:42:43 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.separator_right2 = {
|
|
|
|
|
provider = options.separator_style.left,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_PositionSeparator",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
2021-08-19 08:05:24 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.position_icon = {
|
|
|
|
|
provider = options.separator_style.position_icon,
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_PositionIcon",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
2021-08-13 02:42:43 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.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,
|
|
|
|
|
|
2022-05-20 13:43:18 -04:00
|
|
|
|
hl = "Feline_CurrentLine",
|
2022-01-11 01:12:02 -05:00
|
|
|
|
}
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-05-10 09:43:48 -04:00
|
|
|
|
options = nvchad.load_override(options, "feline-nvim/feline.nvim")
|
2022-05-07 05:24:35 -04:00
|
|
|
|
|
|
|
|
|
local function add_table(tbl, inject)
|
|
|
|
|
if inject then
|
|
|
|
|
table.insert(tbl, inject)
|
|
|
|
|
end
|
2022-01-11 01:12:02 -05:00
|
|
|
|
end
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
2022-04-27 11:42:28 -04:00
|
|
|
|
-- components are divided in 3 sections
|
2022-05-07 05:24:35 -04:00
|
|
|
|
options.left = {}
|
|
|
|
|
options.middle = {}
|
|
|
|
|
options.right = {}
|
2022-04-27 11:42:28 -04:00
|
|
|
|
|
|
|
|
|
-- left
|
2022-05-07 05:24:35 -04:00
|
|
|
|
add_table(options.left, options.main_icon)
|
|
|
|
|
add_table(options.left, options.file_name)
|
|
|
|
|
add_table(options.left, options.dir_name)
|
2022-05-20 13:43:18 -04:00
|
|
|
|
|
|
|
|
|
-- lsp
|
|
|
|
|
add_table(options.left, options.lsp_icon)
|
2022-05-07 05:24:35 -04:00
|
|
|
|
add_table(options.left, options.diagnostic.error)
|
|
|
|
|
add_table(options.left, options.diagnostic.warning)
|
|
|
|
|
add_table(options.left, options.diagnostic.hint)
|
|
|
|
|
add_table(options.left, options.diagnostic.info)
|
|
|
|
|
|
|
|
|
|
add_table(options.middle, options.lsp_progress)
|
2022-04-27 11:42:28 -04:00
|
|
|
|
|
|
|
|
|
-- right
|
2022-05-20 13:43:18 -04:00
|
|
|
|
|
|
|
|
|
-- git diffs
|
|
|
|
|
add_table(options.right, options.diff.add)
|
|
|
|
|
add_table(options.right, options.diff.change)
|
|
|
|
|
add_table(options.right, options.diff.remove)
|
2022-05-07 05:24:35 -04:00
|
|
|
|
add_table(options.right, options.git_branch)
|
2022-05-20 13:43:18 -04:00
|
|
|
|
|
2022-05-07 05:24:35 -04:00
|
|
|
|
add_table(options.right, options.empty_space)
|
|
|
|
|
add_table(options.right, options.empty_spaceColored)
|
|
|
|
|
add_table(options.right, options.mode_icon)
|
|
|
|
|
add_table(options.right, options.empty_space2)
|
|
|
|
|
add_table(options.right, options.separator_right)
|
|
|
|
|
add_table(options.right, options.separator_right2)
|
|
|
|
|
add_table(options.right, options.position_icon)
|
|
|
|
|
add_table(options.right, options.current_line)
|
|
|
|
|
|
|
|
|
|
-- Initialize the components table
|
|
|
|
|
options.components = { active = {} }
|
|
|
|
|
|
|
|
|
|
options.components.active[1] = options.left
|
|
|
|
|
options.components.active[2] = options.middle
|
|
|
|
|
options.components.active[3] = options.right
|
|
|
|
|
|
|
|
|
|
options.theme = {
|
2022-05-20 13:43:18 -04:00
|
|
|
|
fg = get_color("Feline", "fg#"),
|
|
|
|
|
bg = get_color("Feline", "bg#"),
|
2022-05-07 05:24:35 -04:00
|
|
|
|
}
|
2022-04-27 11:42:28 -04:00
|
|
|
|
|
|
|
|
|
feline.setup {
|
2022-05-07 05:24:35 -04:00
|
|
|
|
theme = options.theme,
|
|
|
|
|
components = options.components,
|
2022-04-27 11:42:28 -04:00
|
|
|
|
}
|