feat: add configurable indicator padding
Add indicator.padding (x, y) to offset the status indicator from the editor edges. Defaults to 1 cell on each axis, moving the indicator away from the right edge and bottom of the buffer.
This commit is contained in:
@@ -16,6 +16,10 @@
|
|||||||
---@field bin? string
|
---@field bin? string
|
||||||
---@field args? string[]
|
---@field args? string[]
|
||||||
|
|
||||||
|
---@class watchexec.IndicatorPadding
|
||||||
|
---@field x? integer
|
||||||
|
---@field y? integer
|
||||||
|
|
||||||
---@class watchexec.IndicatorPatterns
|
---@class watchexec.IndicatorPatterns
|
||||||
---@field success? string
|
---@field success? string
|
||||||
---@field running? string
|
---@field running? string
|
||||||
@@ -27,6 +31,7 @@
|
|||||||
---@field failure_hl? string
|
---@field failure_hl? string
|
||||||
---@field width? integer
|
---@field width? integer
|
||||||
---@field height? integer
|
---@field height? integer
|
||||||
|
---@field padding? watchexec.IndicatorPadding
|
||||||
---@field patterns? watchexec.IndicatorPatterns
|
---@field patterns? watchexec.IndicatorPatterns
|
||||||
|
|
||||||
---@class watchexec.Config
|
---@class watchexec.Config
|
||||||
@@ -64,6 +69,7 @@ local defaults = {
|
|||||||
failure_hl = "WatchexecFailure",
|
failure_hl = "WatchexecFailure",
|
||||||
width = 2,
|
width = 2,
|
||||||
height = 1,
|
height = 1,
|
||||||
|
padding = { x = 1, y = 1 },
|
||||||
patterns = {
|
patterns = {
|
||||||
success = "%[Command was successful%]",
|
success = "%[Command was successful%]",
|
||||||
running = "%[Running",
|
running = "%[Running",
|
||||||
|
|||||||
@@ -35,18 +35,21 @@ local function calculate_position()
|
|||||||
local cfg = config.get().indicator
|
local cfg = config.get().indicator
|
||||||
local width = cfg.width or 2
|
local width = cfg.width or 2
|
||||||
local height = cfg.height or 1
|
local height = cfg.height or 1
|
||||||
|
local pad_x = cfg.padding and cfg.padding.x or 1
|
||||||
|
local pad_y = cfg.padding and cfg.padding.y or 1
|
||||||
|
local statusline_offset = 2
|
||||||
|
|
||||||
if cfg.position == "bottom-left" then
|
if cfg.position == "bottom-left" then
|
||||||
return vim.o.lines - height - 3, 0
|
return vim.o.lines - height - statusline_offset, pad_x
|
||||||
elseif cfg.position == "bottom-right" then
|
elseif cfg.position == "bottom-right" then
|
||||||
return vim.o.lines - height - 3, vim.o.columns - width
|
return vim.o.lines - height - statusline_offset, vim.o.columns - width - pad_x
|
||||||
elseif cfg.position == "top-left" then
|
elseif cfg.position == "top-left" then
|
||||||
return 0, 0
|
return pad_y, pad_x
|
||||||
elseif cfg.position == "top-right" then
|
elseif cfg.position == "top-right" then
|
||||||
return 0, vim.o.columns - width
|
return pad_y, vim.o.columns - width - pad_x
|
||||||
end
|
end
|
||||||
|
|
||||||
return vim.o.lines - height - 3, 0
|
return vim.o.lines - height - statusline_offset, pad_x
|
||||||
end
|
end
|
||||||
|
|
||||||
local function close_float()
|
local function close_float()
|
||||||
|
|||||||
Reference in New Issue
Block a user