Giter VIP home page Giter VIP logo

language-lua's Introduction

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

Trigger Name Body
-[ multiline comment --[[ comment... ]]
=[ nested multiline comment --[=[ comment... ]=]
afun anon function functionName = function (args) -- body... end
for for i=1,10 for i = 1, 10 do -- body... end
fori for i,v in ipairs() for i,v in ipairs(table_name) do -- body... end
forp for k,v in pairs() for k,v in pairs(table_name) do -- body... end
fun function function functionName (args) -- body... end
if if conditional if value then --body... end
ife if else conditional if value then --body... else --body... end
ifn if not conditional if not value then --body... end
ifne if not else conditional if not value then --body... else --body... end
lfun local function local function functionName (args) -- body... end
loc local variable definition shortcut local x = 1
local local variable definition local x = 1
ltab local table definition local name = {}
print print print("logging")
rep repeat loop shortcut repeat -- body... until condition
repeat repeat loop repeat -- body... until condition
req require shortcut local name = require "module"
require require local name = require "module"
ret return definition shortcut return value
return return definition return value
tab table definition name = {}
whi while loop shortcut while condition do -- body... end
while while loop while condition do -- body... end

Table manipulation snippets

Trigger Name Body
tabc table.concat table.concat(tableName, " ", start_index, end_index)
tabf table.foreach table.foreach(tableName, function)
tabi table.insert table.insert(tableName, data)
tabs table.sort table.sort(tableName, sortfunction)
tabr table.remove table.remove(tableName, position)
tabm table.maxn table.maxn(tableName)

Math function snippets

Trigger Name Body
abs math.abs math.abs(x)
acos math.acos math.acos(x)
asin math.asin math.asin(x)
atan math.atan math.atan(x)
atan2 math.atan2 math.atan2(y, x)
ceil math.ceil math.ceil(x)
cos math.cos math.cos(x)
cosh math.cosh math.cosh(x)
deg math.deg math.deg(x)
exp math.exp math.exp(x)
floor math.floor math.floor(x)
fmod math.fmod math.fmod(x, y)
frexp math.frexp math.frexp(x)
huge math.huge math.huge
ldexp math.ldexp math.ldexp(m, e)
log math.log math.log(x)
log10 math.log10 math.log10(x)
max math.max math.max(x, ...)
min math.min math.min(x, ...)
pi math.pi math.pi
pow math.pow math.pow(x, y)
rad math.rad math.rad(x)
random math.random math.random(m, n)
randomseed math.randomseed math.randomseed(x)
sin math.sin math.sin(x)
sinh math.sinh math.sinh(x)
sqrt math.sqrt math.sqrt(x)
tan math.tan math.tan(x)
tanh math.tanh math.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.

language-lua's People

Contributors

chrolo avatar firezenk avatar jagregory avatar kankaristo avatar nebularg avatar rm-code avatar robinlennox avatar rochet2 avatar wyozi avatar xpol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

language-lua's Issues

Atom not propagating 0.9.3.1

It seems like Atom only recognizes 3-level version numbers so 0.9.3.1 is being ignored since there is already a 0.9.3 release. Could you bump the version to 0.9.4 so Atom will recognize it?

Auto-end code blocks

I am not sure if this is an Atom feature or a language grammar feature (or both?) but Atom seems to enjoy adding closing syntax such as brackets, braces, and quotations when you type the opening equivalent. It would be pretty nice if this grammar could auto close code blocks that use "end" such as:

function name()
end

name = function()
end

for i=1, 10 do
end

for i, v in ipairs(t) do
end

for k, v in pairs(t) do
end

while true do
end

do
end

if true then
end

Ctrl-R menu wrongly detects functions

I have a local variable called functionIndex and it is detected as a method called ndex.

I am pretty new to Atom so I'm not sure if this is the fault of this package, but I think my suspicions are correct.

indenting error

If you use the string 'function', it is indented as if you used the keyword function:
For example:

local a = type(x) == 'function' and x or nil

indents one tab after return

Pico8 file support

Not really an issue, but nice to have. Would you mind adding "p8" files to the list of supported files in the grammars/lua.cson file? There's a big community of Pico-8 (http://www.lexaloffle.com/pico-8.php) developers who I'm sure would be very grateful ;)

A table name end with a NUMBER,

wnd_firework1 = i3k_class("wnd_firework1", ui.wnd_base)
function wnd_firework1:ctor()

end

the function i3k_classreturn a Class,while "wnd_firework1" the name of the table is end with a NUMBER, wnd_firewor1 will not highlight like others do.

Package.loadSettings is deprecated.

Store package settings files in the settings/ directory instead of scoped-properties/

Package.loadSettings (/Applications/Atom.app/Contents/Resources/app/src/package.js:565:9)
<unknown> (/Applications/Atom.app/Contents/Resources/app/src/package.js:187:43)

Quotes inside C blocks passed to ffi.cdef breaks the highlighter

This seems to only happen if the quote is inside a C block scope itself.

The quote is interpreted as opening a new string and the rest of the file is highlighted as a string, even after the call to ffi.cdef ends.

Here is a snippet that should reproduce the issue:

ffi.cdef [[ 
int i = 42; // ' this one is OK.
enum test
{
    FOO, // ' this one is KO.
    BAR
};
]]

local baz

Ideally the quote should be ignored as it's inside the multiline string.

Failed to load a language-lua package grammar

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.9.9
System: Ubuntu 16.04.1
Thrown From: language-lua package, v0.9.11

Stack Trace

Failed to load a language-lua package grammar

At Grammar missing required scopeName property: /home/vycktorstark/.atom/packages/language-lua/grammars/lua.cson in /home/vycktorstark/.atom/packages/language-lua/grammars/lua.cson

Error: Grammar missing required scopeName property: /home/vycktorstark/.atom/packages/language-lua/grammars/lua.cson
    at /usr/share/atom/resources/app.asar/node_modules/first-mate/lib/grammar-registry.js:122:64
    at /usr/share/atom/resources/app.asar/node_modules/season/lib/cson.js:180:53
    at tryToString (fs.js:414:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12)
  at /home/vycktorstark/.atom/packages/language-lua/grammars/lua.cson:1:1

Commands

Config

{
  "core": {
    "themes": [
      "atom-material-ui",
      "atom-material-syntax"
    ]
  }
}

Installed Packages

# User
atom-material-syntax, v0.4.6 (active)
atom-material-ui, v1.3.3 (active)
chary-tree-view, v0.2.3 (active)
language-lua, v0.9.11 (inactive)
linter, v1.11.16 (active)
linter-lua, v1.0.2 (active)
minimap, v4.24.7 (active)
minimap-autohide, v0.10.1 (active)
minimap-git-diff, v4.3.1 (active)
minimap-linter, v1.1.1 (active)
selection-highlight, v0.1.5 (active)
atom-dark-syntax, v0.27.0 (inactive)
atom-dark-ui, v0.51.0 (inactive)
atom-light-syntax, v0.28.0 (inactive)
atom-light-ui, v0.43.0 (inactive)
base16-tomorrow-dark-theme, v1.1.0 (inactive)
base16-tomorrow-light-theme, v1.1.1 (inactive)
one-dark-ui, v1.3.2 (inactive)
one-light-ui, v1.3.2 (inactive)
one-dark-syntax, v1.2.0 (inactive)
one-light-syntax, v1.2.0 (inactive)
solarized-dark-syntax, v1.0.2 (inactive)
solarized-light-syntax, v1.0.2 (inactive)
about, v1.5.2 (active)
archive-view, v0.61.1 (active)
autocomplete-atom-api, v0.10.0 (active)
autocomplete-css, v0.11.1 (active)
autocomplete-html, v0.7.2 (active)
autocomplete-plus, v2.31.0 (active)
autocomplete-snippets, v1.11.0 (active)
autoflow, v0.27.0 (inactive)
autosave, v0.23.1 (active)
background-tips, v0.26.0 (active)
bookmarks, v0.41.0 (active)
bracket-matcher, v0.82.1 (active)
command-palette, v0.38.0 (inactive)
deprecation-cop, v0.54.1 (active)
dev-live-reload, v0.47.0 (active)
encoding-selector, v0.22.0 (active)
exception-reporting, v0.39.0 (active)
fuzzy-finder, v1.3.0 (active)
git-diff, v1.1.0 (active)
find-and-replace, v0.198.0 (inactive)
go-to-line, v0.31.0 (inactive)
grammar-selector, v0.48.1 (active)
image-view, v0.58.0 (active)
incompatible-packages, v0.26.1 (active)
keybinding-resolver, v0.35.0 (active)
line-ending-selector, v0.5.0 (active)
link, v0.31.1 (inactive)
markdown-preview, v0.158.1 (active)
metrics, v0.53.1 (active)
notifications, v0.64.1 (active)
open-on-github, v1.2.0 (inactive)
package-generator, v1.0.0 (inactive)
settings-view, v0.238.2 (active)
snippets, v1.0.2 (active)
spell-check, v0.67.1 (active)
status-bar, v1.4.1 (active)
styleguide, v0.47.1 (active)
symbols-view, v0.113.0 (inactive)
tabs, v0.98.1 (active)
timecop, v0.33.1 (active)
tree-view, v0.208.0 (active)
update-package-dependencies, v0.10.0 (active)
welcome, v0.34.0 (active)
whitespace, v0.32.2 (active)
wrap-guide, v0.38.1 (active)
language-c, v0.52.1 (active)
language-clojure, v0.21.0 (active)
language-coffee-script, v0.47.0 (active)
language-csharp, v0.12.1 (active)
language-css, v0.36.2 (active)
language-gfm, v0.86.0 (active)
language-git, v0.13.0 (active)
language-go, v0.42.0 (active)
language-html, v0.44.1 (active)
language-hyperlink, v0.16.0 (active)
language-java, v0.22.0 (active)
language-javascript, v0.119.0 (active)
language-json, v0.18.0 (active)
language-less, v0.29.3 (active)
language-make, v0.22.2 (active)
language-mustache, v0.13.0 (active)
language-objective-c, v0.15.1 (active)
language-perl, v0.35.0 (active)
language-php, v0.37.0 (active)
language-property-list, v0.8.0 (active)
language-python, v0.45.0 (active)
language-ruby, v0.68.5 (active)
language-ruby-on-rails, v0.25.0 (active)
language-sass, v0.52.0 (active)
language-shellscript, v0.22.3 (active)
language-source, v0.9.0 (active)
language-sql, v0.21.1 (active)
language-text, v0.7.1 (active)
language-todo, v0.28.0 (active)
language-toml, v0.18.0 (active)
language-xml, v0.34.8 (active)
language-yaml, v0.26.0 (active)

# Dev
No dev packages

end in function name

Expected ident:

function Tend()
    -- code
end

Actual result:

function Tend()
-- code
end

As you can see, the code is not idented correctly inside the function.
This bug occurs when formatting or writing code normally.
I used this, but that just uses core functionality.
The reason seems to be the end in the function name. Using capital E for example does not have the same effect.
It does not matter where the word end is in the function name. For example the following doesnt work: local function SomeTable.TestTendIdent(args)

Additionally code in other places similarily behaves incorrectly for identation.
For example code in strings: local a = "this idents next line : do"

  • Atom version: 0.190.0
  • package version: 0.1.0
  • OS: windows 7

Auto Indent On Paste does not handle elseif well.

just create an Lua file with the follow contents, copy and paste the whole test() function code:

-- test.lua
function test()
    if a then
    elseif b then
    elseif c then
    elseif d then
    elseif e then
    end
end

Doesn't detect files with shebang

Atom won't detect files that don't have the extension '.lua' even if the file begins with a lua shebang.

If a file begins with
#!/usr/bin/lua5
#!/usr/bin/lua5.1
#!/usr/bin/lua5.2
etc., Atom should detect it and provide syntax highlighting, the same way it does for a Python file with the shebang
#!/usr/bin/python3

Properly highlight goto

local i = 0
::somelabel::
print("Hello")
i = i + 1
if i < 10 then
  goto somelabel
end

In this example, neither the label definition nor the goto statement are being highlighted. It would be nice if they were. For the label definition, the colons and the label name should probably be highlighted differently.

Highlight global variables

It would be nice if global variables had a different color than local variables, or at least if there was an option to configure a color for them. Not sure if the syntax theme has any influence in this.

v0.9.7 is not in the Atom package registry

Hi,

I've noticed that version 0.9.7 of this package has been tagged but is not present in the Atom package repository (i.e., apm install language-lua installs v0.9.4 of this package as it's the latest version of the package in the Atom package registry). Guessing you's haven't been using apm publish patch to publish the releases since 0.9.4?

Thanks for your time,
Brenton

breaking line indenting error

if age > config:get_max_age( id,
CONFIG.AGE ) then
end

should be

if age > config:get_max_age( id,
CONFIG.AGE ) then
end

solved:edit language-lua.cson
'.source.lua':
'editor':
'commentStart': '-- '
'increaseIndentPattern': '^\s_(else|elseif|for|(local\s+)?function|if|repeat|until|while)\b((?!end).)$|{\s$|([\s\S]$'
'decreaseIndentPattern': '^\s
(elseif|else|end|until,?|})?)._$|^)$'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.