GithubHelp home page GithubHelp logo

luau.tmlanguage's Introduction

Hey there ๐Ÿ‘‹

I'm a Computer Science student with a passion for creating software which empowers others, from tooling to help developers, to wide-ranging software to help anyone! Online, I go by the pseudonym Johnny (not my real name!).

  • ๐Ÿ”ญ I'm currently working on StyLua, a Lua code formatter to ease the burden of style review.
  • โšก I love working on different kinds of software, ranging from command line tools to video games.

๐Ÿ“ซ You can reach me at [email protected]

JohnnyMorganz's GitHub stats Top Languages

luau.tmlanguage's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

moo1210 dekkonot

luau.tmlanguage's Issues

Syntax highlighting inconsistencies

Constants are not colored as such when declared, only when used:

-- Variable name is colored as a normal variable
local CONSTANT = 0

-- But colored as a constant here
local var = CONSTANT + 1

Redefined builtins are still colored as builtins:

-- This has the correct coloring
local settings = {
	Foo = "Bar",
}

-- This is colored as a builtin
local bar = settings.Foo

Syntax highlight within typeof(...) is not consistent with highlight outside of typeof:

local function returnsComplexType()
	return {} :: { [string]: { number } }
end

-- Key and [1] both have incorrect highlighting
type Inner = typeof(returnsComplexType().Key[1])

-- This has correct highlighting
local inner = returnsComplexType().Key[1]

Tested with semantic highlighting and Roblox types enabled.

VSCode keyword highlighting bug

Here is the example code showing the bug:

local numbers = {}
for k, v in numbers :: any do
  print(k, v)
end

image

In my screenshot, do should be purple like the other keywords, but it's green.

Syntax highlighting breaks in vscode

minimal reproduction

export type A = {
    LOL: "yes",
}

local a: xd.Something<{
    transparency: typeof(React.createBinding(0))
}> = function()

end

local c: xd.Something<{
    transparency: typeof(React.createBinding(0)), -- this comma is the reason why it diess!!
}> = function() -- it dies
    local a = "hello world"
end

vscode
image
roblox studio
image

Any Chance you Can Fix these?

I'm currently trying to submit pull request with .luau as a language to linguist and encountering these issues when adding grammar:

11 errors found in new grammar 'repository vendor/grammars/Luau.tmLanguage (from https://github.com/JohnnyMorganz/Luau.tmLanguage.git)':

  • Grammar conversion failed. File new/NewLuau.YAML-tmLanguage failed to parse: 1 error(s) decoding:
  • 'Repository[identifiers]' expected a map, got 'slice'
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b_\b": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b([A-Z_][A-Z0-9_]*...": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b([a-zA-Z_]\w*)\b": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b_\b": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b([A-Z_][A-Z0-9_]*...": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b([a-zA-Z_]\w*)\b": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<!:\s*|->\s*)\b([a-zA-Z_]\w*)\...": lookbehind assertion is not fixed length (at offset 8))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b_\b": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b([A-Z_][A-Z0-9_]*...": lookbehind assertion is not fixed length (at offset 12))
  • Invalid regex in grammar: source.luau (in Luau.tmLanguage) contains a malformed regex (regex "(?<![:>.]\s*)\b([a-zA-Z_]\w*)\b": lookbehind assertion is not fixed length (at offset 12))

image

Using typeof to type a function parameter breaks highlighting

When declaring a function, using typeof(something) to type one of the parameters breaks the highlighting.
This does not occur in Studio.
While appearing minor here, depending on the theme settings, it can look a lot worse.

Broken highlighting:

local x: any
x.foo = 20

local function func(header: typeof(Instance.new("Humanoid"))) end

local y: any
y.foo = 10

image

Correct highlighting:

local x: any
x.foo = 20

local function func(header: string) end

local y: any
y.foo = 10

image

Doesn't load with Sublime Text

When trying to load the .tmlanguage, I get this error in the console:

error parsing lexer: Packages/Luau.tmlanguage/Luau.tmLanguage: Unexpected capture value

Incorrect highlighting when symbol "type" is followed by ~=

As seen in the following examples, the syntax highlighting seems to take an unusual turn following "type" when followed by a ~= operator. Both are valid syntax as type is not a reserved word. This happens with or without semantic highlighting for me.

image
image

Improved syntax highlighting for types with "where" in hovers

Generic types in hovers sometimes get expanded like this:

local foo: t2 where t1 = {
    Connect: (self: t1) -> boolean,
    Destroy: (self: t1) -> boolean,
    Disconnect: (self: t1) -> boolean
} ; t2 = {
    Bar: t1,
}

It seems like the where breaks syntax highlighting here

Syntax highlighting can escape markdown comments if the comment includes a Lua code block with a syntax error

Example, caused by a missing parentheses:

https://gist.github.com/Corecii/5f782eb3767a67e8b7f5e39f614c3574

image

(I can't embed the snippet here since we can't nest code blocks inside each other.)

Conveniently this shows on Github as well, since Github has Luau support now via this very language definition! How nice!


I'm assuming this is a Luau.tmLanguage issue because it first appeared in luau-lsp 1.29.0

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.