linguist icon indicating copy to clipboard operation
linguist copied to clipboard

Add Luau language

Open robloxiandemo opened this issue 1 year ago • 25 comments

Description

Resolving this issue, this PR aims to finally add Luau support to the platform.

Checklist:

  • [x] I am adding a new language.
    • [x] The extension of the new language is used in hundreds of repositories on GitHub.com.
      • Search results for each extension:
    • [x] I have included a real-world usage sample for all extensions added in this PR:
      • Sample source(s) [MODIFIED]:
      • Sample license(s) [MODIFIED]:
        • createProcessor.luau - (https://github.com/vinum-team/Vinum/blob/b80a6c194e6901f9d400968293607218598e1386/LICENSE) MIT
        • createSignal.luau - (https://github.com/Floral-Abyss/recs/blob/master/LICENSE.md) MIT
        • equals.luau - (https://github.com/vinum-team/Vinum/blob/b80a6c194e6901f9d400968293607218598e1386/LICENSE) MIT
        • isEmpty.luau - (https://github.com/duckarmor/Freeze/blob/670bb6593d8cc54cdcbb96cd94d1273ee0420abb/LICENSE) MIT
        • none.luau - (https://github.com/duckarmor/Freeze/blob/670bb6593d8cc54cdcbb96cd94d1273ee0420abb/LICENSE) MIT
        • replaceMacros.luau - (https://github.com/grilme99/Flow/blob/973ac39fe52de9ec9407d7ae3d9ab62867b9e982/LICENSE-Brooke) MIT
        • timeStepper.luau - (https://github.com/Floral-Abyss/recs/blob/master/LICENSE.md) MIT
        • toSet.luau - (https://github.com/duckarmor/Freeze/blob/670bb6593d8cc54cdcbb96cd94d1273ee0420abb/LICENSE) MIT
        • ~signal.luau - (https://github.com/highlightjs/highlightjs-luau) MIT~
        • ~vector.luau - (https://github.com/RobloxianDemo/Roblox-Modules) MIT~
    • [x] I have included a syntax highlighting grammar:
      • https://github.com/JohnnyMorganz/Luau.tmLanguage – MIT
    • [x] I have added a color:
      • Hex value: #14a5ff
      • Rationale: Logo color from https://luau-lang.org/ at the time of writing.
    • [x] I have updated the heuristics to distinguish my language from others using the same extension.

robloxiandemo avatar Nov 11 '23 08:11 robloxiandemo

Hey! I'd like to ask if a CI could be ran for this, as I wasn't able to check it myself under the fork.

robloxiandemo avatar Nov 11 '23 08:11 robloxiandemo

I strongly support including support for Luau, which for context is an open-source Lua 5.1 fork, with many backward-compatible features (and therefore syntax) changes built onto it over the years.

With that being said, I do think it's worth noting that Vector3 (or any other Roblox types/globals) probably shouldn't be included in this. Standalone Luau has no built-in Vector3 type or globals such as game, this seems largely out of scope.

moo1210 avatar Nov 11 '23 10:11 moo1210

I'll be going through to fix up my commits with your suggested changes, thank you!

robloxiandemo avatar Nov 11 '23 16:11 robloxiandemo

I strongly support including support for Luau, which for context is an open-source Lua 5.1 fork, with many backward-compatible features (and therefore syntax) changes built onto it over the years.

With that being said, I do think it's worth noting that Vector3 (or any other Roblox types/globals) probably shouldn't be included in this. Standalone Luau has no built-in Vector3 type or globals such as game, this seems largely out of scope.

I will say that it seems the larger scope of usage of Luau is under the Roblox platform.

robloxiandemo avatar Nov 11 '23 17:11 robloxiandemo

I strongly support including support for Luau, which for context is an open-source Lua 5.1 fork, with many backward-compatible features (and therefore syntax) changes built onto it over the years. With that being said, I do think it's worth noting that Vector3 (or any other Roblox types/globals) probably shouldn't be included in this. Standalone Luau has no built-in Vector3 type or globals such as game, this seems largely out of scope.

I will say that it seems the larger scope of usage of Luau is under the Roblox platform.

I agree with this, better have them just in case.

phoriah avatar Nov 14 '23 12:11 phoriah

    * Hex value: `#14a5ff`
    * Rationale: Logo color from https://luau-lang.org/ at the time of writing.

Any chance you could update the color to #479df9 ? Not sure where you got yours from image image

phoriah avatar Nov 14 '23 12:11 phoriah

@RobloxianDemo

phoriah avatar Nov 14 '23 12:11 phoriah

    * Hex value: `#14a5ff`
    * Rationale: Logo color from https://luau-lang.org/ at the time of writing.

Any chance you could update the color to #479df9 ? Not sure where you got yours from image image

Sure, I'll submit a commit for this now.

robloxiandemo avatar Nov 14 '23 16:11 robloxiandemo

    * Hex value: `#14a5ff`
    * Rationale: Logo color from https://luau-lang.org/ at the time of writing.

Any chance you could update the color to #479df9 ? Not sure where you got yours from image image

Resolved here, thank you for your contribution!

robloxiandemo avatar Nov 14 '23 17:11 robloxiandemo

I do hate to add to the color debate, but neither of those colors is correct for the logo. The logo uses #00A2FF:

https://github.com/luau-lang/site/blob/c4e26ca38e3d075a365f548951f05a9be0eda345/logo.svg?short_path=5525394#L2

lewisakura avatar Nov 17 '23 08:11 lewisakura

I do hate to add to the color debate, but neither of those colors is correct for the logo. The logo uses #00A2FF:

https://github.com/luau-lang/site/blob/c4e26ca38e3d075a365f548951f05a9be0eda345/logo.svg?short_path=5525394#L2

Haha, thank you for pointing that out, I'll write up a commit later today to resolve that. 👍

robloxiandemo avatar Nov 17 '23 19:11 robloxiandemo

I do hate to add to the color debate, but neither of those colors is correct for the logo. The logo uses #00A2FF:

https://github.com/luau-lang/site/blob/c4e26ca38e3d075a365f548951f05a9be0eda345/logo.svg?short_path=5525394#L2

Resolved here, thank you for your contribution!

robloxiandemo avatar Nov 17 '23 19:11 robloxiandemo

Seems we'll have to make some changes with the grammar. I'll try to submit a few PRs later this week to resolve it.

robloxiandemo avatar Nov 26 '23 21:11 robloxiandemo

Seems we'll have to make some changes with the grammar. I'll try to submit a few PRs later this week to resolve it.

Really? The current test failures aren't due to the grammar… they're ordering issues.

lildude avatar Nov 27 '23 06:11 lildude

Seems we'll have to make some changes with the grammar. I'll try to submit a few PRs later this week to resolve it.

Really? The current test failures aren't due to the grammar… they're ordering issues.

I ran some private tests with the grammar shortly after seeing those failures, and eleven errors had shown up, apparently due to some backtracking issues with the language. I'd have to check out what's causing it, though I'm not entirely sure.

robloxiandemo avatar Nov 27 '23 17:11 robloxiandemo

Pinging the people from the issue to hopefully aid & speed up the process.

@checkraisefold @RBXTyler @MaximumADHD

Sorry in advance!

phoriah avatar Dec 06 '23 10:12 phoriah

I ran some private tests with the grammar shortly after seeing those failures, and eleven errors had shown up, apparently due to some backtracking issues with the language. I'd have to check out what's causing it, though I'm not entirely sure.

I see it now. It's because of the new/NewLuau.YAML-tmLanguage file. Linguist isn't fussy about the location of the *.YAML-tmLanguage files hence it is finding it and attempting to convert it. It doesn't look like this file is intended to be used yet so the best thing would be for the grammar maintainer to move this file into it's own branch so we can use the main branch without it causing troubles.

lildude avatar Dec 06 '23 12:12 lildude

It's because of the new/NewLuau.YAML-tmLanguage file. Linguist isn't fussy about the location of the *.YAML-tmLanguage files hence it is finding it and attempting to convert it. It doesn't look like this file is intended to be used yet so the best thing would be for the grammar maintainer to move this file into it's own branch so we can use the main branch without it causing troubles.

@JohnnyMorganz

phoriah avatar Dec 06 '23 13:12 phoriah

Please open a PR to delete it! I would be happy to accept. Must have accidentally been committed. I don't have suitable access to do it myself right now.

Although when I last tried to add to linguist locally I also experienced issues where the linguist TextMate grammar parser does not support non-fixed lookbehind (whilst VSCode does). Would be awesome to see if it works though! (Removing the non-fixed lookbehind requires non trivial amounts of effort so I did not get round to it)

JohnnyMorganz avatar Dec 06 '23 18:12 JohnnyMorganz

This seems more like a parsing issue, which happens regardless of which yaml file exists.

- [ ] repository `vendor/grammars/Luau.tmLanguage` (from https://github.com/moo1210/Luau.tmLanguage.git) (10 errors)
  - Invalid regex in grammar: `source.luau` (in `Luau.YAML-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.YAML-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.YAML-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.YAML-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.YAML-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.YAML-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.YAML-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.YAML-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.YAML-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.YAML-tmLanguage`) contains a malformed regex (regex "`(?<![:>.]\s*)\b([a-zA-Z_]\w*)\b`": lookbehind assertion is not fixed length (at offset 12))

moo1210 avatar Dec 07 '23 03:12 moo1210

Although when I last tried to add to linguist locally I also experienced issues where the linguist TextMate grammar parser does not support non-fixed lookbehind (whilst VSCode does)

If it helps, this is because the highlighting engine uses PCRE for performance reasons and as such the compiler enforces the PCRE rules.

lildude avatar Dec 07 '23 07:12 lildude

Yup that's fair, same errors that I see.

The grammar in its current state is unsuitable. Fixing the grammar will require some considerable changes to make it compatible (it may even be simpler to just rewrite it)

JohnnyMorganz avatar Dec 07 '23 09:12 JohnnyMorganz

I believe Luau should be an option for better syntax highlighting supporting types, format strings, etc. and seperating Roblox projects from normal Lua projects in trending or search.

AsynchronousAI avatar Jan 04 '24 01:01 AsynchronousAI

The grammar in its current state is unsuitable. Fixing the grammar will require some considerable changes to make it compatible (it may even be simpler to just rewrite it)

Any updates on this? Would be SUPER cool to have luau support in discovery and syntax highlighting.

CompeyDev avatar Jan 23 '24 18:01 CompeyDev

Any updates on this?

Nope, unfortunately I don't have the time to work on that grammar right now. Contributions welcome!

JohnnyMorganz avatar Jan 23 '24 18:01 JohnnyMorganz

I've fixed the grammar so it should now support Linguist. Can you pull latest changes @robloxiandemo?

Also, I expect to still make improvements. I think I already read this somewhere, but just to double check, grammars automatically get updated in the repo (before the next version release)?

JohnnyMorganz avatar Apr 01 '24 13:04 JohnnyMorganz

I've fixed the grammar so it should now support Linguist. Can you pull latest changes @robloxiandemo?

Hey, and good stuff! Although, I have been trying to pull them, though it just refuses to update to the following regex-related error: image

I'm unsure on how or why it's attempting to use the nonexistent "NewLuau.YAML-tmLanguage" file. Any ideas on how I could get around this, or simply to resolve it?

robloxiandemo avatar Apr 03 '24 02:04 robloxiandemo

This file was already deleted. Can you double check the submodule was updated appropriately? What git revision is checked out

JohnnyMorganz avatar Apr 03 '24 08:04 JohnnyMorganz

This file was already deleted. Can you double check the submodule was updated appropriately? What git revision is checked out

I checked and it seems to be pulling this as the latest revision, a bit stumped on how to get around this to retrieve the repo's latest commit. Screenshot 2024-04-03 063236

robloxiandemo avatar Apr 03 '24 10:04 robloxiandemo

I found a workaround to the issue and have updated the submodule to the latest commit, I just have to avoid trying to update it through the script, as it seems to fetch the old commit as the head, rather than the latest one.

robloxiandemo avatar Apr 03 '24 11:04 robloxiandemo