mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-24 14:30:43 -08:00
New user option 'treesit-enabled-modes' (bug#79180)
* lisp/treesit.el (treesit-enabled-modes): New user option. * src/treesit.c (treesit-major-mode-remap-alist): New variable. * lisp/progmodes/c-ts-mode.el: * lisp/progmodes/csharp-mode.el: * lisp/progmodes/java-ts-mode.el: * lisp/progmodes/js.el: * lisp/progmodes/json-ts-mode.el: * lisp/progmodes/ruby-ts-mode.el: * lisp/progmodes/sh-script.el: * lisp/textmodes/css-mode.el: * lisp/textmodes/mhtml-ts-mode.el: * lisp/textmodes/toml-ts-mode.el: Add ts-mode mapping to 'treesit-major-mode-remap-alist' for ts-modes that already have the corresponding non-ts mode association in 'auto-mode-alist'. * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode-maybe): * lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode-maybe): * lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode-maybe): * lisp/progmodes/go-ts-mode.el (go-ts-mode-maybe) (go-mod-ts-mode-maybe, go-work-ts-mode-maybe): * lisp/progmodes/heex-ts-mode.el (heex-ts-mode-maybe): * lisp/progmodes/lua-ts-mode.el (lua-ts-mode-maybe): * lisp/progmodes/php-ts-mode.el (php-ts-mode-maybe): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode-maybe): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-maybe) (tsx-ts-mode-maybe): * lisp/textmodes/markdown-ts-mode.el (markdown-ts-mode-maybe): * lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode-maybe): Add a wrapper function to 'auto-mode-alist' for ts-modes that have no corresponding non-ts mode. Also add a mapping to 'treesit-major-mode-remap-alist' for the case when a non-ts mode is installed from an external source to be able to customize it with 'treesit-enabled-modes'.
This commit is contained in:
parent
97e2e90519
commit
0ac3a1f26c
26 changed files with 323 additions and 100 deletions
|
|
@ -68,11 +68,8 @@
|
|||
;;
|
||||
;; will turn on the ruby-ts-mode for Ruby source files.
|
||||
;;
|
||||
;; - If you have the Ruby grammar installed, add
|
||||
;;
|
||||
;; (load "ruby-ts-mode")
|
||||
;;
|
||||
;; to your init file.
|
||||
;; - If you have the Ruby grammar installed, customize
|
||||
;; 'treesit-enabled-modes' and add 'ruby-ts-mode' to it.
|
||||
;;
|
||||
;; You can also turn on this mode manually in a buffer.
|
||||
|
||||
|
|
@ -1280,11 +1277,10 @@ leading double colon is not added."
|
|||
|
||||
(derived-mode-add-parents 'ruby-ts-mode '(ruby-mode))
|
||||
|
||||
(when (treesit-ready-p 'ruby)
|
||||
(setq major-mode-remap-defaults
|
||||
(assq-delete-all 'ruby-mode major-mode-remap-defaults))
|
||||
(add-to-list 'major-mode-remap-defaults
|
||||
'(ruby-mode . ruby-ts-mode)))
|
||||
;;;###autoload
|
||||
(when (treesit-available-p)
|
||||
(add-to-list 'treesit-major-mode-remap-alist
|
||||
'(ruby-mode . ruby-ts-mode)))
|
||||
|
||||
(provide 'ruby-ts-mode)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue