From f112ac542ef60bfd3f5168559df3229d389a16e5 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 6 Jul 2026 20:48:19 -0500 Subject: [PATCH] refactor: absorb statusline offset into indicator padding Remove the hardcoded statusline_offset from calculate_position() and let padding.y serve as the sole offset from the bottom edge. Bump default padding.y to 3 to preserve the original visual position. --- README.md | 2 +- doc/watchexec.txt | 2 +- lua/watchexec/config.lua | 2 +- lua/watchexec/indicator.lua | 9 ++++----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 02800a5..7b570b9 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ to close it. Press `wxt` to toggle it back. | `failure_hl` | `string` | `"WatchexecFailure"` | Highlight for failure state. | | `width` | `integer` | `2` | Indicator width in cells. | | `height` | `integer` | `1` | Indicator height in cells. | -| `padding` | `table` | `{ x = 1, y = 1 }` | Offset from editor edges. | +| `padding` | `table` | `{ x = 1, y = 3 }` | Offset from editor edges. | | `patterns` | `table` | *(see below)* | Lua patterns for parsing output. | #### `indicator.patterns` diff --git a/doc/watchexec.txt b/doc/watchexec.txt index 2926fc4..ed4ab8f 100644 --- a/doc/watchexec.txt +++ b/doc/watchexec.txt @@ -187,7 +187,7 @@ indicator (table|nil) ~ y (integer|nil) ~ Vertical offset from the top or bottom edge. - Default: 1 + Default: 3 patterns (table|nil) ~ Lua patterns for detecting command lifecycle in output. diff --git a/lua/watchexec/config.lua b/lua/watchexec/config.lua index 6ae1d60..5a973e8 100644 --- a/lua/watchexec/config.lua +++ b/lua/watchexec/config.lua @@ -69,7 +69,7 @@ local defaults = { failure_hl = "WatchexecFailure", width = 2, height = 1, - padding = { x = 1, y = 1 }, + padding = { x = 1, y = 3 }, patterns = { success = "%[Command was successful%]", running = "%[Running", diff --git a/lua/watchexec/indicator.lua b/lua/watchexec/indicator.lua index f1aeca0..7acbf99 100644 --- a/lua/watchexec/indicator.lua +++ b/lua/watchexec/indicator.lua @@ -36,20 +36,19 @@ local function calculate_position() local width = cfg.width or 2 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 + local pad_y = cfg.padding and cfg.padding.y or 3 if cfg.position == "bottom-left" then - return vim.o.lines - height - statusline_offset, pad_x + return vim.o.lines - height - pad_y, pad_x elseif cfg.position == "bottom-right" then - return vim.o.lines - height - statusline_offset, vim.o.columns - width - pad_x + return vim.o.lines - height - pad_y, vim.o.columns - width - pad_x elseif cfg.position == "top-left" then return pad_y, pad_x elseif cfg.position == "top-right" then return pad_y, vim.o.columns - width - pad_x end - return vim.o.lines - height - statusline_offset, pad_x + return vim.o.lines - height - pad_y, pad_x end local function close_float()