summaryrefslogtreecommitdiff
path: root/lua/aotrix/build.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/aotrix/build.lua')
-rw-r--r--lua/aotrix/build.lua28
1 files changed, 25 insertions, 3 deletions
diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua
index 605b736..ffd0bcd 100644
--- a/lua/aotrix/build.lua
+++ b/lua/aotrix/build.lua
@@ -1,4 +1,5 @@
local CURRENT_COMMAND = nil
+local data_path = vim.fn.stdpath("data")
---@param command string|nil
---@return nil
@@ -16,14 +17,35 @@ function executeCommandInTerminal(command)
end
end
+function writeJsonToFile(json, filePath)
+ local file, error = io.open(filePath, 'r')
+ local content = file:read("*a")
+ if file ~= nil then
+ local decoded_json = vim.json.decode(content)
+ print(decoded_json["first_element"])
+ end
+ -- local file, error = io.open(filePath, 'w')
+ -- if file then
+ -- file:write(tostring(json))
+ -- file:close()
+ -- else
+ -- print("error:", error)
+ -- end
+end
+
+function appendCommandsFromDirectory(commands, directory)
+ encoded_json = vim.json.encode({first_element = 1, second_element = 2})
+ personal_commands_path = string.format("%s/personal_commands.json",
+ data_path)
+ writeJsonToFile(encoded_json, personal_commands_path)
+end
+
local COMMANDS = {}
+appendCommandsFromDirectory(COMMANDS, vim.fn.getcwd())
local personalCommands = require("aotrix.personal_commands")
-
COMMANDS.AddCommand = {
command = function()
CURRENT_COMMAND = personalCommands.createCommand(COMMANDS).command
- encoded_json = vim.json.encode({first_element = 1, second_element = 2})
- print(encoded_json)
return CURRENT_COMMAND()
end,
description = function() return "Add temporary command" end