diff options
| author | Aotrix <[email protected]> | 2026-08-09 19:47:55 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-08-09 19:47:55 +0200 |
| commit | 2a64d67609b52ad31d60daeeeb86360d90459185 (patch) | |
| tree | d403d61e83e4e2aaab33a76cd395410ef2a55591 /lua/aotrix | |
| parent | f6f157c5bccd40e26dd6e6ee69b056c7a76fbd3e (diff) | |
Add default select menu
Diffstat (limited to 'lua/aotrix')
| -rw-r--r-- | lua/aotrix/plugins/build.lua | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/lua/aotrix/plugins/build.lua b/lua/aotrix/plugins/build.lua index 54d18af..6dec5ac 100644 --- a/lua/aotrix/plugins/build.lua +++ b/lua/aotrix/plugins/build.lua @@ -103,17 +103,49 @@ return { end local selectCommand = function(listOfCommands, callback) - 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) + local Menu = require("nui.menu") + local menu = Menu({ + position = "50%", + size = {width = "80%", height = "80%"}, + border = { + style = "single", + text = {top = "[Choose a command]", top_align = "center"} + }, + win_options = { + 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)") + }, + max_width = 100, + keymap = { + focus_next = {"j", "<Down>", "<Tab>"}, + focus_prev = {"k", "<Up>", "<S-Tab>"}, + close = {"<Esc>", "<C-c>"}, + submit = {"<CR>", "<Space>"} + }, + on_submit = function(item) + print("Menu Submitted: ", item.text) end - 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, |
