Skip to content

Commit dac3043

Browse files
authored
feat(tolk): highlight self parameter as keyword (#243)
1 parent ab8af0b commit dac3043

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • server/src/languages/tolk/semantic-tokens

server/src/languages/tolk/semantic-tokens/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ export function provideTolkSemanticTokens(file: TolkFile): SemanticTokens {
114114
const name = n.childForFieldName("name")
115115
if (!name) return true
116116

117+
if (name.endIndex - name.startIndex == 4 && name.text === "self") {
118+
tokens.node(
119+
name,
120+
lsp.SemanticTokenTypes.keyword,
121+
isMutable ? [lsp.SemanticTokenModifiers.modification] : [],
122+
)
123+
return true
124+
}
117125
tokens.node(
118126
name,
119127
lsp.SemanticTokenTypes.parameter,
@@ -132,6 +140,15 @@ export function provideTolkSemanticTokens(file: TolkFile): SemanticTokens {
132140
case "parameter_declaration": {
133141
const isMutable = resolved.node.childForFieldName("mutate") !== null
134142

143+
if (n.endIndex - n.startIndex == 4 && n.text === "self") {
144+
tokens.node(
145+
n,
146+
lsp.SemanticTokenTypes.keyword,
147+
isMutable ? [lsp.SemanticTokenModifiers.modification] : [],
148+
)
149+
return true
150+
}
151+
135152
tokens.node(
136153
n,
137154
lsp.SemanticTokenTypes.parameter,

0 commit comments

Comments
 (0)