diff options
| author | Yuan Fu | 2022-10-04 12:18:53 -0700 |
|---|---|---|
| committer | Yuan Fu | 2022-10-04 13:30:56 -0700 |
| commit | 253126bf339a16589e86acd51c0f96da07e658d9 (patch) | |
| tree | f2f0140232deb8304438434a831b981a27377633 /lisp/progmodes/python.el | |
| parent | 96d44c4321724556819e2f718f1d94470d753d07 (diff) | |
| download | emacs-253126bf339a16589e86acd51c0f96da07e658d9.tar.gz emacs-253126bf339a16589e86acd51c0f96da07e658d9.zip | |
Fix python tree-sitter font-lock
Add fontification for lhs attribute and some operators.
* lisp/progmodes/python.el (python--treesit-keywords): Add operators.
(python--treesit-settings): Add lhs attribute.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 5b70c63f7b4..3f85201c107 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -915,7 +915,10 @@ It makes underscores and dots word constituent chars.") | |||
| 915 | '("as" "assert" "async" "await" "break" "class" "continue" "def" | 915 | '("as" "assert" "async" "await" "break" "class" "continue" "def" |
| 916 | "del" "elif" "else" "except" "exec" "finally" "for" "from" | 916 | "del" "elif" "else" "except" "exec" "finally" "for" "from" |
| 917 | "global" "if" "import" "lambda" "nonlocal" "pass" "print" | 917 | "global" "if" "import" "lambda" "nonlocal" "pass" "print" |
| 918 | "raise" "return" "try" "while" "with" "yield")) | 918 | "raise" "return" "try" "while" "with" "yield" |
| 919 | ;; These are technically operators, but we fontify them as | ||
| 920 | ;; keywords. | ||
| 921 | "and" "in" "is" "not" "or")) | ||
| 919 | 922 | ||
| 920 | (defvar python--treesit-builtins | 923 | (defvar python--treesit-builtins |
| 921 | '("abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" | 924 | '("abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" |
| @@ -934,6 +937,8 @@ It makes underscores and dots word constituent chars.") | |||
| 934 | "copyright" "credits" "exit" "license" "quit")) | 937 | "copyright" "credits" "exit" "license" "quit")) |
| 935 | 938 | ||
| 936 | (defvar python--treesit-operators | 939 | (defvar python--treesit-operators |
| 940 | ;; This is not used. And and, or, not, is, in are fontified as | ||
| 941 | ;; keywords. | ||
| 937 | '("-" "-=" "!=" "*" "**" "**=" "*=" "/" "//" "//=" "/=" "&" "%" "%=" | 942 | '("-" "-=" "!=" "*" "**" "**=" "*=" "/" "//" "//=" "/=" "&" "%" "%=" |
| 938 | "^" "+" "+=" "<" "<<" "<=" "<>" "=" "==" ">" ">=" ">>" "|" "~" | 943 | "^" "+" "+=" "<" "<<" "<=" "<>" "=" "==" ">" ">=" ">>" "|" "~" |
| 939 | "and" "in" "is" "not" "or")) | 944 | "and" "in" "is" "not" "or")) |
| @@ -1019,6 +1024,9 @@ Do not fontify the initial f for f-strings." | |||
| 1019 | ;; Variable names. | 1024 | ;; Variable names. |
| 1020 | (assignment left: (identifier) | 1025 | (assignment left: (identifier) |
| 1021 | @font-lock-variable-name-face) | 1026 | @font-lock-variable-name-face) |
| 1027 | (assignment left: (attribute | ||
| 1028 | attribute: (identifier) | ||
| 1029 | @font-lock-variable-name-face)) | ||
| 1022 | (pattern_list (identifier) | 1030 | (pattern_list (identifier) |
| 1023 | @font-lock-variable-name-face) | 1031 | @font-lock-variable-name-face) |
| 1024 | (tuple_pattern (identifier) | 1032 | (tuple_pattern (identifier) |