summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin.chausse@goto.com>2025-04-03 00:23:29 -0400
committerBenjamin Chausse <benjamin.chausse@goto.com>2025-04-03 00:23:29 -0400
commita76d52433cd316a9989afccf10813f9d9221ea3b (patch)
tree68229d387a367de79abe9dfe1291aada17259448
parent5804217bdc99e58a65dcf04baf70e028731219b1 (diff)
Better search + Aligned columnsHEADmaster
-rw-r--r--lua/dropship.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/lua/dropship.lua b/lua/dropship.lua
index 7b5eb40..ca25eff 100644
--- a/lua/dropship.lua
+++ b/lua/dropship.lua
@@ -27,6 +27,13 @@ end
local function get_target(opts, callback)
opts = opts or {}
+
+ -- Calculate the maximum length from all entry names
+ local max_name_length = 0
+ for _, entry in ipairs(opts.drop_locations or M.drop_locations) do
+ max_name_length = math.max(max_name_length, #(entry.name or "Unknown"))
+ end
+
pickers
.new(opts, {
prompt_title = opts.prompt_title or "Drop into which project?",
@@ -34,10 +41,14 @@ local function get_target(opts, callback)
finder = finders.new_table({
results = opts.drop_locations or M.drop_locations,
entry_maker = function(entry)
+ local name = entry.name or "Unknown"
+ local dir = entry.dir or "Unknown"
+ local padded_name = name .. ":" .. string.rep(" ", max_name_length - #name + 1)
+ local display = padded_name .. dir
return {
value = entry,
- display = (entry.name or "Unknown") .. ": " .. (entry.dir or "Unknown"),
- ordinal = entry.name or ".",
+ display = display,
+ ordinal = display,
}
end,
}),