Skip to content

Commit 2b65d08

Browse files
Syntax highlighting improvements (#259)
* Use base syntax highlighting for normal variables Allows constants to be coloured * Update changelog * some highlighting file updates
1 parent 72973c6 commit 2b65d08

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ local y = tbl.data -- Should give "This is some special information"
4747
- Luau analyze now exits with code 0 if there are no reported errors (all errors are ignored)
4848
- `require(instance:FindFirstChild("Testing", true))` will no longer resolve as an immediate child of instance due to the recursive argument
4949
- Fixed a bug where internally the wrong pointer to an Instance type was being used for DM nodes which manifested into failed unification and `never` types
50+
- Constant variables will now be syntax highlighted appropriately at definition site (`local CONSTANT`)
5051

5152
## [1.14.3] - 2022-12-10
5253

editors/code/syntaxes/lua.tmLanguage.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,15 @@
384384
"name": "punctuation.definition.interpolated-string-expression.end.lua"
385385
}
386386
},
387+
"patterns": [
388+
{
389+
"include": "#expression"
390+
}
391+
],
392+
"name": "meta.template.expression.lua",
393+
"contentName": "meta.embedded.line.lua"
394+
},
395+
"expression": {
387396
"patterns": [
388397
{
389398
"include": "#keywords"
@@ -406,9 +415,7 @@
406415
{
407416
"include": "#identifier"
408417
}
409-
],
410-
"name": "meta.template.expression.lua",
411-
"contentName": "meta.embedded.line.lua"
418+
]
412419
},
413420
"identifier": {
414421
"patterns": [
@@ -533,14 +540,10 @@
533540
},
534541
"patterns": [
535542
{
536-
"include": "source.lua"
543+
"include": "#expression"
537544
}
538545
]
539546
},
540-
{
541-
"match": "\\b(readonly)\\b",
542-
"name": "storage.modifier.readonly.lua"
543-
},
544547
{
545548
"match": "\\btrue\\b",
546549
"name": "constant.language.boolean.true.lua"

src/operations/SemanticTokens.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ struct SemanticTokensVisitor : public Luau::AstVisitor
166166
{
167167
auto followedTy = Luau::follow(*ty);
168168
auto type = inferTokenType(&followedTy, lsp::SemanticTokenTypes::Variable);
169+
if (type == lsp::SemanticTokenTypes::Variable)
170+
return true; // No special semantic token needed, fall back to syntax highlighting
169171
tokens.emplace_back(SemanticToken{var->location.begin, var->location.end, type, lsp::SemanticTokenModifiers::None});
170172
}
171173
}

0 commit comments

Comments
 (0)