From 317eedd9b277b4457fbdfc6314e2cee955531c24 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sat, 2 Oct 2021 10:37:42 +0530 Subject: [PATCH] feat: Make short statusline toggleable from chadrc --- lua/core/default_config.lua | 2 ++ lua/plugins/configs/statusline.lua | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index ef6ee25..681e78b 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -91,6 +91,8 @@ M.plugins = { "NvimTree", "terminal", }, + -- show short statusline on small screens + shortline = true, shown = {}, -- default, round , slant , block , arrow style = "default", diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua index 04fa185..1f7aa44 100644 --- a/lua/plugins/configs/statusline.lua +++ b/lua/plugins/configs/statusline.lua @@ -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,