Whenever I load a typescript file, I first have to manually start typescript-ts-mode
. After that, it will correctly load typescript-ts-mode
for subsequent typescript files. Is the remapping to the tree sitter modes lazy?
What is the value of
major-mode-remap-alist
?
You can find this out with
M-x describe-variable RET major-mode-remap-alist
This variable controls when/how ts modes get activated. This gets set in the dev extra file. I presume you’re loading this file?
Yes, I'm loading this file. Here is the value for
major-mode-remap-alist
major-mode-remap-alist is a variable defined in ‘files.el’. Its value is shown below. Alist mapping file-specified mode to actual mode. Every entry is of the form (MODE . FUNCTION) which means that in order to activate the major mode MODE (specified via something like ‘auto-mode-alist’, file-local variables, ...) we should actually call FUNCTION instead. You can customize this variable. Probably introduced at or before Emacs version 29.1. Value: ((yaml-mode . yaml-ts-mode) (bash-mode . bash-ts-mode) (js2-mode . js-ts-mode) (typescript-mode . typescript-ts-mode) (json-mode . json-ts-mode) (css-mode . css-ts-mode) (python-mode . python-ts-mode)) Original value was nil
I have to add the following lines to
init.el
to make the modes load properly(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode)) (add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode)) (add-to-list 'auto-mode-alist '("\\.js\\'" . js-ts-mode))
Hey, thanks for the detailed reply.
OK, looks like
major-mode-remap-alist
is set properly. Once you add theauto-mode-alist
lines, does everything work as expected? Or, are you still having to manually enabletypescript-ts-mode
when opening up a.ts
file?
Yes, once I add those lines, everything works as expected.