From 90e69c2d3da8433e518e09a191465674bc2eec62 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sun, 9 Aug 2026 21:59:55 +0200 Subject: Nice UI for commands --- lua/aotrix/plugins/build.lua | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/lua/aotrix/plugins/build.lua b/lua/aotrix/plugins/build.lua index 6dec5ac..c3a03c1 100644 --- a/lua/aotrix/plugins/build.lua +++ b/lua/aotrix/plugins/build.lua @@ -104,6 +104,10 @@ return { local selectCommand = function(listOfCommands, callback) local Menu = require("nui.menu") + local commandDescriptions = {} + for title, _ in pairs(listOfCommands) do + table.insert(commandDescriptions, Menu.item(title)) + end local menu = Menu({ position = "50%", size = {width = "80%", height = "80%"}, @@ -115,11 +119,7 @@ return { winhighlight = "Normal:Normal,FloatBorder:Normal" } }, { - lines = { - Menu.item("Hydrogen (H)"), Menu.item("Carbon (C)"), - Menu.item("Nitrogen (N)"), Menu.item("Helium (He)"), - Menu.item("Neon (Ne)"), Menu.item("Argon (Ar)") - }, + lines = commandDescriptions, max_width = 100, keymap = { focus_next = {"j", "", ""}, @@ -128,24 +128,11 @@ return { submit = {"", ""} }, on_submit = function(item) - print("Menu Submitted: ", item.text) + CURRENT_COMMAND = listOfCommands[item.text].command + callback(item.text) end }) - - -- mount the component menu:mount() - - -- vim.ui.select(vim.tbl_keys(listOfCommands), { - -- prompt = "Select your command.", - -- format_item = function(item) - -- return listOfCommands[item].description() - -- end - -- }, function(choice) - -- if (choice ~= nil) then - -- CURRENT_COMMAND = listOfCommands[choice].command - -- callback(choice) - -- end - -- end) end local addCommand = function(current_command, commands, -- cgit v1.2.3