Home

Awesome

Lua language support in Atom

Add syntax highlighting and snippets to Lua files in Atom.

See: https://atom.io/packages/language-lua and: https://www.npmjs.com/package/language-lua

Common snippets

TriggerNameBody
-[multiline comment--[[ comment... ]]
=[nested multiline comment--[=[ comment... ]=]
afunanon functionfunctionName = function (args) -- body... end
forfor i=1,10for i = 1, 10 do -- body... end
forifor i,v in ipairs()for i,v in ipairs(table_name) do -- body... end
forpfor k,v in pairs()for k,v in pairs(table_name) do -- body... end
funfunctionfunction functionName (args) -- body... end
ifif conditionalif value then --body... end
ifeif else conditionalif value then --body... else --body... end
ifnif not conditionalif not value then --body... end
ifneif not else conditionalif not value then --body... else --body... end
lfunlocal functionlocal function functionName (args) -- body... end
loclocal variable definition shortcutlocal x = 1
locallocal variable definitionlocal x = 1
ltablocal table definitionlocal name = {}
printprintprint("logging")
reprepeat loop shortcutrepeat -- body... until condition
repeatrepeat looprepeat -- body... until condition
reqrequire shortcutlocal name = require "module"
requirerequirelocal name = require "module"
retreturn definition shortcutreturn value
returnreturn definitionreturn value
tabtable definitionname = {}
whiwhile loop shortcutwhile condition do -- body... end
whilewhile loopwhile condition do -- body... end

Table manipulation snippets

TriggerNameBody
tabctable.concattable.concat(tableName, " ", start_index, end_index)
tabftable.foreachtable.foreach(tableName, function)
tabitable.inserttable.insert(tableName, data)
tabstable.sorttable.sort(tableName, sortfunction)
tabrtable.removetable.remove(tableName, position)
tabmtable.maxntable.maxn(tableName)

Math function snippets

TriggerNameBody
absmath.absmath.abs(x)
acosmath.acosmath.acos(x)
asinmath.asinmath.asin(x)
atanmath.atanmath.atan(x)
atan2math.atan2math.atan2(y, x)
ceilmath.ceilmath.ceil(x)
cosmath.cosmath.cos(x)
coshmath.coshmath.cosh(x)
degmath.degmath.deg(x)
expmath.expmath.exp(x)
floormath.floormath.floor(x)
fmodmath.fmodmath.fmod(x, y)
frexpmath.frexpmath.frexp(x)
hugemath.hugemath.huge
ldexpmath.ldexpmath.ldexp(m, e)
logmath.logmath.log(x)
log10math.log10math.log10(x)
maxmath.maxmath.max(x, ...)
minmath.minmath.min(x, ...)
pimath.pimath.pi
powmath.powmath.pow(x, y)
radmath.radmath.rad(x)
randommath.randommath.random(m, n)
randomseedmath.randomseedmath.randomseed(x)
sinmath.sinmath.sin(x)
sinhmath.sinhmath.sinh(x)
sqrtmath.sqrtmath.sqrt(x)
tanmath.tanmath.tan(x)
tanhmath.tanhmath.tanh(x)

Author

Jorge Garrido Oval

Contributors

Contributions are greatly appreciated. Please fork this repository and open a pull request to add snippets, make grammar tweaks, etc.

License

Atom language-lua is released under the MIT license.

Originally converted from the Lua TextMate bundle.