From 3b2a5e9264fe3c8e297413bb99eff6567dc1add1 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sun, 21 Jun 2026 17:32:51 +0200 Subject: Adds hihi when a new command is created --- lua/aotrix/build.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lua/aotrix/build.lua') diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua index d1b10a6..91b2504 100644 --- a/lua/aotrix/build.lua +++ b/lua/aotrix/build.lua @@ -29,10 +29,13 @@ local readJsonFromFile = function(filePath) return nil end -local writeTableToJsonFile = function(table, filePath) - local file, error = io.open(filePath, 'w') +local addCommandToJsonFile = function(command, commandsFilePath, directory) + local current_json = readJsonFromFile(commandsFilePath) + current_json["hihi"] = 2 + local file, error = io.open(commandsFilePath, 'w') if file then - file:write(vim.json.encode(table)) + local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t' + file:write(vim.json.encode(current_json, {indent = indent})) file:close() else print("Error in writeTableToJsonFile: " .. error) @@ -40,9 +43,7 @@ local writeTableToJsonFile = function(table, filePath) end local appendCommandsFromFile = function(commands, commandsFilePath, directory) - local personal_commands_path = commandsFilePath - local current_list_of_commands_json = readJsonFromFile( - personal_commands_path) + local current_list_of_commands_json = readJsonFromFile(commandsFilePath) if current_list_of_commands_json ~= nil and current_list_of_commands_json[directory] ~= nil then for _, block in pairs(current_list_of_commands_json[directory]) do @@ -56,12 +57,14 @@ local appendCommandsFromFile = function(commands, commandsFilePath, directory) end local COMMANDS = {} -appendCommandsFromFile(COMMANDS, data_path .. "/personal_commands.json", - vim.fn.getcwd()) +PERSONAL_COMMAND_JSON_PATH = data_path .. "/personal_commands.json" +appendCommandsFromFile(COMMANDS, PERSONAL_COMMAND_JSON_PATH, vim.fn.getcwd()) local personalCommands = require("aotrix.personal_commands") COMMANDS.AddCommand = { command = function() - CURRENT_COMMAND = personalCommands.createCommand(COMMANDS).command + local created_command = personalCommands.createCommand(COMMANDS) + addCommandToJsonFile(created_command, PERSONAL_COMMAND_JSON_PATH) + CURRENT_COMMAND = created_command.command return CURRENT_COMMAND() end, description = function() return "Add command" end -- cgit v1.2.3