diff options
| author | Aotrix <[email protected]> | 2026-08-09 21:59:55 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-08-09 21:59:55 +0200 |
| commit | 90e69c2d3da8433e518e09a191465674bc2eec62 (patch) | |
| tree | b9ca4df7f2ef752b699643c08298f1e5b8b231bc /lua/aotrix/plugins/build.lua | |
| parent | 2a64d67609b52ad31d60daeeeb86360d90459185 (diff) | |
Nice UI for commands
Diffstat (limited to 'lua/aotrix/plugins/build.lua')
| -rw-r--r-- | lua/aotrix/plugins/build.lua | 27 |
1 files 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", "<Down>", "<Tab>"}, @@ -128,24 +128,11 @@ return { submit = {"<CR>", "<Space>"} }, 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, |
