From 1f0ab79a26a3bfc396f8fa09a1acda0df2d2fec3 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Wed, 3 Jun 2026 21:02:19 +0200 Subject: Create temporary command --- lua/aotrix/build.lua | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'lua/aotrix/build.lua') diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua index c429467..35d9675 100644 --- a/lua/aotrix/build.lua +++ b/lua/aotrix/build.lua @@ -1,16 +1,19 @@ -local CURRENT_COMMAND = "" +local CURRENT_COMMAND = nil ----@param command string +---@param command string|nil ---@return nil function executeCommandInTerminal(command) - vim.cmd.term() - vim.cmd.startinsert() - local channel = vim.bo.channel - -- 'clear' is used to hide the command - local exit_message = "\nPress enter to exit..." - vim.api.nvim_chan_send(channel, - "clear && " .. command .. "; echo '" .. exit_message .. - "' && read -s && exit" .. "\n") + if (command ~= nil) then + vim.cmd.term() + vim.cmd.startinsert() + local channel = vim.bo.channel + -- 'clear' is used to hide the command + local exitMessage = "\nPress enter to exit..." + local commandString = command() + vim.api.nvim_chan_send(channel, + "clear && " .. commandString .. "; echo '" .. + exitMessage .. "' && read -s && exit" .. "\n") + end end local COMMANDS = {} @@ -29,14 +32,14 @@ function selectCommand(listOfCommands, callback) end }, function(choice) if (choice ~= nil) then - CURRENT_COMMAND = listOfCommands[choice].command() + CURRENT_COMMAND = listOfCommands[choice].command callback() end end) end function executeCommand(listOfCommands) - if (string.len(CURRENT_COMMAND) == 0) then + if (CURRENT_COMMAND == nil) then selectCommand(listOfCommands, function() executeCommandInTerminal(CURRENT_COMMAND) -- cgit v1.2.3