Skip to content

Commit e51051c

Browse files
authored
feat: add settings for global padding (#28)
* feat: add padding options * fix: handle issue with trailing separator * docs: add padding option
1 parent 328cc37 commit e51051c

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ bar.apply_to_config(
6666
local config = {
6767
position = "bottom",
6868
max_width = 32,
69+
padding = {
70+
left = 1,
71+
right = 1,
72+
},
6973
separator = {
7074
space = 1,
7175
left_icon = wez.nerdfonts.fa_long_arrow_right,

plugin/bar/config.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ local M = {}
66
M.options = {
77
position = "bottom",
88
max_width = 32,
9+
padding = {
10+
left = 1,
11+
right = 1,
12+
},
913
separator = {
1014
space = 1,
1115
left_icon = wez.nerdfonts.fa_long_arrow_right,

plugin/init.lua

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ wez.on("format-tab-title", function(tab, _, _, conf, _, _)
101101
}
102102
end)
103103

104-
-- Name of workspace
105104
wez.on("update-status", function(window, pane)
106105
local present, conf = pcall(window.effective_config, window)
107106
if not present then
@@ -115,8 +114,10 @@ wez.on("update-status", function(window, pane)
115114
{ Background = { Color = palette.tab_bar.background } },
116115
}
117116

117+
table.insert(left_cells, { Text = string.rep(" ", options.padding.left) })
118+
118119
if options.modules.workspace.enabled then
119-
local stat = " " .. options.modules.workspace.icon .. " " .. window:active_workspace() .. " "
120+
local stat = options.modules.workspace.icon .. utilities._space(window:active_workspace(), options.separator.space)
120121
local stat_fg = palette.ansi[options.modules.workspace.color]
121122

122123
if options.modules.leader.enabled and window:leader_is_active() then
@@ -134,7 +135,10 @@ wez.on("update-status", function(window, pane)
134135
goto set_left_status
135136
end
136137
table.insert(left_cells, { Foreground = { Color = palette.ansi[options.modules.pane.color] } })
137-
table.insert(left_cells, { Text = options.modules.pane.icon .. " " .. utilities._basename(process) .. " " })
138+
table.insert(
139+
left_cells,
140+
{ Text = options.modules.pane.icon .. utilities._space(utilities._basename(process), options.separator.space) }
141+
)
138142
end
139143

140144
::set_left_status::
@@ -191,12 +195,15 @@ wez.on("update-status", function(window, pane)
191195
table.insert(right_cells, { Foreground = { Color = palette.brights[1] } })
192196
table.insert(right_cells, {
193197
Text = utilities._space(options.separator.right_icon, options.separator.space, nil)
194-
.. options.modules[name].icon
195-
.. utilities._space(options.separator.field_icon, options.separator.space, nil),
198+
.. options.modules[name].icon,
196199
})
200+
table.insert(right_cells, { Text = utilities._space(options.separator.field_icon, options.separator.space, nil) })
197201
end
198202
::continue::
199203
end
204+
-- remove trailing separator
205+
table.remove(right_cells, #right_cells)
206+
table.insert(right_cells, { Text = string.rep(" ", options.padding.right) })
200207

201208
window:set_right_status(wez.format(right_cells))
202209
end)

0 commit comments

Comments
 (0)