mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
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>
This commit is contained in:
parent
3da5cfb4a2
commit
1610b1aafb
2 changed files with 10 additions and 3 deletions
|
|
@ -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"))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue