fix: feline integration

dev
Pocco81 2 years ago
parent 1d1fda12f4
commit f76626386e

@ -1,7 +1,13 @@
local M = {}
local lsp = require("feline.providers.lsp")
local lsp_severity = vim.diagnostic.severity
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 = {
left_semicircle = "",
right_semicircle = "",
@ -26,11 +32,9 @@ local assets = {
slim_dot = "",
}
local clrs = require("catppuccin.palettes.init").get_palette()
-- settings
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,
extras = clrs.overlay1,
curr_file = clrs.maroon,
@ -60,8 +64,27 @@ local mode_colors = {
["!"] = { "SHELL", clrs.green },
}
function M.setup(opts)
if opts then
opts.assets = opts.assets or {}
opts.sett = opts.sett or {}
opts.mode_colors = opts.mode_colors or {}
else
opts = {}
end
assets = vim.tbl_deep_extend("force", assets, opts.assets)
sett = vim.tbl_deep_extend("force", sett, opts.sett)
mode_colors = vim.tbl_deep_extend("force", mode_colors, opts.mode_colors)
end
function M.get()
local shortline = false
local components = {
active = {},
inactive = {},
}
local function is_enabled(is_shortline, winid, min_width)
if is_shortline then
return true
@ -71,12 +94,6 @@ local function is_enabled(is_shortline, winid, min_width)
return vim.api.nvim_win_get_width(winid) > min_width
end
-- Initialize the components table
local components = {
active = {},
inactive = {},
}
table.insert(components.active, {}) -- (1) left
table.insert(components.active, {}) -- (2) center
table.insert(components.active, {}) -- (3) right
@ -112,9 +129,9 @@ end
-- Current vi mode ------>
local vi_mode_hl = function()
return {
fg = sett.bkg,
fg = sett.text,
bg = mode_colors[vim.fn.mode()][2],
style = { "bold" },
style = "bold",
}
end
@ -132,7 +149,7 @@ components.active[1][2] = {
provider = "",
hl = function()
return {
fg = sett.bkg,
fg = sett.text,
bg = mode_colors[vim.fn.mode()][2],
}
end,
@ -145,7 +162,7 @@ components.active[1][3] = {
hl = vi_mode_hl,
}
-- there is a dilema: we need to hide Diffs if there is no git info. We can do that, but this will
-- there is a dilema: we need to hide Diffs if ther is no git info. We can do that, but this will
-- leave the right_semicircle colored with purple, and since we can't change the color conditonally
-- then the solution is to create two right_semicircles: one with a mauve sett.bkg and the other one normal
-- sett.bkg; both have the same fg (vi mode). The mauve one appears if there is git info, else the one with
@ -184,7 +201,7 @@ components.active[1][5] = {
components.active[1][6] = {
provider = "git_diff_added",
hl = {
fg = sett.bkg,
fg = sett.text,
bg = sett.diffs,
},
icon = "",
@ -193,7 +210,7 @@ components.active[1][6] = {
components.active[1][7] = {
provider = "git_diff_changed",
hl = {
fg = sett.bkg,
fg = sett.text,
bg = sett.diffs,
},
icon = "",
@ -202,7 +219,7 @@ components.active[1][7] = {
components.active[1][8] = {
provider = "git_diff_removed",
hl = {
fg = sett.bkg,
fg = sett.text,
bg = sett.diffs,
},
icon = "",
@ -394,11 +411,11 @@ components.active[3][3] = {
icon = ""
return icon
end
return "%m" .. " " .. icon .. " " .. filename .. " "
return " " .. icon .. " " .. filename .. " "
end,
enabled = is_enabled(shortline, winid, 70),
hl = {
fg = sett.bkg,
fg = sett.text,
bg = sett.curr_file,
},
left_sep = {
@ -415,11 +432,9 @@ components.active[3][4] = {
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
return "" .. dir_name .. " "
end,
enabled = is_enabled(shortline, winid, 80),
hl = {
fg = sett.bkg,
fg = sett.text,
bg = sett.curr_dir,
},
left_sep = {
@ -433,3 +448,6 @@ components.active[3][4] = {
-- ######## Right
return components
end
return M

Loading…
Cancel
Save