mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-31 14:43:40 -05: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:
@@ -2,9 +2,7 @@
|
||||
;;; lang/javascript/packages.el
|
||||
|
||||
;; Major modes
|
||||
(unless (or (modulep! +tree-sitter)
|
||||
(fboundp 'treesit-available-p)
|
||||
(treesit-available-p))
|
||||
(unless (modulep! +tree-sitter)
|
||||
(package! typescript-mode :pin "481df3ad2cdf569d8e6697679669ff6206fbd2f9"))
|
||||
|
||||
;; Extensions
|
||||
|
@@ -60,7 +60,12 @@
|
||||
(or (not (autoloadp fn))
|
||||
(autoload-do-load fn mode)))
|
||||
;; 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)
|
||||
(doom-rpartial #'treesit-ready-p 'message)
|
||||
#'treesit-ensure-installed)
|
||||
|
Reference in New Issue
Block a user