summaryrefslogtreecommitdiff
path: root/runtime/queries/python/highlights.scm
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-09 08:42:49 +0000
committerBlaž Hrastnik2021-04-09 09:57:46 +0000
commit4e31d1521bf9bb59f6485954d4ada16bf853c85a (patch)
treed8d05c9303701590dee6351eea693887dbab3981 /runtime/queries/python/highlights.scm
parentc1e5733b02e4ba39b82d7b330fab0b2ded2220f2 (diff)
Add tree-sitter queries.
Diffstat (limited to 'runtime/queries/python/highlights.scm')
-rw-r--r--runtime/queries/python/highlights.scm124
1 files changed, 124 insertions, 0 deletions
diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm
new file mode 100644
index 00000000..f64fecb2
--- /dev/null
+++ b/runtime/queries/python/highlights.scm
@@ -0,0 +1,124 @@
+; Identifier naming conventions
+
+((identifier) @constructor
+ (#match? @constructor "^[A-Z]"))
+
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z_]*$"))
+
+; Builtin functions
+
+((call
+ function: (identifier) @function.builtin)
+ (#match?
+ @function.builtin
+ "^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))
+
+; Function calls
+
+(decorator) @function
+
+(call
+ function: (attribute attribute: (identifier) @function.method))
+(call
+ function: (identifier) @function)
+
+; Function definitions
+
+(function_definition
+ name: (identifier) @function)
+
+(identifier) @variable
+(attribute attribute: (identifier) @property)
+(type (identifier) @type)
+
+; Literals
+
+[
+ (none)
+ (true)
+ (false)
+] @constant.builtin
+
+[
+ (integer)
+ (float)
+] @number
+
+(comment) @comment
+(string) @string
+(escape_sequence) @escape
+
+(interpolation
+ "{" @punctuation.special
+ "}" @punctuation.special) @embedded
+
+[
+ "-"
+ "-="
+ "!="
+ "*"
+ "**"
+ "**="
+ "*="
+ "/"
+ "//"
+ "//="
+ "/="
+ "&"
+ "%"
+ "%="
+ "^"
+ "+"
+ "->"
+ "+="
+ "<"
+ "<<"
+ "<="
+ "<>"
+ "="
+ ":="
+ "=="
+ ">"
+ ">="
+ ">>"
+ "|"
+ "~"
+ "and"
+ "in"
+ "is"
+ "not"
+ "or"
+] @operator
+
+[
+ "as"
+ "assert"
+ "async"
+ "await"
+ "break"
+ "class"
+ "continue"
+ "def"
+ "del"
+ "elif"
+ "else"
+ "except"
+ "exec"
+ "finally"
+ "for"
+ "from"
+ "global"
+ "if"
+ "import"
+ "lambda"
+ "nonlocal"
+ "pass"
+ "print"
+ "raise"
+ "return"
+ "try"
+ "while"
+ "with"
+ "yield"
+] @keyword