From fb620cddf81213c77a00ab2f4df238b0ea6fb709 Mon Sep 17 00:00:00 2001 From: alexekdahl Date: Sat, 8 Nov 2025 21:30:17 +0100 Subject: [PATCH 1/3] feat(ui): add configurable window position (top_center, center, bottom_center) Adds `ui.position` option to control where the marks window appears. Defaults to 'center'. Supported values: - top_center: positions the window near the top, centered horizontally - bottom_center: positions it near the bottom - center: keeps the existing centered behavior --- lua/marksman/init.lua | 11 +++++++++++ lua/marksman/ui.lua | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/lua/marksman/init.lua b/lua/marksman/init.lua index 81c03b7..cf63cbd 100644 --- a/lua/marksman/init.lua +++ b/lua/marksman/init.lua @@ -36,9 +36,19 @@ local default_config = { max_marks = 100, search_in_ui = true, silent = false, + -- minimal should be configured via ui opts minimal = false, disable_default_keymaps = false, debounce_ms = 500, -- Debounce save operations + -- UI specific settings + ui = { + -- Position of the marks window. + -- "center" positions the window in the middle of the editor (default). + -- "top_center" aligns the window at the top of the screen, centered horizontally. + -- "bottom_center" aligns the window at the bottom of the screen, centered horizontally. + minimal = false, + position = "center", + }, } -- Configuration validation schema @@ -732,3 +742,4 @@ function M.setup(opts) end return M + diff --git a/lua/marksman/ui.lua b/lua/marksman/ui.lua index 1931d7e..04edb8e 100644 --- a/lua/marksman/ui.lua +++ b/lua/marksman/ui.lua @@ -624,8 +624,43 @@ function M.show_marks_window(marks, project_name, search_query) pcall(vim.api.nvim_buf_add_highlight, buf, -1, hl.hl_group, hl.line, hl.col, hl.end_col) end - -- Calculate window position (centered) - local row = math.floor((vim.o.lines - WINDOW_HEIGHT) / 2) + -- Calculate window position based on user configuration. By default the + -- marks window is centered in the editor, but users can override + -- this by specifying ui.position in their plugin configuration. A + -- value of "top_center" positions the window near the top of the + -- screen, while "bottom_center" aligns it near the bottom. Any + -- unrecognised value falls back to the centered position. We also + -- clamp the row so the window never renders outside the visible + -- editor lines. Note: vim.o.lines returns the total number of + -- lines in the UI (not just the buffer), so subtracting the window + -- height ensures the window is fully on screen. + local pos = nil + if config and type(config.ui) == "table" then + pos = config.ui.position + end + local row + if pos == "top_center" then + -- Place the window a couple of lines down to avoid + -- overlapping the very top of the UI. A value of 1 gives + -- a small margin but still keeps the window anchored near + -- the top. + row = 1 + elseif pos == "bottom_center" then + -- Place the window a couple of lines above the bottom to + -- leave room for command line and status line. We subtract + -- 2 to account for the border and padding. + row = vim.o.lines - WINDOW_HEIGHT - 2 + else + -- Default to center positioning + row = math.floor((vim.o.lines - WINDOW_HEIGHT) / 2) + end + -- Ensure row stays within valid bounds + if row < 0 then + row = 0 + elseif row > vim.o.lines - WINDOW_HEIGHT then + row = math.max(vim.o.lines - WINDOW_HEIGHT, 0) + end + -- Always center horizontally local col = math.floor((vim.o.columns - WINDOW_WIDTH) / 2) -- Window title @@ -701,3 +736,4 @@ function M.cleanup() end return M + From da1d2c7aee3696edb228bf11c49be1b61a93c9ae Mon Sep 17 00:00:00 2001 From: alexekdahl Date: Sat, 8 Nov 2025 21:47:03 +0100 Subject: [PATCH 2/3] feat(config): validate ui.position option in schema Extends the configuration schema to include the new `ui.position` field. --- lua/marksman/init.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lua/marksman/init.lua b/lua/marksman/init.lua index cf63cbd..901c617 100644 --- a/lua/marksman/init.lua +++ b/lua/marksman/init.lua @@ -34,19 +34,15 @@ local default_config = { }, auto_save = true, max_marks = 100, - search_in_ui = true, silent = false, - -- minimal should be configured via ui opts minimal = false, disable_default_keymaps = false, debounce_ms = 500, -- Debounce save operations - -- UI specific settings ui = { -- Position of the marks window. -- "center" positions the window in the middle of the editor (default). -- "top_center" aligns the window at the top of the screen, centered horizontally. -- "bottom_center" aligns the window at the bottom of the screen, centered horizontally. - minimal = false, position = "center", }, } @@ -55,11 +51,19 @@ local default_config = { local config_schema = { auto_save = { type = "boolean" }, max_marks = { type = "number", min = 1, max = 1000 }, - search_in_ui = { type = "boolean" }, silent = { type = "boolean" }, minimal = { type = "boolean" }, disable_default_keymaps = { type = "boolean" }, debounce_ms = { type = "number", min = 100, max = 5000 }, + ui = { + type = "table", + fields = { + position = { + type = "string", + allowed = { "center", "top_center", "bottom_center" }, + }, + }, + }, } local config = {} @@ -742,4 +746,3 @@ function M.setup(opts) end return M - From c5b99f2ede3359fe5381d7f8a23fa7dcd804ff77 Mon Sep 17 00:00:00 2001 From: alexekdahl Date: Sun, 9 Nov 2025 10:59:19 +0100 Subject: [PATCH 3/3] chore: updated readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 666e67a..f47152a 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,9 @@ Vim's built-in marks are great, but they're global and get messy fast. Marksman silent = false, disable_default_keymaps = false, debounce_ms = 500, + ui = { + position = "center", -- "center", "top_center", or "bottom_center" + }, }, } ``` @@ -129,6 +132,9 @@ require("marksman").setup({ silent = false, -- Suppress notifications disable_default_keymaps = false, debounce_ms = 500, -- Save debounce (100-5000ms) + ui = { + position = "center", -- Window position: "center", "top_center", or "bottom_center" + }, highlights = { ProjectMarksTitle = { fg = "#61AFEF", bold = true }, ProjectMarksNumber = { fg = "#C678DD" },