diff options
| author | Aotrix <[email protected]> | 2026-06-21 18:32:22 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-06-21 18:32:22 +0200 |
| commit | 46cab40d999a77ca1b43ef4a9ec7d6119831d91f (patch) | |
| tree | 1e2695ecb3146e82a44585e44c500686c936bfe2 | |
| parent | 3b2a5e9264fe3c8e297413bb99eff6567dc1add1 (diff) | |
Commands are saved
| -rw-r--r-- | lua/aotrix/build.lua | 15 |
1 files 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, |
