Add Luau language by mirsdemo · Pull Request #6612 · github-linguist/linguist · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7febf72
Feature: Add `Luau` language.
mirsdemo Nov 11, 2023
912f57c
Featire: Add `Luau` code samples.
mirsdemo Nov 11, 2023
81be622
Feature: Add the grammar.
mirsdemo Nov 11, 2023
77339ab
Feature: Add `Luau` to grammar index.
mirsdemo Nov 11, 2023
428f5d2
Fix: Add comment block and change the interpreter.
mirsdemo Nov 11, 2023
1eced93
Feature: Add new samples in place of the old ones.
mirsdemo Nov 12, 2023
c0dd82e
Patch: Slight typo in the header.
mirsdemo Nov 12, 2023
a3a4286
Patch: Header typos again, I'm such a genius.
mirsdemo Nov 12, 2023
ba342d6
Patch: Introduce the languageId.
mirsdemo Nov 12, 2023
7463c5f
Patch: Resolve grammar conflict.
mirsdemo Nov 12, 2023
f55cbc5
Patch: Resolve grammar conflict.
mirsdemo Nov 12, 2023
b99f319
Patch: Update the hex value.
mirsdemo Nov 14, 2023
92bed6f
Patch: Update the hex value.
mirsdemo Nov 17, 2023
3ae7360
Sort
lildude Dec 6, 2023
5f21201
Patch: Update the submodule to the latest commit.
Apr 3, 2024
405f7e4
Patch: Resolve merge conflicts.
Apr 3, 2024
f0db075
Patch: Resolve further conflicts.
Apr 3, 2024
3588fea
Patch: Remove conflict.
Apr 4, 2024
f5eaf45
Patch: Reintroduce Luau into grammar index.
Apr 4, 2024
1173698
Revert "Patch: Reintroduce Luau into grammar index."
Apr 4, 2024
ec33c7d
Merge branch 'github-linguist:master' into master
Apr 4, 2024
4d4b3eb
Patch: Retry resolving the conflict issue.
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.
Apr 5, 2024
2f9a8a2
Patch: Update old samples and their sources.
mirsdemo Apr 6, 2024
6f5e853
Merge branch 'master' of https://github.com/robloxiandemo/linguist
mirsdemo Apr 6, 2024
deb5f00
Patch: Update old samples and their sources.
mirsdemo Apr 6, 2024
e3f8ba2
Merge branch 'master' of https://github.com/robloxiandemo/linguist
mirsdemo Apr 6, 2024
f80ee08
Patch: Update old samples and their sources.
mirsdemo Apr 6, 2024
0c0382a
Merge branch 'master' of https://github.com/robloxiandemo/linguist
mirsdemo Apr 6, 2024
8fa4f1f
Patch: Update the samples further.
mirsdemo Apr 6, 2024
481ae46
Revert "Patch: Update old samples and their sources."
mirsdemo May 1, 2024
7bfe7ca
Test: New samples, sadly one source.
mirsdemo 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
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ vendor/grammars/Ligo-grammar:
- source.religo
vendor/grammars/LiveScript.tmbundle:
- source.livescript
vendor/grammars/Luau.tmLanguage:
- source.luau
vendor/grammars/MATLAB-Language-grammar:
- source.matlab
vendor/grammars/MQL5-sublime:
Expand Down
12 changes: 12 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3931,6 +3931,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
116 changes: 116 additions & 0 deletions samples/Luau/EnumList.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
--!optimize 2
--!strict
--!native

--// EnumList v2.1.0
--// Authored by @sleitnick and modified by @robloxiandemo
--// Fetched from (https://github.com/Sleitnick/RbxUtil/blob/main/modules/enum-list/init.lua)
--// Licensed under the MIT License (https://github.com/Sleitnick/RbxUtil/blob/main/LICENSE.md)

type EnumNames = { string }

--[=[
@interface EnumItem
.Name string
.Value number
.EnumType EnumList
@within EnumList
]=]
export type EnumItem = {
Name: string,
Value: number,
EnumType: any,
}

local LIST_KEY = newproxy()
local NAME_KEY = newproxy()

local function makeReadOnly<ITable>(_table: ITable)
return setmetatable({}, {
__index = _table,
__newindex = function()
error("Attempt to modify read-only table", 2)
end,
__metatable = false,
})
end

local function CreateEnumItem(name: string, value: number, enum: any): EnumItem
local enumItem = {
Name = name,
Value = value,
EnumType = enum,
}
makeReadOnly(enumItem)
return enumItem
end

--[=[
@class EnumList
Defines a new Enum.
]=]
local EnumList = {}
EnumList.__index = EnumList

--[=[
@param name string
@param enums {string}
@return EnumList
Constructs a new EnumList.

```lua
local directions = EnumList.new("Directions", {
"Up",
"Down",
"Left",
"Right",
})

local direction = directions.Up
```
]=]
function EnumList.new(name: string, enums: EnumNames)
assert(type(name) == "string", "Name string required")
assert(type(enums) == "table", "Enums table required")
local self = {}
self[LIST_KEY] = {}
self[NAME_KEY] = name
for i, enumName in ipairs(enums) do
assert(type(enumName) == "string", "Enum name must be a string")
local enumItem = CreateEnumItem(enumName, i, self)
self[enumName] = enumItem
table.insert(self[LIST_KEY], enumItem)
end
return makeReadOnly(setmetatable(self, EnumList))
end

--[=[
@param obj any
@return boolean
Returns `true` if `obj` belongs to the EnumList.
]=]
function EnumList:BelongsTo(obj: any): boolean
return type(obj) == "table" and obj.EnumType == self
end

--[=[
Returns an array of all enum items.
@return {EnumItem}
@since v2.0.0
]=]
function EnumList:GetEnumItems()
return self[LIST_KEY]
end

--[=[
Get the name of the enum.
@return string
@since v2.0.0
]=]
function EnumList:GetName()
return self[NAME_KEY]
end

export type EnumList = typeof(EnumList.new(...))

return EnumList
229 changes: 229 additions & 0 deletions samples/Luau/Option.luau
Loading