diff options
| author | Yuan Fu | 2024-10-07 17:24:32 -0700 |
|---|---|---|
| committer | Yuan Fu | 2024-10-07 17:24:32 -0700 |
| commit | ed57faafc74e0810b492841deccb3cdc77a258ff (patch) | |
| tree | 9e47ea5e3739330045994d5787d042f7f1a1d036 | |
| parent | 37a6c859b04ef9f88c3f9751027d544100cf1d2c (diff) | |
| download | emacs-ed57faafc74e0810b492841deccb3cdc77a258ff.tar.gz emacs-ed57faafc74e0810b492841deccb3cdc77a258ff.zip | |
Set treesit-primary-parser for tree-sitter modes
I debated whether to do this, since technically speaking it's
not needed for single-language modes. But ultimately it's
better to be explicit and set a good example with builtin modes.
* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode):
* lisp/progmodes/csharp-mode.el (csharp-ts-mode):
* lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode):
* lisp/progmodes/go-ts-mode.el (go-ts-mode):
(go-mod-ts-mode):
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode):
* lisp/progmodes/java-ts-mode.el (java-ts-mode):
* lisp/progmodes/json-ts-mode.el (json-ts-mode):
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode):
* lisp/progmodes/python.el (python-ts-mode):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode):
* lisp/progmodes/sh-script.el:
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode):
(tsx-ts-mode):
* lisp/textmodes/css-mode.el (css-ts-mode):
* lisp/textmodes/html-ts-mode.el (html-ts-mode):
* lisp/textmodes/toml-ts-mode.el (toml-ts-mode):
* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode): Set
treesit-primary-parser.
| -rw-r--r-- | lisp/progmodes/cmake-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/csharp-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/dockerfile-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/go-ts-mode.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/heex-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/java-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/json-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/lua-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/rust-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/sh-script.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/typescript-ts-mode.el | 4 | ||||
| -rw-r--r-- | lisp/textmodes/css-mode.el | 2 | ||||
| -rw-r--r-- | lisp/textmodes/html-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/textmodes/toml-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/textmodes/yaml-ts-mode.el | 2 |
17 files changed, 19 insertions, 19 deletions
diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el index 854adf4ade7..597ef69d9b8 100644 --- a/lisp/progmodes/cmake-ts-mode.el +++ b/lisp/progmodes/cmake-ts-mode.el | |||
| @@ -208,7 +208,7 @@ Return nil if there is no name or if NODE is not a defun node." | |||
| 208 | :syntax-table cmake-ts-mode--syntax-table | 208 | :syntax-table cmake-ts-mode--syntax-table |
| 209 | 209 | ||
| 210 | (when (treesit-ready-p 'cmake) | 210 | (when (treesit-ready-p 'cmake) |
| 211 | (treesit-parser-create 'cmake) | 211 | (setq treesit-primary-parser (treesit-parser-create 'cmake)) |
| 212 | 212 | ||
| 213 | ;; Comments. | 213 | ;; Comments. |
| 214 | (setq-local comment-start "# ") | 214 | (setq-local comment-start "# ") |
diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 1f86527191a..b86555b1d87 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el | |||
| @@ -1049,7 +1049,7 @@ Key bindings: | |||
| 1049 | (error "Tree-sitter for C# isn't available")) | 1049 | (error "Tree-sitter for C# isn't available")) |
| 1050 | 1050 | ||
| 1051 | ;; Tree-sitter. | 1051 | ;; Tree-sitter. |
| 1052 | (treesit-parser-create 'c-sharp) | 1052 | (setq treesit-primary-parser (treesit-parser-create 'c-sharp)) |
| 1053 | 1053 | ||
| 1054 | ;; Comments. | 1054 | ;; Comments. |
| 1055 | (c-ts-common-comment-setup) | 1055 | (c-ts-common-comment-setup) |
diff --git a/lisp/progmodes/dockerfile-ts-mode.el b/lisp/progmodes/dockerfile-ts-mode.el index e31fd86bbdf..42fa7482a87 100644 --- a/lisp/progmodes/dockerfile-ts-mode.el +++ b/lisp/progmodes/dockerfile-ts-mode.el | |||
| @@ -133,7 +133,7 @@ Return nil if there is no name or if NODE is not a stage node." | |||
| 133 | :syntax-table dockerfile-ts-mode--syntax-table | 133 | :syntax-table dockerfile-ts-mode--syntax-table |
| 134 | 134 | ||
| 135 | (when (treesit-ready-p 'dockerfile) | 135 | (when (treesit-ready-p 'dockerfile) |
| 136 | (treesit-parser-create 'dockerfile) | 136 | (setq treesit-primary-parser (treesit-parser-create 'dockerfile)) |
| 137 | 137 | ||
| 138 | ;; Comments. | 138 | ;; Comments. |
| 139 | (setq-local comment-start "# ") | 139 | (setq-local comment-start "# ") |
diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index 2d3e6aac090..899f7852c2b 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el | |||
| @@ -253,7 +253,7 @@ | |||
| 253 | :syntax-table go-ts-mode--syntax-table | 253 | :syntax-table go-ts-mode--syntax-table |
| 254 | 254 | ||
| 255 | (when (treesit-ready-p 'go) | 255 | (when (treesit-ready-p 'go) |
| 256 | (treesit-parser-create 'go) | 256 | (setq treesit-primary-parser (treesit-parser-create 'go)) |
| 257 | 257 | ||
| 258 | ;; Comments. | 258 | ;; Comments. |
| 259 | (setq-local comment-start "// ") | 259 | (setq-local comment-start "// ") |
| @@ -453,7 +453,7 @@ what the parent of the node would be if it were a node." | |||
| 453 | :syntax-table go-mod-ts-mode--syntax-table | 453 | :syntax-table go-mod-ts-mode--syntax-table |
| 454 | 454 | ||
| 455 | (when (treesit-ready-p 'gomod) | 455 | (when (treesit-ready-p 'gomod) |
| 456 | (treesit-parser-create 'gomod) | 456 | (setq treesit-primary-parser (treesit-parser-create 'gomod)) |
| 457 | 457 | ||
| 458 | ;; Comments. | 458 | ;; Comments. |
| 459 | (setq-local comment-start "// ") | 459 | (setq-local comment-start "// ") |
diff --git a/lisp/progmodes/heex-ts-mode.el b/lisp/progmodes/heex-ts-mode.el index b527d96b579..84fd513525c 100644 --- a/lisp/progmodes/heex-ts-mode.el +++ b/lisp/progmodes/heex-ts-mode.el | |||
| @@ -148,7 +148,7 @@ With ARG, do it many times. Negative ARG means move backward." | |||
| 148 | :group 'heex-ts | 148 | :group 'heex-ts |
| 149 | 149 | ||
| 150 | (when (treesit-ready-p 'heex) | 150 | (when (treesit-ready-p 'heex) |
| 151 | (treesit-parser-create 'heex) | 151 | (setq treesit-primary-parser (treesit-parser-create 'heex)) |
| 152 | 152 | ||
| 153 | ;; Comments | 153 | ;; Comments |
| 154 | (setq-local treesit-thing-settings | 154 | (setq-local treesit-thing-settings |
diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 4ceb211ade1..6c7c5a30ab8 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el | |||
| @@ -326,7 +326,7 @@ Return nil if there is no name or if NODE is not a defun node." | |||
| 326 | (unless (treesit-ready-p 'java) | 326 | (unless (treesit-ready-p 'java) |
| 327 | (error "Tree-sitter for Java isn't available")) | 327 | (error "Tree-sitter for Java isn't available")) |
| 328 | 328 | ||
| 329 | (treesit-parser-create 'java) | 329 | (setq treesit-primary-parser (treesit-parser-create 'java)) |
| 330 | 330 | ||
| 331 | ;; Comments. | 331 | ;; Comments. |
| 332 | (c-ts-common-comment-setup) | 332 | (c-ts-common-comment-setup) |
diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 1fb96555010..7409c6be833 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el | |||
| @@ -128,7 +128,7 @@ Return nil if there is no name or if NODE is not a defun node." | |||
| 128 | (unless (treesit-ready-p 'json) | 128 | (unless (treesit-ready-p 'json) |
| 129 | (error "Tree-sitter for JSON isn't available")) | 129 | (error "Tree-sitter for JSON isn't available")) |
| 130 | 130 | ||
| 131 | (treesit-parser-create 'json) | 131 | (setq treesit-primary-parser (treesit-parser-create 'json)) |
| 132 | 132 | ||
| 133 | ;; Comments. | 133 | ;; Comments. |
| 134 | (setq-local comment-start "// ") | 134 | (setq-local comment-start "// ") |
diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index 4ea453c9b65..aea5e1e6116 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el | |||
| @@ -752,7 +752,7 @@ Calls REPORT-FN directly." | |||
| 752 | (use-local-map lua-ts-mode-map) | 752 | (use-local-map lua-ts-mode-map) |
| 753 | 753 | ||
| 754 | (when (treesit-ready-p 'lua) | 754 | (when (treesit-ready-p 'lua) |
| 755 | (treesit-parser-create 'lua) | 755 | (setq treesit-primary-parser (treesit-parser-create 'lua)) |
| 756 | 756 | ||
| 757 | ;; Comments. | 757 | ;; Comments. |
| 758 | (setq-local comment-start "--") | 758 | (setq-local comment-start "--") |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 0001bdd21a9..e4b9fe2367d 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -7147,7 +7147,7 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 7147 | \\{python-ts-mode-map}" | 7147 | \\{python-ts-mode-map}" |
| 7148 | :syntax-table python-mode-syntax-table | 7148 | :syntax-table python-mode-syntax-table |
| 7149 | (when (treesit-ready-p 'python) | 7149 | (when (treesit-ready-p 'python) |
| 7150 | (treesit-parser-create 'python) | 7150 | (setq treesit-primary-parser (treesit-parser-create 'python)) |
| 7151 | (setq-local treesit-font-lock-feature-list | 7151 | (setq-local treesit-font-lock-feature-list |
| 7152 | '(( comment definition) | 7152 | '(( comment definition) |
| 7153 | ( keyword string type) | 7153 | ( keyword string type) |
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index adcdf15c7ad..aff0b8911b9 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el | |||
| @@ -1127,7 +1127,7 @@ leading double colon is not added." | |||
| 1127 | (unless (treesit-ready-p 'ruby) | 1127 | (unless (treesit-ready-p 'ruby) |
| 1128 | (error "Tree-sitter for Ruby isn't available")) | 1128 | (error "Tree-sitter for Ruby isn't available")) |
| 1129 | 1129 | ||
| 1130 | (treesit-parser-create 'ruby) | 1130 | (setq treesit-primary-parser (treesit-parser-create 'ruby)) |
| 1131 | 1131 | ||
| 1132 | (setq-local add-log-current-defun-function #'ruby-ts-add-log-current-function) | 1132 | (setq-local add-log-current-defun-function #'ruby-ts-add-log-current-function) |
| 1133 | 1133 | ||
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el index 571ffa9b220..038955d1ae0 100644 --- a/lisp/progmodes/rust-ts-mode.el +++ b/lisp/progmodes/rust-ts-mode.el | |||
| @@ -507,7 +507,7 @@ See `prettify-symbols-compose-predicate'." | |||
| 507 | :syntax-table rust-ts-mode--syntax-table | 507 | :syntax-table rust-ts-mode--syntax-table |
| 508 | 508 | ||
| 509 | (when (treesit-ready-p 'rust) | 509 | (when (treesit-ready-p 'rust) |
| 510 | (treesit-parser-create 'rust) | 510 | (setq treesit-primary-parser (treesit-parser-create 'rust)) |
| 511 | 511 | ||
| 512 | ;; Syntax. | 512 | ;; Syntax. |
| 513 | (setq-local syntax-propertize-function | 513 | (setq-local syntax-propertize-function |
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index a348e9ba6fd..8ba64100203 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el | |||
| @@ -1623,7 +1623,7 @@ not written in Bash or sh." | |||
| 1623 | (add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t) | 1623 | (add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t) |
| 1624 | (add-hook 'hack-local-variables-hook | 1624 | (add-hook 'hack-local-variables-hook |
| 1625 | #'sh-after-hack-local-variables nil t) | 1625 | #'sh-after-hack-local-variables nil t) |
| 1626 | (treesit-parser-create 'bash) | 1626 | (setq treesit-primary-parser (treesit-parser-create 'bash)) |
| 1627 | (setq-local treesit-font-lock-feature-list | 1627 | (setq-local treesit-font-lock-feature-list |
| 1628 | '(( comment function) | 1628 | '(( comment function) |
| 1629 | ( command declaration-command keyword string) | 1629 | ( command declaration-command keyword string) |
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 3606a139d50..4860eaf3a34 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el | |||
| @@ -502,7 +502,7 @@ This mode is intended to be inherited by concrete major modes." | |||
| 502 | :syntax-table typescript-ts-mode--syntax-table | 502 | :syntax-table typescript-ts-mode--syntax-table |
| 503 | 503 | ||
| 504 | (when (treesit-ready-p 'typescript) | 504 | (when (treesit-ready-p 'typescript) |
| 505 | (treesit-parser-create 'typescript) | 505 | (setq treesit-primary-parser (treesit-parser-create 'typescript)) |
| 506 | 506 | ||
| 507 | ;; Indent. | 507 | ;; Indent. |
| 508 | (setq-local treesit-simple-indent-rules | 508 | (setq-local treesit-simple-indent-rules |
| @@ -540,7 +540,7 @@ at least 3 (which is the default value)." | |||
| 540 | :syntax-table typescript-ts-mode--syntax-table | 540 | :syntax-table typescript-ts-mode--syntax-table |
| 541 | 541 | ||
| 542 | (when (treesit-ready-p 'tsx) | 542 | (when (treesit-ready-p 'tsx) |
| 543 | (treesit-parser-create 'tsx) | 543 | (setq treesit-primary-parser (treesit-parser-create 'tsx)) |
| 544 | 544 | ||
| 545 | ;; Comments. | 545 | ;; Comments. |
| 546 | (setq-local comment-start "// ") | 546 | (setq-local comment-start "// ") |
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index f5a20e0ca0e..c8da28187ee 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el | |||
| @@ -1814,7 +1814,7 @@ can also be used to fill comments. | |||
| 1814 | (setq-local font-lock-fontify-region-function #'css--fontify-region) | 1814 | (setq-local font-lock-fontify-region-function #'css--fontify-region) |
| 1815 | 1815 | ||
| 1816 | ;; Tree-sitter specific setup. | 1816 | ;; Tree-sitter specific setup. |
| 1817 | (treesit-parser-create 'css) | 1817 | (setq treesit-primary-parser (treesit-parser-create 'css)) |
| 1818 | (setq-local treesit-simple-indent-rules css--treesit-indent-rules) | 1818 | (setq-local treesit-simple-indent-rules css--treesit-indent-rules) |
| 1819 | (setq-local treesit-defun-type-regexp "rule_set") | 1819 | (setq-local treesit-defun-type-regexp "rule_set") |
| 1820 | (setq-local treesit-defun-name-function #'css--treesit-defun-name) | 1820 | (setq-local treesit-defun-name-function #'css--treesit-defun-name) |
diff --git a/lisp/textmodes/html-ts-mode.el b/lisp/textmodes/html-ts-mode.el index 235e1055fa9..f78fbdde1da 100644 --- a/lisp/textmodes/html-ts-mode.el +++ b/lisp/textmodes/html-ts-mode.el | |||
| @@ -92,7 +92,7 @@ Return nil if there is no name or if NODE is not a defun node." | |||
| 92 | (unless (treesit-ready-p 'html) | 92 | (unless (treesit-ready-p 'html) |
| 93 | (error "Tree-sitter for HTML isn't available")) | 93 | (error "Tree-sitter for HTML isn't available")) |
| 94 | 94 | ||
| 95 | (treesit-parser-create 'html) | 95 | (setq treesit-primary-parser (treesit-parser-create 'html)) |
| 96 | 96 | ||
| 97 | ;; Indent. | 97 | ;; Indent. |
| 98 | (setq-local treesit-simple-indent-rules html-ts-mode--indent-rules) | 98 | (setq-local treesit-simple-indent-rules html-ts-mode--indent-rules) |
diff --git a/lisp/textmodes/toml-ts-mode.el b/lisp/textmodes/toml-ts-mode.el index 3c4533a7fea..806f045c23b 100644 --- a/lisp/textmodes/toml-ts-mode.el +++ b/lisp/textmodes/toml-ts-mode.el | |||
| @@ -124,7 +124,7 @@ Return nil if there is no name or if NODE is not a defun node." | |||
| 124 | :syntax-table toml-ts-mode--syntax-table | 124 | :syntax-table toml-ts-mode--syntax-table |
| 125 | 125 | ||
| 126 | (when (treesit-ready-p 'toml) | 126 | (when (treesit-ready-p 'toml) |
| 127 | (treesit-parser-create 'toml) | 127 | (setq treesit-primary-parser (treesit-parser-create 'toml)) |
| 128 | 128 | ||
| 129 | ;; Comments | 129 | ;; Comments |
| 130 | (setq-local comment-start "# ") | 130 | (setq-local comment-start "# ") |
diff --git a/lisp/textmodes/yaml-ts-mode.el b/lisp/textmodes/yaml-ts-mode.el index 210835585fe..42d7c2e1798 100644 --- a/lisp/textmodes/yaml-ts-mode.el +++ b/lisp/textmodes/yaml-ts-mode.el | |||
| @@ -148,7 +148,7 @@ boundaries. JUSTIFY is passed to `fill-paragraph'." | |||
| 148 | :syntax-table yaml-ts-mode--syntax-table | 148 | :syntax-table yaml-ts-mode--syntax-table |
| 149 | 149 | ||
| 150 | (when (treesit-ready-p 'yaml) | 150 | (when (treesit-ready-p 'yaml) |
| 151 | (treesit-parser-create 'yaml) | 151 | (setq treesit-primary-parser (treesit-parser-create 'yaml)) |
| 152 | 152 | ||
| 153 | ;; Comments. | 153 | ;; Comments. |
| 154 | (setq-local comment-start "# ") | 154 | (setq-local comment-start "# ") |