Fix python-ts-mode built-in functions and attributes (bug#70478)
authorPrateek Sharma <ps.prateek.sharma143@gmail.com>
Fri, 19 Apr 2024 20:36:17 +0000 (02:06 +0530)
committerYuan Fu <casouri@gmail.com>
Sun, 21 Apr 2024 23:37:15 +0000 (16:37 -0700)
* lisp/progmodes/python.el (python--treesit-settings): Change the
treesitter query to fetch the correct type of node for built-in
functions and attributes and highlight them with corresponding
font-lock face.

lisp/progmodes/python.el

index 9849fde8588ec7f1d51116148621c421b8d8ed36..02588d756e9277cc024e4455953833bb2e357c50 100644 (file)
@@ -1187,13 +1187,15 @@ fontified."
 
    :feature 'builtin
    :language 'python
-   `(((identifier) @font-lock-builtin-face
-      (:match ,(rx-to-string
-                `(seq bol
-                      (or ,@python--treesit-builtins
-                          ,@python--treesit-special-attributes)
-                      eol))
-              @font-lock-builtin-face)))
+   `((call function: (identifier) @font-lock-builtin-face
+           (:match ,(rx-to-string
+                     `(seq bol (or ,@python--treesit-builtins) eol))
+                   @font-lock-builtin-face))
+     (attribute attribute: (identifier) @font-lock-builtin-face
+                (:match ,(rx-to-string
+                          `(seq bol
+                                (or ,@python--treesit-special-attributes) eol))
+                        @font-lock-builtin-face)))
 
    :feature 'decorator
    :language 'python