[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 8ec923775d 2/9: Tweak various ts-mode's indent and fontificatio
From: |
Yuan Fu |
Subject: |
emacs-29 8ec923775d 2/9: Tweak various ts-mode's indent and fontification (bug#59931) |
Date: |
Mon, 12 Dec 2022 18:09:37 -0500 (EST) |
branch: emacs-29
commit 8ec923775de3482acf4b158a79838eae64fd4980
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Yuan Fu <casouri@gmail.com>
Tweak various ts-mode's indent and fontification (bug#59931)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw
string literal font-locking.
* lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add
text_block indent rule.
(java-ts-mode--font-lock-settings): Add text_block font-locking.
* lisp/progmodes/js.el (js-ts-mode): Prefer top-level navigation.
* lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings):
Add comment feature.
(json-ts-mode): Use comment feature.
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode):
Prefer top-level navigation.
---
lisp/progmodes/c-ts-mode.el | 4 +++-
lisp/progmodes/java-ts-mode.el | 4 +++-
lisp/progmodes/js.el | 1 +
lisp/progmodes/json-ts-mode.el | 5 ++++-
lisp/progmodes/typescript-ts-mode.el | 2 ++
5 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 824325d83e..deba83641b 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -251,7 +251,9 @@ MODE is either `c' or `cpp'."
:language mode
:feature 'string
`((string_literal) @font-lock-string-face
- (system_lib_string) @font-lock-string-face)
+ (system_lib_string) @font-lock-string-face
+ ,@(when (eq mode 'cpp)
+ '((raw_string_literal) @font-lock-string-face)))
:language mode
:feature 'literal
diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el
index 9155a7fff2..ac591a0859 100644
--- a/lisp/progmodes/java-ts-mode.el
+++ b/lisp/progmodes/java-ts-mode.el
@@ -73,6 +73,7 @@
((node-is "]") parent-bol 0)
((and (parent-is "comment") comment-end) comment-start -1)
((parent-is "comment") comment-start-skip 0)
+ ((parent-is "text_block") no-indent)
((parent-is "class_body") parent-bol java-ts-mode-indent-offset)
((parent-is "interface_body") parent-bol java-ts-mode-indent-offset)
((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset)
@@ -162,7 +163,8 @@
:language 'java
:override t
:feature 'string
- `((string_literal) @font-lock-string-face)
+ `((string_literal) @font-lock-string-face
+ (text_block) @font-lock-string-face)
:language 'java
:override t
:feature 'literal
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f7318c481a..1de0f3442f 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3871,6 +3871,7 @@ Currently there are `js-mode' and `js-ts-mode'."
;; Indent.
(setq-local treesit-simple-indent-rules js--treesit-indent-rules)
;; Navigation.
+ (setq-local treesit-defun-prefer-top-level t)
(setq-local treesit-defun-type-regexp
(rx (or "class_declaration"
"method_definition"
diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el
index a118908a00..6fb982e37b 100644
--- a/lisp/progmodes/json-ts-mode.el
+++ b/lisp/progmodes/json-ts-mode.el
@@ -74,6 +74,9 @@
(defvar json-ts-mode--font-lock-settings
(treesit-font-lock-rules
+ :language 'json
+ :feature 'comment
+ '((comment) @font-lock-comment-face)
:language 'json
:feature 'bracket
'((["[" "]" "{" "}"]) @font-lock-bracket-face)
@@ -161,7 +164,7 @@ the subtrees."
;; Font-lock.
(setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings)
(setq-local treesit-font-lock-feature-list
- '((constant number pair string)
+ '((comment constant number pair string)
(escape-sequence)
(bracket delimiter error)))
diff --git a/lisp/progmodes/typescript-ts-mode.el
b/lisp/progmodes/typescript-ts-mode.el
index 8c4364ecc5..e4d188971a 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -329,6 +329,8 @@ Argument LANGUAGE is either `typescript' or `tsx'."
(group (or (syntax comment-end)
(seq (+ "*") "/")))))
+ (setq-local treesit-defun-prefer-top-level t)
+
;; Electric
(setq-local electric-indent-chars
(append "{}():;," electric-indent-chars))
- emacs-29 updated (5b178efd85 -> 0f9e6532b1), Yuan Fu, 2022/12/12
- emacs-29 ca67d988d8 3/9: Add cmake-ts-mode, Yuan Fu, 2022/12/12
- emacs-29 647b6a8099 1/9: Add expression for generic_name in csharp-ts-mode (bug#59897), Yuan Fu, 2022/12/12
- emacs-29 8ec923775d 2/9: Tweak various ts-mode's indent and fontification (bug#59931),
Yuan Fu <=
- emacs-29 5d4274d9b6 5/9: ; * admin/notes/tree-sitter/build-module/build.sh: Add -fPIC., Yuan Fu, 2022/12/12
- emacs-29 631908f701 6/9: Add "->" to python--treesit-operators (bug#59968), Yuan Fu, 2022/12/12
- emacs-29 0f9e6532b1 9/9: Use font-lock-number-face for numeric values in csharp-mode, Yuan Fu, 2022/12/12
- emacs-29 d264b75669 4/9: Align C++ access specifiers to their enclosing class/struct/union, Yuan Fu, 2022/12/12
- emacs-29 c0fe6c72ce 7/9: Improve dockerfile-ts-mode imenu generation (Bug#59979), Yuan Fu, 2022/12/12
- emacs-29 4bccb7b211 8/9: Make treesit-query-validate create a read-only buffer, Yuan Fu, 2022/12/12