diff options
| author | Aotrix <[email protected]> | 2026-09-19 01:36:20 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-09-19 01:36:20 +0200 |
| commit | 4de1862476e9e182885ed2d8a4750ec3c7103c22 (patch) | |
| tree | 1d2c1adc331c9a119f68af37d7841722ccd0eb52 /lua/aotrix | |
| parent | 82615d77798bf614996600be3684f4f4141446aa (diff) | |
Nicegit add lua/aotrix/plugins/build.lua git add lua/aotrix/plugins/build.lua !
Diffstat (limited to 'lua/aotrix')
| -rw-r--r-- | lua/aotrix/plugins/build.lua | 25 |
1 files changed, 9 insertions, 16 deletions
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 |
