~ashton314/emacs-bedrock#14: 
typescript files are not recognized out of the box

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?

Status
REPORTED
Submitter
~cowboyd
Assigned to
No-one
Submitted
1 year, 2 months ago
Updated
1 year, 2 months ago
Labels
No labels applied.

~ashton314 1 year, 2 months ago

What is the value of major-mode-remap-alist?

~ashton314 1 year, 2 months ago

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?

~cowboyd 1 year, 2 months ago

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))

~ashton314 1 year, 2 months ago

Hey, thanks for the detailed reply.

OK, looks like major-mode-remap-alist is set properly. Once you add the auto-mode-alist lines, does everything work as expected? Or, are you still having to manually enable typescript-ts-mode when opening up a .ts file?

~cowboyd 1 year, 2 months ago

Yes, once I add those lines, everything works as expected.

Register here or Log in to comment, or comment via email.