From 46cab40d999a77ca1b43ef4a9ec7d6119831d91f Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sun, 21 Jun 2026 18:32:22 +0200 Subject: Commands are saved --- lua/aotrix/build.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua index 91b2504..e1fd061 100644 --- a/lua/aotrix/build.lua +++ b/lua/aotrix/build.lua @@ -29,9 +29,17 @@ local readJsonFromFile = function(filePath) return nil end -local addCommandToJsonFile = function(command, commandsFilePath, directory) +local addCommandToJsonFile = function(commandBlock, commandsFilePath, directory) local current_json = readJsonFromFile(commandsFilePath) - current_json["hihi"] = 2 + if current_json ~= nil then + if current_json[directory] == nil then + current_json[directory] = {} + end + table.insert(current_json[directory], { + command = tostring(commandBlock.command()), + description = tostring(commandBlock.description()) + }) + end local file, error = io.open(commandsFilePath, 'w') if file then local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t' @@ -63,7 +71,8 @@ local personalCommands = require("aotrix.personal_commands") COMMANDS.AddCommand = { command = function() local created_command = personalCommands.createCommand(COMMANDS) - addCommandToJsonFile(created_command, PERSONAL_COMMAND_JSON_PATH) + addCommandToJsonFile(created_command, PERSONAL_COMMAND_JSON_PATH, + vim.fn.getcwd()) CURRENT_COMMAND = created_command.command return CURRENT_COMMAND() end, -- cgit v1.2.3