diff --git a/Luau.YAML-tmLanguage b/Luau.YAML-tmLanguage
index cc5c789..a0706e3 100644
--- a/Luau.YAML-tmLanguage
+++ b/Luau.YAML-tmLanguage
@@ -33,6 +33,7 @@ patterns:
- include: "#table"
- include: "#type_cast"
- include: "#type_annotation"
+ - include: "#attribute"
repository:
function-definition:
@@ -78,6 +79,7 @@ repository:
"1": { name: storage.modifier.local.luau }
patterns:
- include: "#comment"
+ - include: "#attribute"
- begin: "(:)"
beginCaptures:
"1": { name: keyword.operator.type.luau }
@@ -398,3 +400,12 @@ repository:
"1": { name: variable.parameter.luau }
"2": { name: keyword.operator.type.luau }
- include: "#type_literal"
+
+ attribute:
+ patterns:
+ # TODO: support parameters for attributes as defined in the RFC
+ - name: meta.attribute.luau
+ match: "(@)({{identifier}})"
+ captures:
+ "1": { name: keyword.operator.attribute.luau }
+ "2": { name: storage.type.attribute.luau}
diff --git a/Luau.tmLanguage b/Luau.tmLanguage
index a195a6e..aee4dde 100644
--- a/Luau.tmLanguage
+++ b/Luau.tmLanguage
@@ -86,6 +86,10 @@
include
#type_annotation
+
+ include
+ #attribute
+
repository
@@ -224,6 +228,10 @@
include
#comment
+
+ include
+ #attribute
+
begin
(:)
@@ -1138,6 +1146,31 @@
+ attribute
+
+ patterns
+
+
+ name
+ meta.attribute.luau
+ match
+ (@)([a-zA-Z_][a-zA-Z0-9_]*)
+ captures
+
+ 1
+
+ name
+ keyword.operator.attribute.luau
+
+ 2
+
+ name
+ storage.type.attribute.luau
+
+
+
+
+
\ No newline at end of file
diff --git a/Luau.tmLanguage.json b/Luau.tmLanguage.json
index bbc9c3c..66fdcd6 100644
--- a/Luau.tmLanguage.json
+++ b/Luau.tmLanguage.json
@@ -60,6 +60,9 @@
},
{
"include": "#type_annotation"
+ },
+ {
+ "include": "#attribute"
}
],
"repository": {
@@ -150,6 +153,9 @@
{
"include": "#comment"
},
+ {
+ "include": "#attribute"
+ },
{
"begin": "(:)",
"beginCaptures": {
@@ -749,6 +755,22 @@
]
}
]
+ },
+ "attribute": {
+ "patterns": [
+ {
+ "name": "meta.attribute.luau",
+ "match": "(@)([a-zA-Z_][a-zA-Z0-9_]*)",
+ "captures": {
+ "1": {
+ "name": "keyword.operator.attribute.luau"
+ },
+ "2": {
+ "name": "storage.type.attribute.luau"
+ }
+ }
+ }
+ ]
}
}
}
\ No newline at end of file
diff --git a/tests/baselines/attribute-function-no-param.baseline.txt b/tests/baselines/attribute-function-no-param.baseline.txt
new file mode 100644
index 0000000..ec97855
--- /dev/null
+++ b/tests/baselines/attribute-function-no-param.baseline.txt
@@ -0,0 +1,300 @@
+original file
+-----------------------------------
+@attr_1 @attr_2
+local function a()
+end
+
+local b = @attr_1 @attr_2 function() end
+
+c(@attr_1 @attr_2 function() end)
+
+@attr_1
+local function d()
+end
+
+local e = @attr_1 function() end
+
+f(@attr_1 function() end)
+
+@attr_1 @attr_2 local function g() end
+@attr1 local function h() end
+
+---@doc_comment
+@attr_1
+local function i() end
+-----------------------------------
+
+>@attr_1 @attr_2
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+>local function a()
+ ^^^^^
+ source.luau meta.function.luau storage.modifier.local.luau
+ ^
+ source.luau meta.function.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau
+ ^
+ source.luau meta.function.luau entity.name.function.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+>end
+ ^^^
+ source.luau keyword.control.luau
+>
+ ^
+ source.luau
+>local b = @attr_1 @attr_2 function() end
+ ^^^^^
+ source.luau storage.modifier.local.luau
+ ^
+ source.luau
+ ^
+ source.luau variable.other.readwrite.luau
+ ^
+ source.luau
+ ^
+ source.luau keyword.operator.assignment.luau
+ ^
+ source.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+ ^
+ source.luau
+ ^^^
+ source.luau keyword.control.luau
+>
+ ^
+ source.luau
+>c(@attr_1 @attr_2 function() end)
+ ^
+ source.luau entity.name.function.luau
+ ^
+ source.luau punctuation.arguments.begin.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+ ^
+ source.luau
+ ^^^
+ source.luau keyword.control.luau
+ ^
+ source.luau punctuation.arguments.end.luau
+>
+ ^
+ source.luau
+>@attr_1
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+>local function d()
+ ^^^^^
+ source.luau meta.function.luau storage.modifier.local.luau
+ ^
+ source.luau meta.function.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau
+ ^
+ source.luau meta.function.luau entity.name.function.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+>end
+ ^^^
+ source.luau keyword.control.luau
+>
+ ^
+ source.luau
+>local e = @attr_1 function() end
+ ^^^^^
+ source.luau storage.modifier.local.luau
+ ^
+ source.luau
+ ^
+ source.luau variable.other.readwrite.luau
+ ^
+ source.luau
+ ^
+ source.luau keyword.operator.assignment.luau
+ ^
+ source.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+ ^
+ source.luau
+ ^^^
+ source.luau keyword.control.luau
+>
+ ^
+ source.luau
+>f(@attr_1 function() end)
+ ^
+ source.luau entity.name.function.luau
+ ^
+ source.luau punctuation.arguments.begin.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+ ^
+ source.luau
+ ^^^
+ source.luau keyword.control.luau
+ ^
+ source.luau punctuation.arguments.end.luau
+>
+ ^
+ source.luau
+>@attr_1 @attr_2 local function g() end
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^^^^^
+ source.luau meta.function.luau storage.modifier.local.luau
+ ^
+ source.luau meta.function.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau
+ ^
+ source.luau meta.function.luau entity.name.function.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+ ^
+ source.luau
+ ^^^
+ source.luau keyword.control.luau
+>@attr1 local function h() end
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+ ^
+ source.luau
+ ^^^^^
+ source.luau meta.function.luau storage.modifier.local.luau
+ ^
+ source.luau meta.function.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau
+ ^
+ source.luau meta.function.luau entity.name.function.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+ ^
+ source.luau
+ ^^^
+ source.luau keyword.control.luau
+>
+ ^
+ source.luau
+>---@doc_comment
+ ^^^
+ source.luau comment.line.double-dash.documentation.luau
+ ^^^^^^^^^^^^
+ source.luau comment.line.double-dash.documentation.luau storage.type.class.luadoc.luau
+>@attr_1
+ ^
+ source.luau meta.attribute.luau keyword.operator.attribute.luau
+ ^^^^^^
+ source.luau meta.attribute.luau storage.type.attribute.luau
+>local function i() end
+ ^^^^^
+ source.luau meta.function.luau storage.modifier.local.luau
+ ^
+ source.luau meta.function.luau
+ ^^^^^^^^
+ source.luau meta.function.luau keyword.control.luau
+ ^
+ source.luau meta.function.luau
+ ^
+ source.luau meta.function.luau entity.name.function.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.begin.luau
+ ^
+ source.luau meta.function.luau meta.parameter.luau punctuation.definition.parameters.end.luau
+ ^
+ source.luau
+ ^^^
+ source.luau keyword.control.luau
\ No newline at end of file
diff --git a/tests/cases/attribute-function-no-param.luau b/tests/cases/attribute-function-no-param.luau
new file mode 100644
index 0000000..71ec9e1
--- /dev/null
+++ b/tests/cases/attribute-function-no-param.luau
@@ -0,0 +1,22 @@
+@attr_1 @attr_2
+local function a()
+end
+
+local b = @attr_1 @attr_2 function() end
+
+c(@attr_1 @attr_2 function() end)
+
+@attr_1
+local function d()
+end
+
+local e = @attr_1 function() end
+
+f(@attr_1 function() end)
+
+@attr_1 @attr_2 local function g() end
+@attr1 local function h() end
+
+---@doc_comment
+@attr_1
+local function i() end
\ No newline at end of file