mirror of
https://github.com/doomemacs/doomemacs.git
synced 2025-12-06 02:30:33 -08:00
fix(tree-sitter): remap to ts-mode w/o base mode
If the base major mode doesn't exist, let's assume we want no
fallthrough for this major mode (in the event the grammar isn't ready)
and simply push forward anyway, even if a missing grammar results in a
broken state.
This will particularly affect major modes like `typescript-mode` (which
simply won't be installed if +tree-sitter is enabled) and
`go-{mod,work}-ts-mode` (for which no base major modes exist).
The difference (generally) between most base and ts-modes is
performance, not features, so "gracefully failing back to the base mode"
makes sense UX-wise, but `typescript-mode` notably inferior to
`typescript-ts-mode` (particularly in its TSX support). Beginners may
misidentify its shortcomings as bugs, so it's better to simply error out
early so the user can be made aware of the problem sooner and less
ambiguously.
This commit is contained in:
parent
5cda3ed25a
commit
1dae2bf916
2 changed files with 7 additions and 4 deletions
|
|
@ -2,9 +2,7 @@
|
||||||
;;; lang/javascript/packages.el
|
;;; lang/javascript/packages.el
|
||||||
|
|
||||||
;; Major modes
|
;; Major modes
|
||||||
(unless (or (modulep! +tree-sitter)
|
(unless (modulep! +tree-sitter)
|
||||||
(fboundp 'treesit-available-p)
|
|
||||||
(treesit-available-p))
|
|
||||||
(package! typescript-mode :pin "481df3ad2cdf569d8e6697679669ff6206fbd2f9"))
|
(package! typescript-mode :pin "481df3ad2cdf569d8e6697679669ff6206fbd2f9"))
|
||||||
|
|
||||||
;; Extensions
|
;; Extensions
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,12 @@
|
||||||
(or (not (autoloadp fn))
|
(or (not (autoloadp fn))
|
||||||
(autoload-do-load fn mode)))
|
(autoload-do-load fn mode)))
|
||||||
;; Only prompt once, and log other times.
|
;; Only prompt once, and log other times.
|
||||||
(or (null (cdr ts))
|
(or (null (cdr ts)) ; no grammars, no problem!
|
||||||
|
;; If the base/fallback mode doesn't exist, let's
|
||||||
|
;; assume we want no fallthrough for this major mode
|
||||||
|
;; and push forward anyway, even if a missing grammar
|
||||||
|
;; results in a broken state.
|
||||||
|
(not (fboundp fallback-mode))
|
||||||
(cl-every (if (get mode '+tree-sitter-ensured)
|
(cl-every (if (get mode '+tree-sitter-ensured)
|
||||||
(doom-rpartial #'treesit-ready-p 'message)
|
(doom-rpartial #'treesit-ready-p 'message)
|
||||||
#'treesit-ensure-installed)
|
#'treesit-ensure-installed)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue