Skip to content

Commit

Permalink
feat: add settings for global padding (#28)
Browse files Browse the repository at this point in the history
* feat: add padding options

* fix: handle issue with trailing separator

* docs: add padding option
  • Loading branch information
adriankarlen authored Oct 3, 2024
1 parent 328cc37 commit e51051c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ bar.apply_to_config(
local config = {
position = "bottom",
max_width = 32,
padding = {
left = 1,
right = 1,
},
separator = {
space = 1,
left_icon = wez.nerdfonts.fa_long_arrow_right,
Expand Down
4 changes: 4 additions & 0 deletions plugin/bar/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ local M = {}
M.options = {
position = "bottom",
max_width = 32,
padding = {
left = 1,
right = 1,
},
separator = {
space = 1,
left_icon = wez.nerdfonts.fa_long_arrow_right,
Expand Down
17 changes: 12 additions & 5 deletions plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ wez.on("format-tab-title", function(tab, _, _, conf, _, _)
}
end)

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

table.insert(left_cells, { Text = string.rep(" ", options.padding.left) })

if options.modules.workspace.enabled then
local stat = " " .. options.modules.workspace.icon .. " " .. window:active_workspace() .. " "
local stat = options.modules.workspace.icon .. utilities._space(window:active_workspace(), options.separator.space)
local stat_fg = palette.ansi[options.modules.workspace.color]

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

::set_left_status::
Expand Down Expand Up @@ -191,12 +195,15 @@ wez.on("update-status", function(window, pane)
table.insert(right_cells, { Foreground = { Color = palette.brights[1] } })
table.insert(right_cells, {
Text = utilities._space(options.separator.right_icon, options.separator.space, nil)
.. options.modules[name].icon
.. utilities._space(options.separator.field_icon, options.separator.space, nil),
.. options.modules[name].icon,
})
table.insert(right_cells, { Text = utilities._space(options.separator.field_icon, options.separator.space, nil) })
end
::continue::
end
-- remove trailing separator
table.remove(right_cells, #right_cells)
table.insert(right_cells, { Text = string.rep(" ", options.padding.right) })

window:set_right_status(wez.format(right_cells))
end)
Expand Down

0 comments on commit e51051c

Please sign in to comment.