luapack/plug/assigns.lua

17 lines
358 B
Lua

local reg = '([%%w_%%.%%[%%]]+)%%s*(%s)=%%s*'
local regv = '%1 = %1 %2 '
return function(op)
return {
name = 'Assigments',
transform = function(e, opts)
return e.src
:gsub(reg:format '[%+%-%*%/%%^|&]', regv)
:gsub(reg:format '%.%.', regv)
:gsub(reg:format 'and', regv)
:gsub(reg:format 'or', regv)
end,
}
end