Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml10
-rw-r--r--runtime/queries/lua/injections.scm26
-rw-r--r--runtime/queries/luap/highlights.scm45
-rw-r--r--runtime/queries/luau/injections.scm24
5 files changed, 106 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index e00eba03..2875cb72 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -147,6 +147,7 @@
| log | ✓ | | | | |
| lpf | ✓ | | | | |
| lua | ✓ | ✓ | ✓ | | `lua-language-server` |
+| luap | ✓ | | | | |
| luau | ✓ | ✓ | ✓ | | `luau-lsp` |
| mail | ✓ | ✓ | | | |
| make | ✓ | | ✓ | | |
diff --git a/languages.toml b/languages.toml
index 30492e79..719cc319 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1416,6 +1416,16 @@ language-servers = [ "lua-language-server" ]
name = "lua"
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-lua", rev = "88e446476a1e97a8724dff7a23e2d709855077f2" }
+[[language]]
+name = "luap"
+scope = "source.luap"
+file-types = []
+injection-regex = "luap"
+
+[[grammar]]
+name = "luap"
+source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-luap", rev = "c134aaec6acf4fa95fe4aa0dc9aba3eacdbbe55a" }
+
[[grammar]]
name = "teal"
source = { git = "https://github.com/euclidianAce/tree-sitter-teal", rev = "3db655924b2ff1c54fdf6371b5425ea6b5dccefe" }
diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm
index fca94d58..8f8c174a 100644
--- a/runtime/queries/lua/injections.scm
+++ b/runtime/queries/lua/injections.scm
@@ -1,3 +1,29 @@
((comment) @injection.content
(#set! injection.language "comment")
(#set! injection.include-children))
+
+; string.match("123", "%d+")
+(function_call
+ (dot_index_expression
+ field: (identifier) @_method
+ (#any-of? @_method "find" "match" "gmatch" "gsub"))
+ arguments: (arguments
+ .
+ (_)
+ .
+ (string
+ content: (string_content) @injection.content
+ (#set! injection.language "luap")
+ (#set! injection.include-children))))
+
+; ("123"):match("%d+")
+(function_call
+ (method_index_expression
+ method: (identifier) @_method
+ (#any-of? @_method "find" "match" "gmatch" "gsub"))
+ arguments: (arguments
+ .
+ (string
+ content: (string_content) @injection.content
+ (#set! injection.language "luap")
+ (#set! injection.include-children))))
diff --git a/runtime/queries/luap/highlights.scm b/runtime/queries/luap/highlights.scm
new file mode 100644
index 00000000..e01cd226
--- /dev/null
+++ b/runtime/queries/luap/highlights.scm
@@ -0,0 +1,45 @@
+[
+ (anchor_begin)
+ (anchor_end)
+] @punctuation.delimiter
+
+(pattern
+ (character
+ "." @variable.builtin))
+
+[
+ "["
+ "]"
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ (zero_or_more)
+ (shortest_zero_or_more)
+ (one_or_more)
+ (zero_or_one)
+] @operator
+
+(range
+ from: (character) @constant
+ "-" @operator
+ to: (character) @constant)
+
+(set
+ (character) @constant)
+
+(negated_set
+ (character) @constant)
+
+(class) @constant.character.escape
+
+(class
+ "%" @string.regexp
+ (escape_char) @string.regexp)
+
+(negated_set
+ "^" @operator)
+
+(balanced_match
+ (character) @variable.parameter)
diff --git a/runtime/queries/luau/injections.scm b/runtime/queries/luau/injections.scm
index 321c90ad..86d4196e 100644
--- a/runtime/queries/luau/injections.scm
+++ b/runtime/queries/luau/injections.scm
@@ -1,2 +1,26 @@
((comment) @injection.content
(#set! injection.language "comment"))
+
+; string.match("123", "%d+")
+(call_stmt
+ invoked: (var
+ table_name: (name)
+ (key
+ field_name: (name) @_method))
+ (arglist
+ .
+ (_)
+ .
+ (string) @injection.content)
+ (#any-of? @_method "find" "format" "match" "gmatch" "gsub")
+ (#set! injection.language "luap"))
+
+; ("123"):match("%d+")
+(call_stmt
+ method_table: (_)
+ method_name: (name) @_method
+ (arglist
+ .
+ (string) @injection.content)
+ (#any-of? @_method "find" "format" "match" "gmatch" "gsub")
+ (#set! injection.language "luap"))