summaryrefslogtreecommitdiffstats
path: root/queries
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2023-11-20 08:26:18 -0800
committerGitHub <noreply@github.com>2023-11-21 01:26:18 +0900
commit1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2 (patch)
tree3983382f83ef934c258dbe640564ce87e33a4e87 /queries
parentUpdate parsers: commonlisp, cuda, glsl, hlsl, pod, smithy, tlaplus, v, wing (diff)
downloadnvim-treesitter-1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2.tar
nvim-treesitter-1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2.tar.gz
nvim-treesitter-1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2.tar.bz2
nvim-treesitter-1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2.tar.lz
nvim-treesitter-1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2.tar.xz
nvim-treesitter-1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2.tar.zst
nvim-treesitter-1610b1aafb9b7b3a7b54c853ed45c6cb1a3d0df2.zip
feat(python): `@string.regex` capture, injection improvements (#5697)
* feat(python): `@string.regex` capture, injection improvements * fix(python): match regex only for first argument of re module * chore(python): remove unneeded capture Co-authored-by: Santos Gallegos <stsewd@proton.me> * fix(python): only highlight string content itself as regex --------- Co-authored-by: Santos Gallegos <stsewd@proton.me>
Diffstat (limited to 'queries')
-rw-r--r--queries/python/highlights.scm8
-rw-r--r--queries/python/injections.scm5
2 files changed, 10 insertions, 3 deletions
diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm
index de98dccbf..b09122dd9 100644
--- a/queries/python/highlights.scm
+++ b/queries/python/highlights.scm
@@ -346,3 +346,11 @@
;; https://docs.python.org/3/library/stdtypes.html
"bool" "int" "float" "complex" "list" "tuple" "range" "str"
"bytes" "bytearray" "memoryview" "set" "frozenset" "dict" "type" "object"))
+
+;; Regex from the `re` module
+
+(call
+ function: (attribute
+ object: (identifier) @_re)
+ arguments: (argument_list . (string (string_content) @string.regex))
+ (#eq? @_re "re"))
diff --git a/queries/python/injections.scm b/queries/python/injections.scm
index b836ea3f7..aa36a5af9 100644
--- a/queries/python/injections.scm
+++ b/queries/python/injections.scm
@@ -1,10 +1,9 @@
(call
function: (attribute
object: (identifier) @_re)
- arguments: (argument_list (string
- (string_content) @injection.content) @_string)
+ arguments: (argument_list . (string
+ (string_content) @injection.content))
(#eq? @_re "re")
- (#lua-match? @_string "^r.*")
(#set! injection.language "regex"))
((comment) @injection.content