From ac5c1f1d92fd3e41562350c2c099b8e5f4a1246f Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sat, 31 Jan 2026 21:18:45 +0100 Subject: add compile shortcut --- lua/aotrix/compile.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lua/aotrix/compile.lua b/lua/aotrix/compile.lua index 9b0c58b..e7c9556 100644 --- a/lua/aotrix/compile.lua +++ b/lua/aotrix/compile.lua @@ -77,6 +77,28 @@ end ---@return nil function compileTarget() function compile(pTarget) + if not (pTarget == nil) and string.len(pTarget) > 0 then + createFloatingTerminal() + local commandTable = { + "cmake --build " .. build_dir .. " --target " .. pTarget + } + local commandConcatenation = "" + for i, command in ipairs(commandTable) do + commandConcatenation = commandConcatenation .. command + if i < #commandTable then + commandConcatenation = commandConcatenation .. " && " + end + end + executeCommandInTerminal(commandConcatenation) + end + end + + defineBuildFolderPath() + chooseTarget(compile) +end + +function compileAndExecuteTarget() + function compileAndExecute(pTarget) if not (pTarget == nil) and string.len(pTarget) > 0 then createFloatingTerminal() local commandTable = { @@ -95,7 +117,8 @@ function compileTarget() end defineBuildFolderPath() - chooseTarget(compile) + chooseTarget(compileAndExecute) end -vim.keymap.set("n", "mt", compileTarget) +vim.keymap.set("n", "mc", compileTarget) +vim.keymap.set("n", "mt", compileAndExecuteTarget) -- cgit v1.2.3