Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Luau language #6612

Merged
merged 34 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7febf72
Feature: Add `Luau` language.
robloxiandemo Nov 11, 2023
912f57c
Featire: Add `Luau` code samples.
robloxiandemo Nov 11, 2023
81be622
Feature: Add the grammar.
robloxiandemo Nov 11, 2023
77339ab
Feature: Add `Luau` to grammar index.
robloxiandemo Nov 11, 2023
428f5d2
Fix: Add comment block and change the interpreter.
robloxiandemo Nov 11, 2023
1eced93
Feature: Add new samples in place of the old ones.
robloxiandemo Nov 12, 2023
c0dd82e
Patch: Slight typo in the header.
robloxiandemo Nov 12, 2023
a3a4286
Patch: Header typos again, I'm such a genius.
robloxiandemo Nov 12, 2023
ba342d6
Patch: Introduce the languageId.
robloxiandemo Nov 12, 2023
7463c5f
Patch: Resolve grammar conflict.
robloxiandemo Nov 12, 2023
f55cbc5
Patch: Resolve grammar conflict.
robloxiandemo Nov 12, 2023
b99f319
Patch: Update the hex value.
robloxiandemo Nov 14, 2023
92bed6f
Patch: Update the hex value.
robloxiandemo Nov 17, 2023
3ae7360
Sort
lildude Dec 6, 2023
5f21201
Patch: Update the submodule to the latest commit.
robloxiandemo Apr 3, 2024
405f7e4
Patch: Resolve merge conflicts.
robloxiandemo Apr 3, 2024
f0db075
Patch: Resolve further conflicts.
robloxiandemo Apr 3, 2024
3588fea
Patch: Remove conflict.
robloxiandemo Apr 4, 2024
f5eaf45
Patch: Reintroduce Luau into grammar index.
robloxiandemo Apr 4, 2024
1173698
Revert "Patch: Reintroduce Luau into grammar index."
robloxiandemo Apr 4, 2024
ec33c7d
Merge branch 'github-linguist:master' into master
robloxiandemo Apr 4, 2024
4d4b3eb
Patch: Retry resolving the conflict issue.
robloxiandemo Apr 4, 2024
afcdb27
Update vendor/licenses/git_submodule/Luau.tmLanguage.dep.yml
lildude Apr 5, 2024
d005379
Enhancement: Update old samples and their sources.
robloxiandemo Apr 5, 2024
2f9a8a2
Patch: Update old samples and their sources.
robloxiandemo Apr 6, 2024
6f5e853
Merge branch 'master' of https://github.com/robloxiandemo/linguist
robloxiandemo Apr 6, 2024
deb5f00
Patch: Update old samples and their sources.
robloxiandemo Apr 6, 2024
e3f8ba2
Merge branch 'master' of https://github.com/robloxiandemo/linguist
robloxiandemo Apr 6, 2024
f80ee08
Patch: Update old samples and their sources.
robloxiandemo Apr 6, 2024
0c0382a
Merge branch 'master' of https://github.com/robloxiandemo/linguist
robloxiandemo Apr 6, 2024
8fa4f1f
Patch: Update the samples further.
robloxiandemo Apr 6, 2024
481ae46
Revert "Patch: Update old samples and their sources."
robloxiandemo May 1, 2024
7bfe7ca
Test: New samples, sadly one source.
robloxiandemo May 1, 2024
b363c0c
Merge branch 'master' into master
lildude Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@
[submodule "vendor/grammars/lua.tmbundle"]
path = vendor/grammars/lua.tmbundle
url = https://github.com/textmate/lua.tmbundle
[submodule "vendor/grammars/Luau.tmLanguage"]
path = vendor/grammars/Luau.tmLanguage
url = https://github.com/JohnnyMorganz/Luau.tmLanguage.git
[submodule "vendor/grammars/m3"]
path = vendor/grammars/m3
url = https://github.com/newgrammars/m3
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ vendor/grammars/logtalk.tmbundle:
- source.logtalk
vendor/grammars/lua.tmbundle:
- source.lua
vendor/grammars/Luau.tmLanguage:
- source.luau
vendor/grammars/m3:
- source.modula-3
vendor/grammars/make.tmbundle:
Expand Down
12 changes: 12 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3879,6 +3879,18 @@ Lua:
interpreters:
- lua
language_id: 213
Luau:
type: programming
tm_scope: source.luau
ace_mode: lua
codemirror_mode: lua
codemirror_mime_type: text/x-lua
color: "#00A2FF"
extensions:
- ".luau"
interpreters:
- luau
language_id: 365050359
M:
type: programming
aliases:
Expand Down
22 changes: 22 additions & 0 deletions samples/Luau/createProcessor.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--// Authored by @sinlerdev (https://github.com/sinlerdev)
--// Fetched from (https://github.com/vinum-team/Vinum/blob/b80a6c194e6901f9d400968293607218598e1386/src/Utils/createProcessor.luau)
--// Licensed under the MIT License (https://github.com/vinum-team/Vinum/blob/b80a6c194e6901f9d400968293607218598e1386/LICENSE)

--!strict
local function createProcessor(valueChecker: (a: any, b: any) -> boolean, cleaner: (taskItem: any) -> ())
return function<T>(old: T, new: T, isDestroying: boolean)
if isDestroying then
cleaner(old)
return false
end

if valueChecker(old, new) then
return false
end

cleaner(old)
return true
end
end

return createProcessor
37 changes: 37 additions & 0 deletions samples/Luau/createSignal.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--// Authored by @AmaranthineCodices (https://github.com/AmaranthineCodices)
--// Fetched from (https://github.com/Floral-Abyss/recs/blob/be123afef8f1fddbd9464b7d34d5178393601ae3/recs/createSignal.luau)
--// Licensed under the MIT License (https://github.com/Floral-Abyss/recs/blob/master/LICENSE.md)

--!strict

local function createSignal()
local listeners = {}
local signal = {}

function signal:Connect(listener)
listeners[listener] = true

local connection = {
Connected = true,
}

function connection.Disconnect()
connection.Connected = false
listeners[listener] = nil
end
connection.disconnect = connection.Disconnect

return connection
end
signal.connect = signal.Connect

local function fire(...)
for listener, _ in pairs(listeners) do
spawn(listener, ...)
end
end

return signal, fire
end

return createSignal
17 changes: 17 additions & 0 deletions samples/Luau/equals.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--// Authored by @sinlerdev (https://github.com/sinlerdev)
--// Fetched from (https://github.com/vinum-team/Vinum/blob/b80a6c194e6901f9d400968293607218598e1386/src/Utils/equals.luau)
--// Licensed under the MIT License (https://github.com/vinum-team/Vinum/blob/b80a6c194e6901f9d400968293607218598e1386/LICENSE)

--!strict

local function equals(a: any, b: any): boolean
-- INFO: Vinum doesn't officially support immutability currently- so, we just assume
-- that every new table entry is not equal. See issue 26
if type(a) == "table" then
return false
end

return a == b
end

return equals
21 changes: 21 additions & 0 deletions samples/Luau/isEmpty.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--// Authored by @benbrimeyer (https://github.com/benbrimeyer)
--// Fetched from (https://github.com/duckarmor/Freeze/blob/670bb6593d8cc54cdcbb96cd94d1273ee0420abb/source/isEmpty.luau)
--// Licensed under the MIT License (https://github.com/duckarmor/Freeze/blob/670bb6593d8cc54cdcbb96cd94d1273ee0420abb/LICENSE)

--!strict
--[=[
Returns true if the collection is empty.

```lua
Freeze.isEmpty({})
-- true
```

@within Freeze
@function isEmpty
@return boolean
]=]

return function(collection)
return next(collection) == nil
end
21 changes: 21 additions & 0 deletions samples/Luau/none.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--// Authored by @benbrimeyer (https://github.com/benbrimeyer)
--// Fetched from (https://github.com/duckarmor/Freeze/blob/670bb6593d8cc54cdcbb96cd94d1273ee0420abb/source/None.luau)
--// Licensed under the MIT License (https://github.com/duckarmor/Freeze/blob/670bb6593d8cc54cdcbb96cd94d1273ee0420abb/LICENSE)

--[=[
@prop None None
@within Freeze

Since lua tables cannot distinguish between values not being present and a value of nil,
`Freeze.None` exists to represent values that should be interpreted as `nil`.

This is useful when removing values with functions such as [`Freeze.Dictionary.merge`](../api/Dictionary#merge).
]=]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lildude: based on your comment on #6616, should the tokenizer be taught about --[[ ]] and --[====[/]====] comments? Or is that only necessary if there are extension ambiguities?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably no harm in adding support for this format but it only really comes into play when there are extension ambiguities.


local None = newproxy(true)

getmetatable(None).__tostring = function()
return "Freeze.None"
end

return None
Loading