diff options
| author | Theodor Thornhill | 2023-07-24 16:17:34 +0200 |
|---|---|---|
| committer | Theodor Thornhill | 2023-07-24 16:22:07 +0200 |
| commit | 4e977136d3148c3baa0e03568c7a2c7dc28eea65 (patch) | |
| tree | 55fd9302c2d976985f583ae2ba1c8cc2a3484d05 | |
| parent | 906ecf442c43da98e6b8c7488f549691901690e9 (diff) | |
| download | emacs-4e977136d3148c3baa0e03568c7a2c7dc28eea65.tar.gz emacs-4e977136d3148c3baa0e03568c7a2c7dc28eea65.zip | |
Make compat check also check typescript
* lisp/progmodes/typescript-ts-mode.el
(tsx-ts-mode--font-lock-compatibility-bb1f97b):
Add argument so that we run the 'treesit-query-capture' when the
language is 'typescript', not only 'tsx'.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings): Use supplied argument.
| -rw-r--r-- | lisp/progmodes/typescript-ts-mode.el | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index ae0a80aea86..bacf9fbd08e 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el | |||
| @@ -154,15 +154,16 @@ Argument LANGUAGE is either `typescript' or `tsx'." | |||
| 154 | "&&" "||" "!" "?.") | 154 | "&&" "||" "!" "?.") |
| 155 | "TypeScript operators for tree-sitter font-locking.") | 155 | "TypeScript operators for tree-sitter font-locking.") |
| 156 | 156 | ||
| 157 | (defun tsx-ts-mode--font-lock-compatibility-bb1f97b () | 157 | (defun tsx-ts-mode--font-lock-compatibility-bb1f97b (language) |
| 158 | "Font lock rules helper, to handle different releases of tree-sitter-tsx. | 158 | "Font lock rules helper, to handle different releases of tree-sitter-tsx. |
| 159 | Check if a node type is available, then return the right font lock rules." | 159 | Check if a node type is available, then return the right font lock rules. |
| 160 | Argument LANGUAGE is either `typescript' or `tsx'." | ||
| 160 | ;; handle commit bb1f97b | 161 | ;; handle commit bb1f97b |
| 161 | ;; Warning: treesitter-query-capture says both node types are valid, | 162 | ;; Warning: treesitter-query-capture says both node types are valid, |
| 162 | ;; but then raises an error if the wrong node type is used. So it is | 163 | ;; but then raises an error if the wrong node type is used. So it is |
| 163 | ;; important to check with the new node type (member_expression) | 164 | ;; important to check with the new node type (member_expression) |
| 164 | (condition-case nil | 165 | (condition-case nil |
| 165 | (progn (treesit-query-capture 'tsx '((member_expression) @capture)) | 166 | (progn (treesit-query-capture language '((member_expression) @capture)) |
| 166 | '((jsx_opening_element | 167 | '((jsx_opening_element |
| 167 | [(member_expression (identifier)) (identifier)] | 168 | [(member_expression (identifier)) (identifier)] |
| 168 | @typescript-ts-jsx-tag-face) | 169 | @typescript-ts-jsx-tag-face) |
| @@ -337,7 +338,7 @@ Argument LANGUAGE is either `typescript' or `tsx'." | |||
| 337 | 338 | ||
| 338 | :language language | 339 | :language language |
| 339 | :feature 'jsx | 340 | :feature 'jsx |
| 340 | (append (tsx-ts-mode--font-lock-compatibility-bb1f97b) | 341 | (append (tsx-ts-mode--font-lock-compatibility-bb1f97b language) |
| 341 | `((jsx_attribute (property_identifier) @typescript-ts-jsx-attribute-face))) | 342 | `((jsx_attribute (property_identifier) @typescript-ts-jsx-attribute-face))) |
| 342 | 343 | ||
| 343 | :language language | 344 | :language language |