├── .gitignore ├── CONTRIBUTING.md ├── LICENSE-MIT ├── README.md ├── grammars └── lua.cson ├── package.json ├── settings └── language-lua.cson └── snippets └── language-lua.cson /.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | See the [Atom contributing guide](https://atom.io/docs/latest/contributing) 2 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 FireZenk 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Lua language support in Atom 2 | ====== 3 | 4 | Add syntax highlighting and snippets to Lua files in Atom. 5 | 6 | See: https://atom.io/packages/language-lua 7 | and: https://www.npmjs.com/package/language-lua 8 | 9 | Common snippets 10 | --- 11 | | Trigger | Name | Body | 12 | | ------------- |--------------------------| ---------------------| 13 | | -[ | multiline comment | --[[ comment... ]] | 14 | | =[ | nested multiline comment | --[=[ comment... ]=] | 15 | | afun | anon function | functionName = function (args) -- body... end | 16 | | for | for i=1,10 | for i = 1, 10 do -- body... end | 17 | | fori | for i,v in ipairs() | for i,v in ipairs(table_name) do -- body... end | 18 | | forp | for k,v in pairs() | for k,v in pairs(table_name) do -- body... end | 19 | | fun | function | function functionName (args) -- body... end | 20 | | if | if conditional | if value then --body... end | 21 | | ife | if else conditional | if value then --body... else --body... end | 22 | | ifn | if not conditional | if not value then --body... end | 23 | | ifne | if not else conditional | if not value then --body... else --body... end | 24 | | lfun | local function | local function functionName (args) -- body... end | 25 | | loc | local variable definition shortcut | local x = 1 | 26 | | local | local variable definition | local x = 1 | 27 | | ltab | local table definition | local name = {} | 28 | | print | print | print("logging") | 29 | | rep | repeat loop shortcut | repeat -- body... until condition | 30 | | repeat | repeat loop | repeat -- body... until condition | 31 | | req | require shortcut | local name = require "module" | 32 | | require | require | local name = require "module" | 33 | | ret | return definition shortcut | return value | 34 | | return | return definition | return value | 35 | | tab | table definition | name = {} | 36 | | whi | while loop shortcut | while condition do -- body... end | 37 | | while | while loop | while condition do -- body... end | 38 | 39 | Table manipulation snippets 40 | --- 41 | | Trigger | Name | Body | 42 | | ------------- |--------------------------| ---------------------| 43 | | tabc | table.concat | table.concat(tableName, " ", start_index, end_index) | 44 | | tabf | table.foreach | table.foreach(tableName, function) | 45 | | tabi | table.insert | table.insert(tableName, data) | 46 | | tabs | table.sort | table.sort(tableName, sortfunction) | 47 | | tabr | table.remove | table.remove(tableName, position) | 48 | | tabm | table.maxn | table.maxn(tableName) 49 | 50 | Math function snippets 51 | --- 52 | | Trigger | Name | Body | 53 | | ------------- |--------------------------| ---------------------| 54 | | abs | math.abs | math.abs(x) | 55 | | acos | math.acos | math.acos(x) | 56 | | asin | math.asin | math.asin(x) | 57 | | atan | math.atan | math.atan(x) | 58 | | atan2 | math.atan2 | math.atan2(y, x) | 59 | | ceil | math.ceil | math.ceil(x) | 60 | | cos | math.cos | math.cos(x) | 61 | | cosh | math.cosh | math.cosh(x) | 62 | | deg | math.deg | math.deg(x) | 63 | | exp | math.exp | math.exp(x) | 64 | | floor | math.floor | math.floor(x) | 65 | | fmod | math.fmod | math.fmod(x, y) | 66 | | frexp | math.frexp | math.frexp(x) | 67 | | huge | math.huge | math.huge | 68 | | ldexp | math.ldexp | math.ldexp(m, e) | 69 | | log | math.log | math.log(x) | 70 | | log10 | math.log10 | math.log10(x) | 71 | | max | math.max | math.max(x, ...) | 72 | | min | math.min | math.min(x, ...) | 73 | | pi | math.pi | math.pi | 74 | | pow | math.pow | math.pow(x, y) | 75 | | rad | math.rad | math.rad(x) | 76 | | random | math.random | math.random(m, n) | 77 | | randomseed | math.randomseed | math.randomseed(x) | 78 | | sin | math.sin | math.sin(x) | 79 | | sinh | math.sinh | math.sinh(x) | 80 | | sqrt | math.sqrt | math.sqrt(x) | 81 | | tan | math.tan | math.tan(x) | 82 | | tanh | math.tanh | math.tanh(x) | 83 | 84 | Author 85 | ------ 86 | __Jorge Garrido Oval__ 87 | * [https://github.com/FireZenk](https://github.com/FireZenk) 88 | 89 | 90 | Contributors 91 | --- 92 | 93 | Contributions are greatly appreciated. Please fork this repository and open a 94 | pull request to add snippets, make grammar tweaks, etc. 95 | 96 | License 97 | ------ 98 | Atom language-lua is released under the MIT license. 99 | 100 | >Originally [converted](http://atom.io/docs/latest/converting-a-text-mate-bundle) 101 | from the [Lua TextMate bundle](https://github.com/textmate/lua.tmbundle). 102 | -------------------------------------------------------------------------------- /grammars/lua.cson: -------------------------------------------------------------------------------- 1 | 'comment': 'Lua Syntax: version 0.8' 2 | 'fileTypes': [ 3 | 'lua' 4 | 'nse' 5 | 'rockspec' 6 | 'luacheckrc' 7 | 'lakefile' 8 | ] 9 | 'firstLineMatch': '\\A#!.*?\\blua\\b' 10 | 'name': 'Lua' 11 | 'patterns': [ 12 | { 13 | 'captures': 14 | '1': 15 | 'name': 'keyword.control.lua' 16 | '2': 17 | 'name': 'entity.name.function.scope.lua' 18 | '3': 19 | 'name': 'entity.name.function.lua' 20 | '4': 21 | 'name': 'punctuation.definition.parameters.begin.lua' 22 | '5': 23 | 'name': 'variable.parameter.function.lua' 24 | '6': 25 | 'name': 'punctuation.definition.parameters.end.lua' 26 | 'match': '\\b(function)(?:\\s+([a-zA-Z_.:]+[.:])?([a-zA-Z_]\\w*)\\s*)?(\\()([^)]*)(\\))' 27 | 'name': 'meta.function.lua' 28 | } 29 | { 30 | 'match': '(?=?|(?", 6 | "description": "Add syntax highlighting and snippets to Lua files in Atom", 7 | "repository": "https://github.com/FireZenk/language-lua", 8 | "license": "MIT", 9 | "engines": { 10 | "atom": ">=0.50.0" 11 | }, 12 | "dependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /settings/language-lua.cson: -------------------------------------------------------------------------------- 1 | '.source.lua': 2 | 'editor': 3 | 'commentStart': '-- ' 4 | 'increaseIndentPattern': '((\\b(else|function|then|do|repeat)\\b((?!\\b(end|until)\\b).)*)|(\\{\\s*))$' 5 | 'decreaseIndentPattern': '^\\s*((\\b(elseif|else|end|until)\\b)|(\\})|(\\)))' 6 | 'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)|^\\s*end$' 7 | -------------------------------------------------------------------------------- /snippets/language-lua.cson: -------------------------------------------------------------------------------- 1 | '.source.lua': 2 | 'multiline comment': 3 | 'prefix': '-[' 4 | 'body': '--[[ ${0:comment...}]' 5 | 'nested multiline comment': 6 | 'prefix': '=[' 7 | 'body': '--[=[ ${0:comment...}]=' 8 | 'function': 9 | 'prefix': 'fun' 10 | 'body': 'function ${1:FunctionName} (${2:args})\n\t${0:-- body...}\nend' 11 | 'anon function': 12 | 'prefix': 'afun' 13 | 'body': '${1:FunctionName} = function (${2:args})\n\t${0:-- body...}\nend' 14 | 'while loop': 15 | 'prefix': 'while' 16 | 'body': 'while ${1:condition} do\n\t${0:-- body...}\nend' 17 | 'while loop shortcut': 18 | 'prefix': 'whi' 19 | 'body': 'while ${1:condition} do\n\t${0:-- body...}\nend' 20 | 'repeat loop': 21 | 'prefix': 'repeat' 22 | 'body': 'repeat\n\t${0:-- body...}\nuntil ${1:condition}' 23 | 'repeat loop shortcut': 24 | 'prefix': 'rep' 25 | 'body': 'repeat\n\t${0:-- body...}\nuntil ${1:condition}' 26 | 'for i,v in ipairs()': 27 | 'prefix': 'fori' 28 | 'body': 'for ${1:i},${2:v} in ipairs(${3:table_name}) do\n\t${0:-- body...}\nend' 29 | 'for i=1,10': 30 | 'prefix': 'for' 31 | 'body': 'for ${1:i}=${2:1},${3:10} do\n\t${0:-- body...}\nend' 32 | 'for k,v in pairs()': 33 | 'prefix': 'forp' 34 | 'body': 'for ${1:k},${2:v} in pairs(${3:table_name}) do\n\t${0:-- body...}\nend' 35 | 'local function': 36 | 'prefix': 'lfun' 37 | 'body': 'local function ${1:FunctionName} (${2:args})\n\t${0:-- body...}\nend' 38 | 'local variable definition': 39 | 'prefix': 'local' 40 | 'body': 'local ${1:x} = ${0:1}' 41 | 'local variable definition shortcut': 42 | 'prefix': 'loc' 43 | 'body': 'local ${1:x} = ${0:1}' 44 | 'local table definition': 45 | 'prefix': 'ltab' 46 | 'body': 'local ${0:name} = {}' 47 | 'return definition': 48 | 'prefix': 'return' 49 | 'body': 'return ${0:value}' 50 | 'return definition shortcut': 51 | 'prefix': 'ret' 52 | 'body': 'return ${0:value}' 53 | 'print': 54 | 'prefix': 'print' 55 | 'body': 'print("${0:logging}")' 56 | 'require': 57 | 'prefix': 'require' 58 | 'body': 'local ${0:name} = require "${1:module}"' 59 | 'require shortcut': 60 | 'prefix': 'req' 61 | 'body': 'local ${0:name} = require "${1:module}"' 62 | 'if conditional': 63 | 'prefix': 'if', 64 | 'body': 'if ${1:value} then\n\t${0:--body...}\nend' 65 | 'if else conditional': 66 | 'prefix': 'ife', 67 | 'body': 'if ${1:value} then\n\t${0:--body...}\nelse\n\t${1:--body...}\nend' 68 | 'if not conditional': 69 | 'prefix': 'ifn', 70 | 'body': 'if not ${1:value} then\n\t${0:--body...}\nend' 71 | 'if not else conditional': 72 | 'prefix': 'ifne', 73 | 'body': 'if not ${1:value} then\n\t${0:--body...}\nelse\n\t${1:--body...}\nend' 74 | 'table definition': 75 | 'prefix': 'tab' 76 | 'body': '${0:name} = {}' 77 | 'table.insert': 78 | 'prefix': 'tabi', 79 | 'body': 'table.insert(${0:tableName},${1:data})' 80 | 'table.foreach': 81 | 'prefix': 'tabf', 82 | 'body': 'table.foreach(${0:tableName},${1:function})' 83 | 'table.concat': 84 | 'prefix': 'tabc' 85 | 'body': 'table.concat(${1:tableName}${2:, " "}${3:, start_index}${4:, end_index})' 86 | 'table.sort': 87 | 'prefix': 'tabs', 88 | 'body': 'table.sort(${1:tableName}${2:, sortfunction})' 89 | 'table.remove': 90 | 'prefix': 'tabr', 91 | 'body': 'table.remove(${1:tableName}${2:, position})' 92 | 'table.maxn': 93 | 'prefix': 'tabm', 94 | 'body': 'table.maxn(${1:tableName})' 95 | 'math.abs': 96 | 'prefix': 'abs', 97 | 'body': 'math.abs(${0:x})' 98 | 'math.acos': 99 | 'prefix': 'acos', 100 | 'body': 'math.acos(${0:x})' 101 | 'math.asin': 102 | 'prefix': 'asin', 103 | 'body': 'math.asin(${0:x})' 104 | 'math.atan': 105 | 'prefix': 'atan', 106 | 'body': 'math.atan(${0:x})' 107 | 'math.atan2': 108 | 'prefix': 'atan2', 109 | 'body': 'math.atan2(${0:y}, ${1:x})' 110 | 'math.ceil': 111 | 'prefix': 'ceil', 112 | 'body': 'math.ceil(${0:x})' 113 | 'math.cos': 114 | 'prefix': 'cos', 115 | 'body': 'math.cos(${0:x})' 116 | 'math.cosh': 117 | 'prefix': 'cosh', 118 | 'body': 'math.cosh(${0:x})' 119 | 'math.deg': 120 | 'prefix': 'deg', 121 | 'body': 'math.deg(${0:x})' 122 | 'math.exp': 123 | 'prefix': 'exp', 124 | 'body': 'math.exp(${0:x})' 125 | 'math.floor': 126 | 'prefix': 'floor', 127 | 'body': 'math.floor(${0:x})' 128 | 'math.fmod': 129 | 'prefix': 'fmod', 130 | 'body': 'math.fmod(${0:x}, ${1:y})' 131 | 'math.frexp': 132 | 'prefix': 'frexp', 133 | 'body': 'math.frexp(${0:x})' 134 | 'math.huge': 135 | 'prefix': 'huge', 136 | 'body': 'math.huge' 137 | 'math.ldexp': 138 | 'prefix': 'ldexp', 139 | 'body': 'math.ldexp(${0:m}, ${1:e})' 140 | 'math.log': 141 | 'prefix': 'log', 142 | 'body': 'math.log(${0:x})' 143 | 'math.log10': 144 | 'prefix': 'log10', 145 | 'body': 'math.log10(${0:x})' 146 | 'math.max': 147 | 'prefix': 'max', 148 | 'body': 'math.max(${0:x}, ${1:...})' 149 | 'math.min': 150 | 'prefix': 'min', 151 | 'body': 'math.min(${0:x}, ${1:...})' 152 | 'math.pi': 153 | 'prefix': 'pi', 154 | 'body': 'math.pi' 155 | 'math.pow': 156 | 'prefix': 'pow', 157 | 'body': 'math.pow(${0:x}, ${1:y})' 158 | 'math.rad': 159 | 'prefix': 'rad', 160 | 'body': 'math.rad(${0:x})' 161 | 'math.random': 162 | 'prefix': 'random', 163 | 'body': 'math.random(${0:m}, ${1:n})' 164 | 'math.randomseed': 165 | 'prefix': 'randomseed', 166 | 'body': 'math.randomseed(${0:x})' 167 | 'math.sin': 168 | 'prefix': 'sin', 169 | 'body': 'math.sin(${0:x})' 170 | 'math.sinh': 171 | 'prefix': 'sinh', 172 | 'body': 'math.sinh(${0:x})' 173 | 'math.sqrt': 174 | 'prefix': 'sqrt', 175 | 'body': 'math.sqrt(${0:x})' 176 | 'math.tan': 177 | 'prefix': 'tan', 178 | 'body': 'math.tan(${0:x})' 179 | 'math.tanh': 180 | 'prefix': 'tanh', 181 | 'body': 'math.tanh(${0:x})' 182 | --------------------------------------------------------------------------------