statusline: Make config overridable
This commit is contained in:
parent
78cf3e97ad
commit
a1e33798b6
@ -4,12 +4,13 @@ if not present then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local colors = require("base46").get_colors "base_30"
|
local options = {
|
||||||
|
colors = require("base46").get_colors "base_30",
|
||||||
|
lsp = require "feline.providers.lsp",
|
||||||
|
lsp_severity = vim.diagnostic.severity,
|
||||||
|
}
|
||||||
|
|
||||||
local lsp = require "feline.providers.lsp"
|
options.icon_styles = {
|
||||||
local lsp_severity = vim.diagnostic.severity
|
|
||||||
|
|
||||||
local icon_styles = {
|
|
||||||
default = {
|
default = {
|
||||||
left = "",
|
left = "",
|
||||||
right = " ",
|
right = " ",
|
||||||
@ -50,32 +51,26 @@ local icon_styles = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local separator = require("core.utils").load_config().plugins.options.statusline.separator_style
|
options.separator_style = options.icon_styles[require("core.utils").load_config().plugins.options.statusline.style]
|
||||||
local separator_style = icon_styles[separator]
|
|
||||||
|
|
||||||
-- Initialize the components table
|
options.main_icon = {
|
||||||
local components = {
|
provider = options.separator_style.main_icon,
|
||||||
active = {},
|
|
||||||
}
|
|
||||||
|
|
||||||
local main_icon = {
|
|
||||||
provider = separator_style.main_icon,
|
|
||||||
|
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.statusline_bg,
|
fg = options.colors.statusline_bg,
|
||||||
bg = colors.nord_blue,
|
bg = options.colors.nord_blue,
|
||||||
},
|
},
|
||||||
|
|
||||||
right_sep = {
|
right_sep = {
|
||||||
str = separator_style.right,
|
str = options.separator_style.right,
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.nord_blue,
|
fg = options.colors.nord_blue,
|
||||||
bg = colors.lightbg,
|
bg = options.colors.lightbg,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local file_name = {
|
options.file_name = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local filename = vim.fn.expand "%:t"
|
local filename = vim.fn.expand "%:t"
|
||||||
local extension = vim.fn.expand "%:e"
|
local extension = vim.fn.expand "%:e"
|
||||||
@ -87,41 +82,41 @@ local file_name = {
|
|||||||
return " " .. icon .. " " .. filename .. " "
|
return " " .. icon .. " " .. filename .. " "
|
||||||
end,
|
end,
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.white,
|
fg = options.colors.white,
|
||||||
bg = colors.lightbg,
|
bg = options.colors.lightbg,
|
||||||
},
|
},
|
||||||
|
|
||||||
right_sep = {
|
right_sep = {
|
||||||
str = separator_style.right,
|
str = options.separator_style.right,
|
||||||
hl = { fg = colors.lightbg, bg = colors.lightbg2 },
|
hl = { fg = options.colors.lightbg, bg = options.colors.lightbg2 },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local dir_name = {
|
options.dir_name = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
||||||
return " " .. dir_name .. " "
|
return " " .. dir_name .. " "
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = options.colors.grey_fg2,
|
||||||
bg = colors.lightbg2,
|
bg = options.colors.lightbg2,
|
||||||
},
|
},
|
||||||
right_sep = {
|
right_sep = {
|
||||||
str = separator_style.right,
|
str = options.separator_style.right,
|
||||||
hi = {
|
hi = {
|
||||||
fg = colors.lightbg2,
|
fg = options.colors.lightbg2,
|
||||||
bg = colors.statusline_bg,
|
bg = options.colors.statusline_bg,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local diff = {
|
options.diff = {
|
||||||
add = {
|
add = {
|
||||||
provider = "git_diff_added",
|
provider = "git_diff_added",
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = options.colors.grey_fg2,
|
||||||
bg = colors.statusline_bg,
|
bg = options.colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
@ -129,8 +124,8 @@ local diff = {
|
|||||||
change = {
|
change = {
|
||||||
provider = "git_diff_changed",
|
provider = "git_diff_changed",
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = options.colors.grey_fg2,
|
||||||
bg = colors.statusline_bg,
|
bg = options.colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
@ -138,62 +133,62 @@ local diff = {
|
|||||||
remove = {
|
remove = {
|
||||||
provider = "git_diff_removed",
|
provider = "git_diff_removed",
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = options.colors.grey_fg2,
|
||||||
bg = colors.statusline_bg,
|
bg = options.colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local git_branch = {
|
options.git_branch = {
|
||||||
provider = "git_branch",
|
provider = "git_branch",
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = options.colors.grey_fg2,
|
||||||
bg = colors.statusline_bg,
|
bg = options.colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
local diagnostic = {
|
options.diagnostic = {
|
||||||
error = {
|
error = {
|
||||||
provider = "diagnostic_errors",
|
provider = "diagnostic_errors",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.ERROR)
|
return options.lsp.diagnostics_exist(options.lsp_severity.ERROR)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hl = { fg = colors.red },
|
hl = { fg = options.colors.red },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
|
|
||||||
warning = {
|
warning = {
|
||||||
provider = "diagnostic_warnings",
|
provider = "diagnostic_warnings",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.WARN)
|
return options.lsp.diagnostics_exist(options.lsp_severity.WARN)
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.yellow },
|
hl = { fg = options.colors.yellow },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
|
|
||||||
hint = {
|
hint = {
|
||||||
provider = "diagnostic_hints",
|
provider = "diagnostic_hints",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.HINT)
|
return options.lsp.diagnostics_exist(options.lsp_severity.HINT)
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.grey_fg2 },
|
hl = { fg = options.colors.grey_fg2 },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
provider = "diagnostic_info",
|
provider = "diagnostic_info",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.INFO)
|
return options.lsp.diagnostics_exist(options.lsp_severity.INFO)
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.green },
|
hl = { fg = options.colors.green },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local lsp_progress = {
|
options.lsp_progress = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
||||||
|
|
||||||
@ -225,10 +220,10 @@ local lsp_progress = {
|
|||||||
|
|
||||||
return ""
|
return ""
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.green },
|
hl = { fg = options.colors.green },
|
||||||
}
|
}
|
||||||
|
|
||||||
local lsp_icon = {
|
options.lsp_icon = {
|
||||||
provider = function()
|
provider = function()
|
||||||
if next(vim.lsp.buf_get_clients()) ~= nil then
|
if next(vim.lsp.buf_get_clients()) ~= nil then
|
||||||
return " LSP"
|
return " LSP"
|
||||||
@ -236,100 +231,100 @@ local lsp_icon = {
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
|
hl = { fg = options.colors.grey_fg2, bg = options.colors.statusline_bg },
|
||||||
}
|
}
|
||||||
|
|
||||||
local mode_colors = {
|
options.mode_colors = {
|
||||||
["n"] = { "NORMAL", colors.red },
|
["n"] = { "NORMAL", options.colors.red },
|
||||||
["no"] = { "N-PENDING", colors.red },
|
["no"] = { "N-PENDING", options.colors.red },
|
||||||
["i"] = { "INSERT", colors.dark_purple },
|
["i"] = { "INSERT", options.colors.dark_purple },
|
||||||
["ic"] = { "INSERT", colors.dark_purple },
|
["ic"] = { "INSERT", options.colors.dark_purple },
|
||||||
["t"] = { "TERMINAL", colors.green },
|
["t"] = { "TERMINAL", options.colors.green },
|
||||||
["v"] = { "VISUAL", colors.cyan },
|
["v"] = { "VISUAL", options.colors.cyan },
|
||||||
["V"] = { "V-LINE", colors.cyan },
|
["V"] = { "V-LINE", options.colors.cyan },
|
||||||
[""] = { "V-BLOCK", colors.cyan },
|
[""] = { "V-BLOCK", options.colors.cyan },
|
||||||
["R"] = { "REPLACE", colors.orange },
|
["R"] = { "REPLACE", options.colors.orange },
|
||||||
["Rv"] = { "V-REPLACE", colors.orange },
|
["Rv"] = { "V-REPLACE", options.colors.orange },
|
||||||
["s"] = { "SELECT", colors.nord_blue },
|
["s"] = { "SELECT", options.colors.nord_blue },
|
||||||
["S"] = { "S-LINE", colors.nord_blue },
|
["S"] = { "S-LINE", options.colors.nord_blue },
|
||||||
[""] = { "S-BLOCK", colors.nord_blue },
|
[""] = { "S-BLOCK", options.colors.nord_blue },
|
||||||
["c"] = { "COMMAND", colors.pink },
|
["c"] = { "COMMAND", options.colors.pink },
|
||||||
["cv"] = { "COMMAND", colors.pink },
|
["cv"] = { "COMMAND", options.colors.pink },
|
||||||
["ce"] = { "COMMAND", colors.pink },
|
["ce"] = { "COMMAND", options.colors.pink },
|
||||||
["r"] = { "PROMPT", colors.teal },
|
["r"] = { "PROMPT", options.colors.teal },
|
||||||
["rm"] = { "MORE", colors.teal },
|
["rm"] = { "MORE", options.colors.teal },
|
||||||
["r?"] = { "CONFIRM", colors.teal },
|
["r?"] = { "CONFIRM", options.colors.teal },
|
||||||
["!"] = { "SHELL", colors.green },
|
["!"] = { "SHELL", options.colors.green },
|
||||||
}
|
}
|
||||||
|
|
||||||
local chad_mode_hl = function()
|
options.chad_mode_hl = function()
|
||||||
return {
|
return {
|
||||||
fg = mode_colors[vim.fn.mode()][2],
|
fg = options.mode_colors[vim.fn.mode()][2],
|
||||||
bg = colors.one_bg,
|
bg = options.colors.one_bg,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local empty_space = {
|
options.empty_space = {
|
||||||
provider = " " .. separator_style.left,
|
provider = " " .. options.separator_style.left,
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.one_bg2,
|
fg = options.colors.one_bg2,
|
||||||
bg = colors.statusline_bg,
|
bg = options.colors.statusline_bg,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- this matches the vi mode color
|
-- this matches the vi mode color
|
||||||
local empty_spaceColored = {
|
options.empty_spaceColored = {
|
||||||
provider = separator_style.left,
|
provider = options.separator_style.left,
|
||||||
hl = function()
|
hl = function()
|
||||||
return {
|
return {
|
||||||
fg = mode_colors[vim.fn.mode()][2],
|
fg = options.mode_colors[vim.fn.mode()][2],
|
||||||
bg = colors.one_bg2,
|
bg = options.colors.one_bg2,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local mode_icon = {
|
options.mode_icon = {
|
||||||
provider = separator_style.vi_mode_icon,
|
provider = options.separator_style.vi_mode_icon,
|
||||||
hl = function()
|
hl = function()
|
||||||
return {
|
return {
|
||||||
fg = colors.statusline_bg,
|
fg = options.colors.statusline_bg,
|
||||||
bg = mode_colors[vim.fn.mode()][2],
|
bg = options.mode_colors[vim.fn.mode()][2],
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local empty_space2 = {
|
options.empty_space2 = {
|
||||||
provider = function()
|
provider = function()
|
||||||
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
return " " .. options.mode_colors[vim.fn.mode()][1] .. " "
|
||||||
end,
|
end,
|
||||||
hl = chad_mode_hl,
|
hl = options.chad_mode_hl,
|
||||||
}
|
}
|
||||||
|
|
||||||
local separator_right = {
|
options.separator_right = {
|
||||||
provider = separator_style.left,
|
provider = options.separator_style.left,
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey,
|
fg = options.colors.grey,
|
||||||
bg = colors.one_bg,
|
bg = options.colors.one_bg,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local separator_right2 = {
|
options.separator_right2 = {
|
||||||
provider = separator_style.left,
|
provider = options.separator_style.left,
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.green,
|
fg = options.colors.green,
|
||||||
bg = colors.grey,
|
bg = options.colors.grey,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local position_icon = {
|
options.position_icon = {
|
||||||
provider = separator_style.position_icon,
|
provider = options.separator_style.position_icon,
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.black,
|
fg = options.colors.black,
|
||||||
bg = colors.green,
|
bg = options.colors.green,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local current_line = {
|
options.current_line = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local current_line = vim.fn.line "."
|
local current_line = vim.fn.line "."
|
||||||
local total_line = vim.fn.line "$"
|
local total_line = vim.fn.line "$"
|
||||||
@ -344,54 +339,63 @@ local current_line = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.green,
|
fg = options.colors.green,
|
||||||
bg = colors.one_bg,
|
bg = options.colors.one_bg,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function add_table(a, b)
|
options = require("core.utils").load_override(options, "feline-nvim/feline.nvim")
|
||||||
table.insert(a, b)
|
|
||||||
|
local function add_table(tbl, inject)
|
||||||
|
if inject then
|
||||||
|
table.insert(tbl, inject)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- components are divided in 3 sections
|
-- components are divided in 3 sections
|
||||||
local left = {}
|
options.left = {}
|
||||||
local middle = {}
|
options.middle = {}
|
||||||
local right = {}
|
options.right = {}
|
||||||
|
|
||||||
-- left
|
-- left
|
||||||
add_table(left, main_icon)
|
add_table(options.left, options.main_icon)
|
||||||
add_table(left, file_name)
|
add_table(options.left, options.file_name)
|
||||||
add_table(left, dir_name)
|
add_table(options.left, options.dir_name)
|
||||||
add_table(left, diff.add)
|
add_table(options.left, options.diff.add)
|
||||||
add_table(left, diff.change)
|
add_table(options.left, options.diff.change)
|
||||||
add_table(left, diff.remove)
|
add_table(options.left, options.diff.remove)
|
||||||
add_table(left, diagnostic.error)
|
add_table(options.left, options.diagnostic.error)
|
||||||
add_table(left, diagnostic.warning)
|
add_table(options.left, options.diagnostic.warning)
|
||||||
add_table(left, diagnostic.hint)
|
add_table(options.left, options.diagnostic.hint)
|
||||||
add_table(left, diagnostic.info)
|
add_table(options.left, options.diagnostic.info)
|
||||||
|
|
||||||
add_table(middle, lsp_progress)
|
add_table(options.middle, options.lsp_progress)
|
||||||
|
|
||||||
-- right
|
-- right
|
||||||
add_table(right, lsp_icon)
|
add_table(options.right, options.lsp_icon)
|
||||||
add_table(right, git_branch)
|
add_table(options.right, options.git_branch)
|
||||||
add_table(right, empty_space)
|
add_table(options.right, options.empty_space)
|
||||||
add_table(right, empty_spaceColored)
|
add_table(options.right, options.empty_spaceColored)
|
||||||
add_table(right, mode_icon)
|
add_table(options.right, options.mode_icon)
|
||||||
add_table(right, empty_space2)
|
add_table(options.right, options.empty_space2)
|
||||||
add_table(right, separator_right)
|
add_table(options.right, options.separator_right)
|
||||||
add_table(right, separator_right2)
|
add_table(options.right, options.separator_right2)
|
||||||
add_table(right, position_icon)
|
add_table(options.right, options.position_icon)
|
||||||
add_table(right, current_line)
|
add_table(options.right, options.current_line)
|
||||||
|
|
||||||
components.active[1] = left
|
-- Initialize the components table
|
||||||
components.active[2] = middle
|
options.components = { active = {} }
|
||||||
components.active[3] = right
|
|
||||||
|
options.components.active[1] = options.left
|
||||||
|
options.components.active[2] = options.middle
|
||||||
|
options.components.active[3] = options.right
|
||||||
|
|
||||||
|
options.theme = {
|
||||||
|
bg = options.colors.statusline_bg,
|
||||||
|
fg = options.colors.fg,
|
||||||
|
}
|
||||||
|
|
||||||
feline.setup {
|
feline.setup {
|
||||||
theme = {
|
theme = options.theme,
|
||||||
bg = colors.statusline_bg,
|
components = options.components,
|
||||||
fg = colors.fg,
|
|
||||||
},
|
|
||||||
components = components,
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user