aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheLeoP <53507599+TheLeoP@users.noreply.github.com>2023-08-17 21:17:04 -0500
committerGitHub <noreply@github.com>2023-08-18 02:17:04 +0000
commitbbb92b2b8ea17cb477033b6d321dfad4bbde0c13 (patch)
tree12aaa26f7d1386aa5ed3cb8d9ab2dd555ed9e5c9
parentchore(csv,psv,tsv): update parser to fix numbers (diff)
downloadnvim-treesitter-bbb92b2b8ea17cb477033b6d321dfad4bbde0c13.tar
nvim-treesitter-bbb92b2b8ea17cb477033b6d321dfad4bbde0c13.tar.gz
nvim-treesitter-bbb92b2b8ea17cb477033b6d321dfad4bbde0c13.tar.bz2
nvim-treesitter-bbb92b2b8ea17cb477033b6d321dfad4bbde0c13.tar.lz
nvim-treesitter-bbb92b2b8ea17cb477033b6d321dfad4bbde0c13.tar.xz
nvim-treesitter-bbb92b2b8ea17cb477033b6d321dfad4bbde0c13.tar.zst
nvim-treesitter-bbb92b2b8ea17cb477033b6d321dfad4bbde0c13.zip
fix(lua): luap injection (#5275)
* fix(lua): luap injection * test(lua): check for incorrect hlgroup of injected luap * chore(lua): injections styling * chore(lua): ignore luacheck for test.lua
-rw-r--r--queries/lua/injections.scm32
-rw-r--r--tests/query/highlights/lua/test.lua5
2 files changed, 32 insertions, 5 deletions
diff --git a/queries/lua/injections.scm b/queries/lua/injections.scm
index 8cc0605c8..a426ee1b9 100644
--- a/queries/lua/injections.scm
+++ b/queries/lua/injections.scm
@@ -39,30 +39,52 @@
(#offset! @injection.content 0 1 0 0))
; string.match("123", "%d+")
+
(function_call
(dot_index_expression
field: (identifier) @_method
(#any-of? @_method "find" "match"))
- arguments: (arguments (_) . (string content: _ @injection.content (#set! injection.language "luap"))))
+ arguments: (arguments
+ . (_)
+ .
+ (string
+ content: (string_content) @injection.content
+ (#set! injection.language "luap")
+ (#set! injection.include-children))))
(function_call
(dot_index_expression
field: (identifier) @_method
(#any-of? @_method "gmatch" "gsub"))
- arguments: (arguments (_) (string content: _ @injection.content (#set! injection.language "luap"))))
+ arguments: (arguments
+ . (_)
+ .
+ (string
+ content: (string_content) @injection.content
+ (#set! injection.language "luap")
+ (#set! injection.include-children))))
+
+;("123"):match("%d+")
-; ("123"):match("%d+")
(function_call
(method_index_expression
method: (identifier) @_method
(#any-of? @_method "find" "match"))
- arguments: (arguments . (string content: _ @injection.content (#set! injection.language "luap"))))
+ arguments: (arguments
+ . (string
+ content: (string_content) @injection.content
+ (#set! injection.language "luap")
+ (#set! injection.include-children))))
(function_call
(method_index_expression
method: (identifier) @_method
(#any-of? @_method "gmatch" "gsub"))
- arguments: (arguments (string content: _ @injection.content (#set! injection.language "luap"))))
+ arguments: (arguments
+ . (string
+ content: (string_content) @injection.content
+ (#set! injection.language "luap")
+ (#set! injection.include-children))))
(comment content: (_) @injection.content
(#set! injection.language "comment"))
diff --git a/tests/query/highlights/lua/test.lua b/tests/query/highlights/lua/test.lua
index efb9a9994..e8725b9fe 100644
--- a/tests/query/highlights/lua/test.lua
+++ b/tests/query/highlights/lua/test.lua
@@ -1,3 +1,4 @@
+-- luacheck: ignore
local a = { 1, 2, 3, 4, 5 }
-- ^ number ^ punctuation.bracket
-- ^ variable
@@ -11,3 +12,7 @@ _ = next(a)
next(a)
-- ^ function.builtin
+
+-- Checking for incorrect hlgroup of injected luap
+string.match(s, "\0%d[^\n]+")
+-- ^ !constant