Merge pull request #111 from otherJL0/feline

dev
Pocco81 3 years ago committed by GitHub
commit 8a67df6da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ local assets = {
slant_right_2 = "", slant_right_2 = "",
slant_right_2_thin = "", slant_right_2_thin = "",
chubby_dot = "", chubby_dot = "",
slim_dot = '', slim_dot = "",
} }
local clrs = require("catppuccin.core.color_palette") local clrs = require("catppuccin.core.color_palette")
@ -62,6 +62,15 @@ local mode_colors = {
local shortline = false local shortline = false
local function is_enabled(is_shortline, winid, min_width)
if is_shortline then
return true
end
winid = winid or 0
return vim.api.nvim_win_get_width(winid) > min_width
end
-- Initialize the components table -- Initialize the components table
local components = { local components = {
active = {}, active = {},
@ -77,7 +86,7 @@ local invi_sep = {
str = " ", str = " ",
hl = { hl = {
fg = sett.bkg, fg = sett.bkg,
bg = sett.bkg bg = sett.bkg,
}, },
} }
@ -85,17 +94,19 @@ local invi_sep = {
local function any_git_changes() local function any_git_changes()
local gst = b.gitsigns_status_dict -- git stats local gst = b.gitsigns_status_dict -- git stats
if gst then 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 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 end
return false return false
end end
-- #################### STATUSLINE -> -- #################### STATUSLINE ->
-- ######## Left -- ######## Left
-- Current vi mode ------> -- Current vi mode ------>
@ -103,7 +114,7 @@ local vi_mode_hl = function()
return { return {
fg = sett.bkg, fg = sett.bkg,
bg = mode_colors[vim.fn.mode()][2], bg = mode_colors[vim.fn.mode()][2],
style = "bold" style = "bold",
} }
end end
@ -146,12 +157,12 @@ components.active[1][4] = {
hl = function() hl = function()
return { return {
fg = mode_colors[vim.fn.mode()][2], fg = mode_colors[vim.fn.mode()][2],
bg = sett.bkg bg = sett.bkg,
} }
end, end,
enabled = function() enabled = function()
return not any_git_changes() return not any_git_changes()
end end,
} }
-- enable if git diffs are available -- enable if git diffs are available
@ -160,12 +171,12 @@ components.active[1][5] = {
hl = function() hl = function()
return { return {
fg = mode_colors[vim.fn.mode()][2], fg = mode_colors[vim.fn.mode()][2],
bg = sett.diffs bg = sett.diffs,
} }
end, end,
enabled = function() enabled = function()
return any_git_changes() return any_git_changes()
end end,
} }
-- Current vi mode ------> -- Current vi mode ------>
@ -205,7 +216,7 @@ components.active[1][9] = {
}, },
enabled = function() enabled = function()
return any_git_changes() return any_git_changes()
end end,
} }
-- Diffs ------> -- Diffs ------>
@ -230,7 +241,7 @@ components.active[1][10] = {
-- end, -- end,
hl = { hl = {
fg = sett.extras, fg = sett.extras,
bg = sett.bkg bg = sett.bkg,
}, },
left_sep = invi_sep, left_sep = invi_sep,
} }
@ -243,7 +254,7 @@ components.active[1][11] = {
-- end, -- end,
hl = { hl = {
fg = sett.extras, fg = sett.extras,
bg = sett.bkg bg = sett.bkg,
}, },
left_sep = invi_sep, left_sep = invi_sep,
} }
@ -285,12 +296,10 @@ components.active[2][1] = {
return "" return ""
end, end,
enabled = shortline or function(winid) enabled = is_enabled(shortline, winid, 80),
return vim.api.nvim_win_get_width(winid) > 80
end,
hl = { hl = {
fg = clrs.rosewater, fg = clrs.rosewater,
bg = sett.bkg bg = sett.bkg,
}, },
} }
@ -351,12 +360,10 @@ components.active[2][5] = {
components.active[3][1] = { components.active[3][1] = {
provider = "git_branch", provider = "git_branch",
enabled = shortline or function(winid) enabled = is_enabled(shortline, winid, 70),
return vim.api.nvim_win_get_width(winid) > 70
end,
hl = { hl = {
fg = sett.extras, fg = sett.extras,
bg = sett.bkg bg = sett.bkg,
}, },
icon = "", icon = "",
left_sep = invi_sep, left_sep = invi_sep,
@ -373,7 +380,7 @@ components.active[3][2] = {
end, end,
hl = { hl = {
fg = sett.extras, fg = sett.extras,
bg = sett.bkg bg = sett.bkg,
}, },
right_sep = invi_sep, right_sep = invi_sep,
} }
@ -389,9 +396,7 @@ components.active[3][3] = {
end end
return " " .. icon .. " " .. filename .. " " return " " .. icon .. " " .. filename .. " "
end, end,
enabled = shortline or function(winid) enabled = is_enabled(shortline, winid, 70),
return vim.api.nvim_win_get_width(winid) > 70
end,
hl = { hl = {
fg = sett.bkg, fg = sett.bkg,
bg = sett.curr_file, bg = sett.curr_file,
@ -411,9 +416,7 @@ components.active[3][4] = {
return "" .. dir_name .. " " return "" .. dir_name .. " "
end, end,
enabled = shortline or function(winid) enabled = is_enabled(shortline, winid, 80),
return vim.api.nvim_win_get_width(winid) > 80
end,
hl = { hl = {
fg = sett.bkg, fg = sett.bkg,

Loading…
Cancel
Save