feat: Make short statusline toggleable from chadrc

This commit is contained in:
Akianonymus 2021-10-02 10:37:42 +05:30 committed by siduck76
parent a1c234e001
commit 317eedd9b2
2 changed files with 16 additions and 10 deletions

View File

@ -91,6 +91,8 @@ M.plugins = {
"NvimTree",
"terminal",
},
-- show short statusline on small screens
shortline = true,
shown = {},
-- default, round , slant , block , arrow
style = "default",

View File

@ -42,8 +42,12 @@ local icon_styles = {
},
}
local user_statusline_style = require("core.utils").load_config().plugins.options.statusline.style
local config = require("core.utils").load_config().plugins.options.statusline
-- statusline style
local user_statusline_style = config.style
local statusline_style = icon_styles[user_statusline_style]
-- if show short statusline on small screens
local shortline = config.shortline
-- Initialize the components table
local components = {
@ -81,7 +85,7 @@ components.active[1][2] = {
end
return " " .. icon .. " " .. filename .. " "
end,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 70
end,
hl = {
@ -98,7 +102,7 @@ components.active[1][3] = {
return "" .. dir_name .. " "
end,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 80
end,
@ -209,7 +213,7 @@ components.active[2][1] = {
end
return ""
end,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 80
end,
hl = { fg = colors.green },
@ -223,7 +227,7 @@ components.active[3][1] = {
return ""
end
end,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 70
end,
hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
@ -231,7 +235,7 @@ components.active[3][1] = {
components.active[3][2] = {
provider = "git_branch",
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 70
end,
hl = {
@ -308,7 +312,7 @@ components.active[3][6] = {
components.active[3][7] = {
provider = statusline_style.left,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 90
end,
hl = {
@ -319,7 +323,7 @@ components.active[3][7] = {
components.active[3][8] = {
provider = statusline_style.left,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 90
end,
hl = {
@ -330,7 +334,7 @@ components.active[3][8] = {
components.active[3][9] = {
provider = statusline_style.position_icon,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 90
end,
hl = {
@ -353,7 +357,7 @@ components.active[3][10] = {
return " " .. result .. "%% "
end,
enabled = function(winid)
enabled = shortline and function(winid)
return vim.api.nvim_win_get_width(winid) > 90
end,