[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter e3663d0e9c 03/14: Add contextual tree-sitter font-lo
From: |
Yuan Fu |
Subject: |
feature/tree-sitter e3663d0e9c 03/14: Add contextual tree-sitter font-lock to ts-mode and js-mode |
Date: |
Fri, 4 Nov 2022 13:19:09 -0400 (EDT) |
branch: feature/tree-sitter
commit e3663d0e9c6ec32a70226947767850924b90bba7
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Add contextual tree-sitter font-lock to ts-mode and js-mode
* lisp/progmodes/js.el (js--treesit-font-lock-settings)
* lisp/progmodes/ts-mode.el (ts-mode--font-lock-settings): Capture
commend and strings. Add empty lines.
---
lisp/progmodes/js.el | 15 ++++++++++++++-
lisp/progmodes/ts-mode.el | 15 ++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 92a8599d7f..01da87f6be 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3451,10 +3451,13 @@ This function is intended for use in
`after-change-functions'."
(defvar js--treesit-font-lock-settings
(treesit-font-lock-rules
+
:language 'javascript
:override t
:feature 'comment
- `((comment) @font-lock-comment-face)
+ `((comment) @font-lock-comment-face
+ (comment) @contextual)
+
:language 'javascript
:override t
:feature 'constant
@@ -3463,18 +3466,23 @@ This function is intended for use in
`after-change-functions'."
[(true) (false) (null)] @font-lock-constant-face
(number) @font-lock-constant-face)
+
:language 'javascript
:override t
:feature 'keyword
`([,@js--treesit-keywords] @font-lock-keyword-face
[(this) (super)] @font-lock-keyword-face)
+
:language 'javascript
:override t
:feature 'string
`((regex pattern: (regex_pattern)) @font-lock-string-face
(string) @font-lock-string-face
+ (string) @contextual
(template_string) @js--fontify-template-string
+ (template_string) @contextual
(template_substitution ["${" "}"] @font-lock-builtin-face))
+
:language 'javascript
:override t
:feature 'declaration
@@ -3503,6 +3511,7 @@ This function is intended for use in
`after-change-functions'."
(identifier)
@font-lock-function-name-face)
value: (array (number) (function))))
+
:language 'javascript
:override t
:feature 'identifier
@@ -3514,6 +3523,7 @@ This function is intended for use in
`after-change-functions'."
(arrow_function
parameter: (identifier) @font-lock-variable-name-face))
+
:language 'javascript
:override t
:feature 'expression
@@ -3533,6 +3543,7 @@ This function is intended for use in
`after-change-functions'."
left: [(identifier) @font-lock-variable-name-face
(member_expression
property: (property_identifier) @font-lock-variable-name-face)]))
+
:language 'javascript
:override t
:feature 'property
@@ -3547,11 +3558,13 @@ This function is intended for use in
`after-change-functions'."
((shorthand_property_identifier) @font-lock-variable-name-face)
((shorthand_property_identifier_pattern) @font-lock-variable-name-face))
+
:language 'javascript
:override t
:feature 'pattern
`((pair_pattern key: (property_identifier) @font-lock-variable-name-face)
(array_pattern (identifier) @font-lock-variable-name-face))
+
:language 'javascript
:override t
:feature 'jsx
diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el
index 20118bc3db..a7dee1ead8 100644
--- a/lisp/progmodes/ts-mode.el
+++ b/lisp/progmodes/ts-mode.el
@@ -100,10 +100,13 @@
(defvar ts-mode--font-lock-settings
(treesit-font-lock-rules
+
:language 'tsx
:override t
:feature 'comment
- `((comment) @font-lock-comment-face)
+ `((comment) @font-lock-comment-face
+ (comment) @contextual)
+
:language 'tsx
:override t
:feature 'constant
@@ -112,18 +115,23 @@
[(true) (false) (null)] @font-lock-constant-face
(number) @font-lock-constant-face)
+
:language 'tsx
:override t
:feature 'keyword
`([,@ts-mode--keywords] @font-lock-keyword-face
[(this) (super)] @font-lock-keyword-face)
+
:language 'tsx
:override t
:feature 'string
`((regex pattern: (regex_pattern)) @font-lock-string-face
(string) @font-lock-string-face
+ (string) @contextual
(template_string) @js--fontify-template-string
+ (template_string) @contextual
(template_substitution ["${" "}"] @font-lock-builtin-face))
+
:language 'tsx
:override t
:feature 'declaration
@@ -153,6 +161,7 @@
(identifier)
(identifier) @font-lock-function-name-face)
value: (array (number) (function))))
+
:language 'tsx
:override t
:feature 'identifier
@@ -183,6 +192,7 @@
[(_ (identifier) @font-lock-variable-name-face)
(_ (_ (identifier) @font-lock-variable-name-face))
(_ (_ (_ (identifier) @font-lock-variable-name-face)))]))
+
:language 'tsx
:override t
:feature 'expression
@@ -197,6 +207,7 @@
[(identifier) @font-lock-function-name-face
(member_expression
property: (property_identifier) @font-lock-function-name-face)]))
+
:language 'tsx
:override t
:feature 'property
@@ -215,6 +226,7 @@
((shorthand_property_identifier_pattern)
@font-lock-variable-name-face))
+
:language 'tsx
:override t
:feature 'pattern
@@ -222,6 +234,7 @@
key: (property_identifier) @font-lock-variable-name-face)
(array_pattern (identifier) @font-lock-variable-name-face))
+
:language 'tsx
:override t
:feature 'jsx
- feature/tree-sitter updated (9909652849 -> c924b6afb6), Yuan Fu, 2022/11/04
- feature/tree-sitter 5416ae5990 01/14: ; Update guides in /admin/notes/tree-sitter, Yuan Fu, 2022/11/04
- feature/tree-sitter c5f24f76eb 05/14: ; * src/treesit.c: Minor comment change., Yuan Fu, 2022/11/04
- feature/tree-sitter ce9e720413 13/14: ; Minor improvement in treesit-inspect-mode, Yuan Fu, 2022/11/04
- feature/tree-sitter 673a55780d 10/14: ; Remove unused tree-sitter functions, Yuan Fu, 2022/11/04
- feature/tree-sitter e0e3299c01 12/14: ; * lisp/treesit.el (treesit-update-ranges): Update all parsers., Yuan Fu, 2022/11/04
- feature/tree-sitter 784f53a215 11/14: ; Replace error with signal in treesit.el, Yuan Fu, 2022/11/04
- feature/tree-sitter c924b6afb6 14/14: ; * lisp/treesit.el (treesit-ready-p): Fix typo., Yuan Fu, 2022/11/04
- feature/tree-sitter e3663d0e9c 03/14: Add contextual tree-sitter font-lock to ts-mode and js-mode,
Yuan Fu <=
- feature/tree-sitter f6dc55f516 07/14: ; * lisp/progmodes/js.el (js--fontify-template-string): Fix typo., Yuan Fu, 2022/11/04
- feature/tree-sitter f9f9b43df5 02/14: Minor change to tree-sitter imenu function of js-mode, Yuan Fu, 2022/11/04
- feature/tree-sitter 8ad4c4009e 09/14: Add treesit-indent-error, Yuan Fu, 2022/11/04
- feature/tree-sitter b86deb617b 06/14: Fix treesit-parser-set-included-ranges, Yuan Fu, 2022/11/04
- feature/tree-sitter d9d66764e2 08/14: Revise tree-sitter facility for multi-language buffers, Yuan Fu, 2022/11/04
- feature/tree-sitter b028d4f7df 04/14: ; Tree-sitter: Don't refontify if entity contained in the region, Yuan Fu, 2022/11/04