Last active
September 9, 2025 01:29
-
-
Save wolf81/9483c2c4d4e79ca800e286c37d6c9cbe to your computer and use it in GitHub Desktop.
Sublime Text snippet for a Lua class prototype, invoke by typing `class`
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
| <snippet> | |
| <content><![CDATA[ | |
| local ${1:ClassName} = {} | |
| $1.new = function() | |
| $0 | |
| return setmetatable({ | |
| }, $1) | |
| end | |
| return setmetatable($1, { | |
| __call = function(_, ...) return $1.new(...) end, | |
| }) | |
| ]]></content> | |
| <tabTrigger>class</tabTrigger> | |
| <description>Add a Lua class with private scope.</description> | |
| <scope>source.lua</scope> | |
| </snippet> |
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
| <snippet> | |
| <content><![CDATA[ | |
| local M = {} | |
| function M.$0() | |
| end | |
| return M | |
| ]]></content> | |
| <tabTrigger>module</tabTrigger> | |
| <description>Add a Lua module.</description> | |
| <scope>source.lua</scope> | |
| </snippet> |
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
Show hidden characters
| // Snippets for VS Code - store in .vscode/ directory at root of project. | |
| { | |
| "Lua Class Template": { | |
| "prefix": "class", | |
| "scope": "lua", | |
| "body": [ | |
| "local ${1:ClassName} = {}", | |
| "$1.new = function()", | |
| "\t$0", | |
| "\treturn setmetatable({", | |
| "\t}, $1)", | |
| "end", | |
| "return setmetatable($1, {", | |
| "\t__call = function(_, ...) return $1.new(...) end,", | |
| "})" | |
| ], | |
| "description": "Lua class-style metatable template" | |
| }, | |
| "Lua Module Template": { | |
| "prefix": "module", | |
| "scope": "lua", | |
| "body": [ | |
| "local M = {}", | |
| "", | |
| "function M.$0()", | |
| "end", | |
| "", | |
| "return M" | |
| ], | |
| "description": "Lua module with one function stub" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment