From 4de1862476e9e182885ed2d8a4750ec3c7103c22 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sat, 19 Sep 2026 01:36:20 +0200 Subject: Nicegit add lua/aotrix/plugins/build.lua git add lua/aotrix/plugins/build.lua ! --- lua/aotrix/plugins/build.lua | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'lua') diff --git a/lua/aotrix/plugins/build.lua b/lua/aotrix/plugins/build.lua index f178e4e..61dceb4 100644 --- a/lua/aotrix/plugins/build.lua +++ b/lua/aotrix/plugins/build.lua @@ -71,28 +71,21 @@ return { local addCommandToJsonFile = function(commandBlock, commandsFilePath, directory) local current_json = readJsonFromFile(commandsFilePath) - local is_new_file = false - if current_json ~= nil then - if current_json[directory] == nil then - current_json[directory] = {} - end - -- FIXME: duplicates - table.insert(current_json[directory], { - command = tostring(commandBlock.command()), - description = tostring(commandBlock.description()) - }) - else - is_new_file = true + if current_json == nil then current_json = {} end + if current_json[directory] == nil then + current_json[directory] = {} end + -- FIXME: duplicates + table.insert(current_json[directory], { + command = tostring(commandBlock.command()), + description = tostring(commandBlock.description()) + }) local file, error = io.open(commandsFilePath, 'w') - if is_new_file and file ~= nil then file:write("{}") end if file then local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t' if current_json ~= nil then - json_content = vim.json.encode(current_json, - {indent = indent}) - file:write(json_content) + file:write(vim.json.encode(current_json, {indent = indent})) end file:close() else -- cgit v1.2.3