From bcaf0d3d6e5cc6e8ecb8df3a7df7d98c567d36e6 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 29 Jul 2023 09:34:59 -0700 Subject: [PATCH] refactor!: deprecate the "anchor" config option (#106) This was left over from before we had the "override" function. Now, it doesn't make much sense to set the anchor as an option because so much of the rest of the layout logic depends on the anchor being the default. If a user wants to customize the layout, the override function is the way to do it. --- lua/dressing/config.lua | 9 +++++++-- lua/dressing/input.lua | 2 +- lua/dressing/select/builtin.lua | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lua/dressing/config.lua b/lua/dressing/config.lua index b8f22c7..d8c36b5 100644 --- a/lua/dressing/config.lua +++ b/lua/dressing/config.lua @@ -16,7 +16,6 @@ local default_config = { start_in_insert = true, -- These are passed to nvim_open_win - anchor = "SW", border = "rounded", -- 'editor' and 'win' will default to being centered relative = "cursor", @@ -120,7 +119,6 @@ local default_config = { -- Options for built-in selector builtin = { -- These are passed to nvim_open_win - anchor = "NW", border = "rounded", -- 'editor' and 'win' will default to being centered relative = "editor", @@ -170,6 +168,13 @@ local M = vim.deepcopy(default_config) M.update = function(opts) local newconf = vim.tbl_deep_extend("force", default_config, opts or {}) + if newconf.input.anchor or newconf.select.builtin.anchor then + vim.notify( + "Deprecated: dressing no longer accepts an 'anchor' option. Use the 'override' function to change the anchor", + vim.log.levels.WARN + ) + end + for k, v in pairs(newconf) do M[k] = v end diff --git a/lua/dressing/input.lua b/lua/dressing/input.lua index 30a6b63..b275e16 100644 --- a/lua/dressing/input.lua +++ b/lua/dressing/input.lua @@ -229,7 +229,7 @@ local function create_or_update_win(config, prompt, opts) else winopt = { relative = config.relative, - anchor = config.anchor, + anchor = "SW", border = config.border, height = 1, style = "minimal", diff --git a/lua/dressing/select/builtin.lua b/lua/dressing/select/builtin.lua index 3387101..8067f95 100644 --- a/lua/dressing/select/builtin.lua +++ b/lua/dressing/select/builtin.lua @@ -76,7 +76,7 @@ M.select = function(config, items, opts, on_choice) local col = util.calculate_col(config.relative, width, 0) local winopt = { relative = config.relative, - anchor = config.anchor, + anchor = "NW", row = row, col = col, border = config.border,