Closed mgmarlow closed 11 months ago
I also run Emacs without typescript-mode
, but just included
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode))
in my configuration (alongside all the other file extensions in which I wanted to launch a treesitter mode), and then promptly forgot about it.
Ultimately, the scope of this package was to address the issue of selecting between treesitter modes and their non-treesitter counterparts depending on grammar availability; not necessarily adding opinions about which file extensions should be using which mode. However, I agree it would be nice if Emacs just "knew" about grammars being installed, that YAML and TypeScript -ts-mode
s should be tied to the .ya?ml
and .ts
extensions respectively, and it should just launch on its own. Where I hesitate is that if we muck with people's auto-mode-alist
, we might really mess up something they've configured on their own, just how they like it. Altogether, I think how you've approached it in #56 is probably the right way; we just need to add some verbiage in the README about "opting-in" to having your auto-mode alist
modified.
I'll take a closer look at the PR once I get a chance to do some testing. Thanks for contributing!
Thanks for taking a look! The main advantage for me is adding the "recommended" extension to the recipe struct so I can more easily write my own tooling for modifying the auto-mode-alist
. Including an opt-in function seemed like a useful extension.
I'm happy to update the README with some extra notes around using it and its caveats.
I was surprised to find that after enabling
global-treesit-auto-mode
thetypescript-ts-mode
didn't appear for my.ts
buffer even though I had previously installed the parser. After reading through this project, I discovered that the recipe lists for these modes depend on aremap
package that in many cases may not be installed, e.g.typescript-mode
.I'd like to have the tree-sitter modes work if they're ready and installed, even if I lack the remap-mode that it depends on. In this example, I'd like for a
.ts
buffer infundamental-mode
to map totypescript-ts-mode
.I'm thinking this could be implemented by looking at
treesit-ready-p
and checking the buffer extension if theremap
mode isn't bound (viafboundp
). What do you think?