Change python highlights.scm to more fully utilize the themes.

Create type keywords
Allow _CONSTANTS to start with _
Highlight constants before constructors
Move some keywords into @keyword.control
imgbot
Zeddicus414 3 years ago committed by Blaž Hrastnik
parent 6462542fc5
commit a6da99a144

@ -1,10 +1,19 @@
; Identifier naming conventions ; Identifier naming conventions
((identifier) @constant
(#match? @constant "^[A-Z_]*$"))
((identifier) @constructor ((identifier) @constructor
(#match? @constructor "^[A-Z]")) (#match? @constructor "^[A-Z]"))
((identifier) @constant ; Types
(#match? @constant "^[A-Z][A-Z_]*$"))
((identifier) @type
(#match?
@type
"^(bool|bytes|dict|float|frozenset|int|list|set|str|tuple)$"))
(type (identifier)) @type
; Builtin functions ; Builtin functions
@ -12,7 +21,7 @@
function: (identifier) @function.builtin) function: (identifier) @function.builtin)
(#match? (#match?
@function.builtin @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 ; Function calls
@ -30,7 +39,6 @@
(identifier) @variable (identifier) @variable
(attribute attribute: (identifier) @variable.other.member) (attribute attribute: (identifier) @variable.other.member)
(type (identifier) @type)
; Literals ; Literals
@ -81,41 +89,48 @@
">>" ">>"
"|" "|"
"~" "~"
"and"
"in"
"is"
"not"
"or"
] @operator ] @operator
[ [
"as" "as"
"assert" "assert"
"async"
"await" "await"
"break" "break"
"class"
"continue" "continue"
"def"
"del"
"elif" "elif"
"else" "else"
"except" "except"
"exec"
"finally" "finally"
"for" "for"
"from" "from"
"global"
"if" "if"
"import" "import"
"lambda"
"nonlocal"
"pass" "pass"
"print"
"raise" "raise"
"return" "return"
"try" "try"
"while" "while"
"with" "with"
"yield" "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 ] @keyword

Loading…
Cancel
Save