diff options
| author | Aotrix <[email protected]> | 2026-08-09 19:17:11 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-08-09 19:17:11 +0200 |
| commit | d58313ecc3d2d28c3cf05f5d6849fee0287d19e4 (patch) | |
| tree | 4e01608593f73bae55cd9a929034b0460575d652 /lua | |
| parent | 844052931979828d76b7a34f92217b30bbc27f51 (diff) | |
Add command with beautiful ui
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/aotrix/plugins/build.lua | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/lua/aotrix/plugins/build.lua b/lua/aotrix/plugins/build.lua index c940993..a0a642c 100644 --- a/lua/aotrix/plugins/build.lua +++ b/lua/aotrix/plugins/build.lua @@ -120,14 +120,13 @@ return { personal_command_json_path) local selectedCommand = nil - local event = require("nui.utils.autocmd").event local Input = require("nui.input") - local input = Input({ + local inputDescription = Input({ position = "50%", size = {width = 120}, border = { style = "single", - text = {top = "[Howdy?]", top_align = "center"} + text = {top = "[Enter description]", top_align = "center"} }, win_options = { winhighlight = "Normal:Normal,FloatBorder:Normal" @@ -136,9 +135,7 @@ return { prompt = "> ", default_value = "", on_submit = function(value) - selectedCommand = value - local selectedDescription = vim.fn.input( - 'Name the command: ') + local selectedDescription = value commands[selectedDescription] = { command = function() return selectedCommand @@ -155,6 +152,30 @@ return { executeCommandInTerminal(current_command) end }) + local input = Input({ + position = "50%", + size = {width = 120}, + border = { + style = "single", + text = {top = "[Add command]", top_align = "center"} + }, + win_options = { + winhighlight = "Normal:Normal,FloatBorder:Normal" + } + }, { + prompt = "> ", + default_value = "", + on_submit = function(value) + selectedCommand = value + inputDescription:mount() + local insert = vim.api.nvim_replace_termcodes("i", true, + true, true) + vim.api.nvim_feedkeys(insert, "t", false) + inputDescription:map("n", "<Esc>", function() + inputDescription:unmount() + end, {noremap = true}) + end + }) -- mount/open the component input:mount() |
