From dfead6cacab1a9f94396169166c9de8f8d4efdb7 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 21 Jun 2020 16:32:25 +0200 Subject: Adapt Python highlights to new query syntax --- queries/python/highlights.scm | 141 +++++++++++++++++++----------------------- queries/python/locals.scm | 8 +-- 2 files changed, 67 insertions(+), 82 deletions(-) (limited to 'queries/python') 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 - -; Additions for nvim-treesitter -"(" @punctuation.bracket -")" @punctuation.bracket -"[" @punctuation.bracket -"]" @punctuation.bracket -"{" @punctuation.bracket -"}" @punctuation.bracket +[ + "assert" + "await" + "class" + "def" + "del" + "except" + "exec" + "finally" + "global" + "lambda" + "nonlocal" + "pass" + "print" + "raise" + "return" + "try" + "with" + "yield" +] @keyword + +[ "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 -- cgit v1.2.3-70-g09d2