Skip to content

Commit f5c7a97

Browse files
committed
Syntax support for singleton types, fix #141
1 parent 09f8174 commit f5c7a97

File tree

7 files changed

+22
-4
lines changed

7 files changed

+22
-4
lines changed

client/out/extension.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/out/extension.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ async function openUpdatesWindow(context: vscode.ExtensionContext) {
8686
<p style="font-size:1rem">Report any bug or question here: <a href="https://github.com/NightrainsRbx/RobloxLsp/issues">https://github.com/NightrainsRbx/RobloxLsp/issues</a></p>
8787
<hr style="height:2px;border:none;color:#333;background-color:#333;"/>
8888
<h2 style="font-size:2rem; font-weight:100">v1.5.6</h2>
89-
<li style="font-size:1rem">Improved syntax support for Luau and added basic support for type packs.</li>
89+
<li style="font-size:1rem">Improved syntax support for Luau.</li>
90+
<li style="font-size:1rem">Added basic syntax support for generic type packs and singleton types.</li>
9091
<li style="font-size:1rem">Implemented suggeted imports for modules (thanks to <a href="https://github.com/Corecii">@Corecii</a>, <a href="https://github.com/NightrainsRbx/RobloxLsp/pull/123">#123</a>)</li>
9192
<li style="font-size:1rem">Added Vector3 constants (thanks to <a href="https://github.com/aku-e">@aku-e</a>, <a href="https://github.com/NightrainsRbx/RobloxLsp/pull/145">#145</a>)</li>
9293
<li style="font-size:1rem">Color3.fromHex is no longer deprecated.</li>
9394
<li style="font-size:1rem">Fixed deprecated classes not having typings. (<a href="https://github.com/NightrainsRbx/RobloxLsp/issues/147">#147</a>)</li>
9495
<li style="font-size:1rem">Fixed embedded rojo projects not using their correct root name. (<a href="https://github.com/NightrainsRbx/RobloxLsp/issues/128">#128</a>)</li>
9596
<li style="font-size:1rem">Inlay hints are not displayed if the type is "none" or "any".</li>
97+
<li style="font-size:1rem">Fixed diagnostics for type aliases with the same names as built-in types.</li>
9698
<li style="font-size:1rem">Updated binaries.</li>
9799
</div>
98100
</body>

server/script/core/guide.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ m.typeAnnTypes = {
165165
["type.variadic"] = true,
166166
["type.typeof"] = true,
167167
["type.genericpack"] = true,
168+
["type.singleton"] = true,
168169
["type.library"] = true
169170
}
170171

@@ -4714,6 +4715,8 @@ function m.buildTypeAnn(typeUnit, mark)
47144715
text = "..." .. m.buildTypeAnn(typeUnit.value, mark)
47154716
elseif typeUnit.type == "type.typeof" then
47164717
text = "typeof(" .. m.buildExp(typeUnit.value) .. ")"
4718+
elseif typeUnit.type == "type.singleton" then
4719+
text = typeUnit[2] .. typeUnit[1] .. typeUnit[2]:gsub("%[", "]")
47174720
elseif typeUnit.type == "type.meta" then
47184721
text = "{" .. m.buildTypeAnn(typeUnit[1], mark) .. ", @metatable " .. m.buildTypeAnn(typeUnit[2], mark) .. "}"
47194722
elseif typeUnit.type == "paren" then

server/script/parser/ast.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,10 @@ local Defs = {
967967
name.dots = dots
968968
return name
969969
end,
970+
SingletonType = function (str)
971+
str.type = "type.singleton"
972+
return str
973+
end,
970974
NamedType = function (key, colon, value)
971975
value.paramName = key
972976
return value

server/script/parser/grammar.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ TypeUnit <- ModuleType
418418
/ NameType
419419
/ FuncType
420420
/ TableType
421+
/ SingletonType
421422
/ TypeSimple
422423
423424
TypeSimple <- ({| TypePrefix |} Optional?)
@@ -435,7 +436,7 @@ Typeof <- Sp ({} 'typeof' Sp {} PL Exp DirtyPR {} Optional?)
435436
Generics1 <- Sp ({} AL Sp {| (GenericPackType / Name / COMMA)+ |} Sp DirtyAR {})
436437
-> Generics
437438
/ %nil
438-
Generics2 <- Sp ({} AL Sp {| (TypeList / VariadicType / Type / COMMA)* |} Sp DirtyAR {})
439+
Generics2 <- Sp ({} AL Sp {| (VariadicType / Type / TypeList / COMMA)* |} Sp DirtyAR {})
439440
-> Generics
440441
/ %nil
441442
TypeList <- Sp ({} PL {| (VariadicType / Type / COMMA)* |} DirtyPR {})
@@ -457,6 +458,9 @@ VariadicType
457458
GenericPackType
458459
<- Sp (Name DOTS)
459460
-> GenericPackType
461+
SingletonType
462+
<- String
463+
-> SingletonType
460464
461465
FieldType <- Sp ({} Name COLON Type {})
462466
-> FieldType

syntaxes/lua.tmLanguage.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@
549549
},
550550
{
551551
"include": "#comments"
552+
},
553+
{
554+
"include": "#strings"
552555
}
553556
]
554557
},

0 commit comments

Comments
 (0)