aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorRandy Taylor2022-11-13 22:06:33 -0500
committerYuan Fu2022-11-17 10:36:14 -0800
commit2f03053e568f38a1dce5ffe02ad1359069ef84c8 (patch)
treecbda7dcf120a4a2c5ce194585c822afd0bbbd8ae /lisp/progmodes/python.el
parentd5c6d69b4fea2d5a1167a0bcc0b9994a5939b97e (diff)
downloademacs-2f03053e568f38a1dce5ffe02ad1359069ef84c8.tar.gz
emacs-2f03053e568f38a1dce5ffe02ad1359069ef84c8.zip
Utilize new font-lock faces for C/C++ and Python tree-sitter use
* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Use new escape, number, property, operator, bracket, and delimiter font-lock faces. (c-ts-mode--base-mode): Add them to the feature list. (c-ts-mode): Fix typo. * lisp/progmodes/python.el (python--treesit-settings): Use new number, property, operator, bracket, and delimiter font-lock faces. (python-mode): Add them to the feature list.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el41
1 files changed, 35 insertions, 6 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ad4665eb19c..22485a025e0 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -975,11 +975,8 @@ It makes underscores and dots word constituent chars.")
975 "copyright" "credits" "exit" "license" "quit")) 975 "copyright" "credits" "exit" "license" "quit"))
976 976
977(defvar python--treesit-operators 977(defvar python--treesit-operators
978 ;; This is not used. And and, or, not, is, in are fontified as
979 ;; keywords.
980 '("-" "-=" "!=" "*" "**" "**=" "*=" "/" "//" "//=" "/=" "&" "%" "%=" 978 '("-" "-=" "!=" "*" "**" "**=" "*=" "/" "//" "//=" "/=" "&" "%" "%="
981 "^" "+" "+=" "<" "<<" "<=" "<>" "=" "==" ">" ">=" ">>" "|" "~" 979 "^" "+" "+=" "<" "<<" "<=" "<>" "=" "==" ">" ">=" ">>" "|" "~"))
982 "and" "in" "is" "not" "or"))
983 980
984(defvar python--treesit-special-attributes 981(defvar python--treesit-special-attributes
985 '("__annotations__" "__closure__" "__code__" 982 '("__annotations__" "__closure__" "__code__"
@@ -1117,7 +1114,38 @@ be fontified."
1117 :feature 'escape-sequence 1114 :feature 'escape-sequence
1118 :language 'python 1115 :language 'python
1119 :override t 1116 :override t
1120 '((escape_sequence) @font-lock-escape-face)) 1117 '((escape_sequence) @font-lock-escape-face)
1118
1119 :feature 'number
1120 :language 'python
1121 :override t
1122 '([(integer) (float)] @font-lock-number-face)
1123
1124 :feature 'property
1125 :language 'python
1126 :override t
1127 '((attribute
1128 attribute: (identifier) @font-lock-property-face)
1129 (class_definition
1130 body: (block
1131 (expression_statement
1132 (assignment left:
1133 (identifier) @font-lock-property-face)))))
1134
1135 :feature 'operator
1136 :language 'python
1137 :override t
1138 `([,@python--treesit-operators] @font-lock-operator-face)
1139
1140 :feature 'bracket
1141 :language 'python
1142 :override t
1143 '(["(" ")" "[" "]" "{" "}"] @font-lock-bracket-face)
1144
1145 :feature 'delimiter
1146 :language 'python
1147 :override t
1148 '(["," "." ":" ";" (ellipsis)] @font-lock-delimiter-face))
1121 "Tree-sitter font-lock settings.") 1149 "Tree-sitter font-lock settings.")
1122 1150
1123 1151
@@ -6553,7 +6581,8 @@ Add import for undefined name `%s' (empty to skip): "
6553 '(( comment string function-name class-name) 6581 '(( comment string function-name class-name)
6554 ( keyword builtin constant type) 6582 ( keyword builtin constant type)
6555 ( assignment decorator escape-sequence 6583 ( assignment decorator escape-sequence
6556 string-interpolation))) 6584 string-interpolation number property
6585 operator bracket delimiter)))
6557 (setq-local treesit-font-lock-settings python--treesit-settings) 6586 (setq-local treesit-font-lock-settings python--treesit-settings)
6558 (setq-local imenu-create-index-function 6587 (setq-local imenu-create-index-function
6559 #'python-imenu-treesit-create-index) 6588 #'python-imenu-treesit-create-index)