Created
July 17, 2022 08:59
-
-
Save Aiq0/93608dbdaaea8c2f0ad0d18ef0884be9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Removes return values from .sublime-completions | |
local file = io.open('LuaLove.sublime-completions', 'r') | |
if not file then | |
error('could not open in file') | |
end | |
local out = io.open('LuaLove.sublime-completions.new', 'w') | |
if not out then | |
error('could not open out file') | |
end | |
for line in file:lines() do | |
if line:sub(0, 14) == '\t\t\t"contents":' and line:find('=') then | |
local matching_line = line:sub(15) | |
local return_values, function_name, passed_values = matching_line:match('"([^"=]*)%s?=?%s?([^%(]+)%((.*)%)",') | |
local new_passed_values = '' | |
local i = 1 | |
for match in passed_values:gmatch('${%d+:([^}]+)}') do | |
print(match) | |
if i == 1 then | |
new_passed_values = '${1:' .. match .. '}' | |
else | |
new_passed_values = new_passed_values .. ', ${' .. i .. ':' .. match .. '}' | |
end | |
i = i + 1 | |
end | |
print(return_values, function_name, passed_values, new_passed_values) | |
out:write('\t\t\t"contents": "' .. function_name .. '(' .. new_passed_values .. ')",\n') | |
else | |
out:write(line .. '\n') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment