Skip to content

Commit

Permalink
Change python highlights.scm to more fully utilize the themes.
Browse files Browse the repository at this point in the history
Create type keywords
Allow _CONSTANTS to start with _
Highlight constants before constructors
Move some keywords into @keyword.control
  • Loading branch information
Zeddicus414 authored and archseer committed May 20, 2022
1 parent 6462542 commit a6da99a
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions runtime/queries/python/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
; Identifier naming conventions

((identifier) @constant
(#match? @constant "^[A-Z_]*$"))

((identifier) @constructor
(#match? @constructor "^[A-Z]"))

((identifier) @constant
(#match? @constant "^[A-Z][A-Z_]*$"))
; Types

((identifier) @type
(#match?
@type
"^(bool|bytes|dict|float|frozenset|int|list|set|str|tuple)$"))

(type (identifier)) @type

; 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__)$"))
"^(abs|all|any|ascii|bin|breakpoint|bytearray|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|exec|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip|__import__)$"))

; Function calls

Expand All @@ -30,7 +39,6 @@

(identifier) @variable
(attribute attribute: (identifier) @variable.other.member)
(type (identifier) @type)

; Literals

Expand Down Expand Up @@ -81,41 +89,48 @@
">>"
"|"
"~"
"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.control

(for_statement "in" @keyword.control)
(for_in_clause "in" @keyword.control)

[
"and"
"async"
"class"
"def"
"del"
"exec"
"global"
"in"
"is"
"lambda"
"nonlocal"
"not"
"or"
"print"
] @keyword

0 comments on commit a6da99a

Please sign in to comment.