mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-10 07:20:06 -04:00
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
This commit is contained in:
parent
3073b093d0
commit
bbb92b2b8e
2 changed files with 32 additions and 5 deletions
|
|
@ -39,30 +39,52 @@
|
||||||
(#offset! @injection.content 0 1 0 0))
|
(#offset! @injection.content 0 1 0 0))
|
||||||
|
|
||||||
; string.match("123", "%d+")
|
; string.match("123", "%d+")
|
||||||
|
|
||||||
(function_call
|
(function_call
|
||||||
(dot_index_expression
|
(dot_index_expression
|
||||||
field: (identifier) @_method
|
field: (identifier) @_method
|
||||||
(#any-of? @_method "find" "match"))
|
(#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
|
(function_call
|
||||||
(dot_index_expression
|
(dot_index_expression
|
||||||
field: (identifier) @_method
|
field: (identifier) @_method
|
||||||
(#any-of? @_method "gmatch" "gsub"))
|
(#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
|
(function_call
|
||||||
(method_index_expression
|
(method_index_expression
|
||||||
method: (identifier) @_method
|
method: (identifier) @_method
|
||||||
(#any-of? @_method "find" "match"))
|
(#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
|
(function_call
|
||||||
(method_index_expression
|
(method_index_expression
|
||||||
method: (identifier) @_method
|
method: (identifier) @_method
|
||||||
(#any-of? @_method "gmatch" "gsub"))
|
(#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
|
(comment content: (_) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
-- luacheck: ignore
|
||||||
local a = { 1, 2, 3, 4, 5 }
|
local a = { 1, 2, 3, 4, 5 }
|
||||||
-- ^ number ^ punctuation.bracket
|
-- ^ number ^ punctuation.bracket
|
||||||
-- ^ variable
|
-- ^ variable
|
||||||
|
|
@ -11,3 +12,7 @@ _ = next(a)
|
||||||
|
|
||||||
next(a)
|
next(a)
|
||||||
-- ^ function.builtin
|
-- ^ function.builtin
|
||||||
|
|
||||||
|
-- Checking for incorrect hlgroup of injected luap
|
||||||
|
string.match(s, "\0%d[^\n]+")
|
||||||
|
-- ^ !constant
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue