aboutsummaryrefslogtreecommitdiffstats
path: root/queries/python
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2020-06-21 16:32:25 +0200
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-06-24 10:07:22 +0200
commitdfead6cacab1a9f94396169166c9de8f8d4efdb7 (patch)
tree396d87d86b04fb30d4d804cf17b2588a7541ea8a /queries/python
parentadd highlight queries for bash (diff)
downloadnvim-treesitter-dfead6cacab1a9f94396169166c9de8f8d4efdb7.tar
nvim-treesitter-dfead6cacab1a9f94396169166c9de8f8d4efdb7.tar.gz
nvim-treesitter-dfead6cacab1a9f94396169166c9de8f8d4efdb7.tar.bz2
nvim-treesitter-dfead6cacab1a9f94396169166c9de8f8d4efdb7.tar.lz
nvim-treesitter-dfead6cacab1a9f94396169166c9de8f8d4efdb7.tar.xz
nvim-treesitter-dfead6cacab1a9f94396169166c9de8f8d4efdb7.tar.zst
nvim-treesitter-dfead6cacab1a9f94396169166c9de8f8d4efdb7.zip
Adapt Python highlights to new query syntax
Diffstat (limited to 'queries/python')
-rw-r--r--queries/python/highlights.scm139
-rw-r--r--queries/python/locals.scm8
2 files changed, 66 insertions, 81 deletions
diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm
index c56897804..739ab81cf 100644
--- a/queries/python/highlights.scm
+++ b/queries/python/highlights.scm
@@ -77,8 +77,7 @@
; Literals
(none) @constant.builtin
-(true) @boolean
-(false) @boolean
+[(true) (false)] @boolean
((identifier) @constant.builtin
(match? @constant.builtin "self"))
@@ -91,88 +90,78 @@
; Tokens
-"-" @operator
-"->" @operator
-"-=" @operator
-"!=" @operator
-"*" @operator
-"**" @operator
-"**=" @operator
-"*=" @operator
-"/" @operator
-"//" @operator
-"//=" @operator
-"/=" @operator
-"&" @operator
-"%" @operator
-"%=" @operator
-"^" @operator
-"+" @operator
-"+=" @operator
-"<" @operator
-"<<" @operator
-"<=" @operator
-"<>" @operator
-"=" @operator
-"==" @operator
-">" @operator
-">=" @operator
-">>" @operator
-"|" @operator
-"~" @operator
-"and" @operator
-"in" @operator
-"is" @operator
-"not" @operator
-"or" @operator
+[
+ "-"
+ "-="
+ "!="
+ "*"
+ "**"
+ "**="
+ "*="
+ "/"
+ "//"
+ "//="
+ "/="
+ "&"
+ "%"
+ "%="
+ "^"
+ "+"
+ "+="
+ "<"
+ "<<"
+ "<="
+ "<>"
+ "="
+ "=="
+ ">"
+ ">="
+ ">>"
+ "|"
+ "~"
+ "and"
+ "in"
+ "is"
+ "not"
+ "or"
+] @operator
; Keywords
-"as" @include
-"assert" @keyword
-"async" @keyword
-"await" @keyword
-"break" @repeat
-"class" @keyword
-"continue" @repeat
-"def" @keyword
-"del" @keyword
-"elif" @conditional
-"else" @conditional
-"except" @keyword
-"exec" @keyword
-"finally" @keyword
-"for" @repeat
-"from" @include
-"global" @keyword
-"if" @conditional
-"import" @include
-"lambda" @keyword
-"nonlocal" @keyword
-"pass" @keyword
-"print" @keyword
-"raise" @keyword
-"return" @keyword
-"try" @keyword
-"while" @repeat
-"with" @keyword
-"yield" @keyword
+[
+ "assert"
+ "await"
+ "class"
+ "def"
+ "del"
+ "except"
+ "exec"
+ "finally"
+ "global"
+ "lambda"
+ "nonlocal"
+ "pass"
+ "print"
+ "raise"
+ "return"
+ "try"
+ "with"
+ "yield"
+] @keyword
-; Additions for nvim-treesitter
-"(" @punctuation.bracket
-")" @punctuation.bracket
-"[" @punctuation.bracket
-"]" @punctuation.bracket
-"{" @punctuation.bracket
-"}" @punctuation.bracket
+[ "as" "from" "import"] @include
+
+[ "if" "elif" "else" ] @conditional
+
+[ "for" "while" "break" "continue" ] @repeat
+
+[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
(interpolation
"{" @punctuation.special
"}" @punctuation.special) @embedded
-"," @punctuation.delimiter
-"." @punctuation.delimiter
-":" @punctuation.delimiter
+[ "," "." ":" ] @punctuation.delimiter
; Class definitions
diff --git a/queries/python/locals.scm b/queries/python/locals.scm
index 735271663..cdf4d4117 100644
--- a/queries/python/locals.scm
+++ b/queries/python/locals.scm
@@ -30,12 +30,8 @@
; Function defines function and scope
(function_definition
- name: (identifier) @definition.function) @scope
-
-;; Should be extended to when syntax supported
-;(function_definition
- ;name: (identifier) @definition.function
- ;body: (block (expression_statement (string) @definition.function.doc)?)) @scope
+ name: (identifier) @definition.function
+ body: (block (expression_statement (string) @definition.doc)?)) @scope
(class_definition