luapack/plug/assigns.lua

17 lines
358 B
Lua
Raw Normal View History

2022-05-04 01:48:42 +00:00
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