Commit Graph

142 Commits

Author SHA1 Message Date
Henrik Lissner
4c9dee2c78 fix(tree-sitter): treesit-extra-load-path: use file-name-concat
In case doom-profile-data-dir doesn't end with a slash (which is a
stipulation I won't be enforcing for Doom's dir variables in v3 and
beyond).

Fix: #8511
2025-09-17 17:49:22 -04:00
Henrik Lissner
4a6f9f741d feat(tree-sitter): add +tree-sitter/doctor command
For a quick diagnosis of the state of tree-sitter support in the current
buffer.
2025-09-17 01:23:45 -04:00
Henrik Lissner
5614faca7a docs(tree-sitter): revise installation docs
To clarify how to enable tree-sitter, fully.
2025-09-17 01:23:45 -04:00
Henrik Lissner
35d2934727 refactor(tree-sitter): dynamic-modules doctor check 2025-09-15 18:53:31 -04:00
Henrik Lissner
71ec9a9733 fix: backport treesit-available-p sooner
This fixes Doom for Emacs 27-28 users (or builds without treesit).
2025-09-15 18:53:31 -04:00
Henrik Lissner
d6cdbb4d22 docs(tree-sitter): document treesit-font-lock-level
Close: #8487
2025-09-11 23:37:14 -04:00
Henrik Lissner
1adec8b10c fix(tree-sitter): add derived-mode parents to ts-modes
ts-modes do this already in 30/31+ (`derived-mode-add-parents` was added
in 30), but is still needed for 29.x users and any ts-modes that haven't
adapted (many of them).

Fix: doomemacs/community#29
2025-09-07 10:58:45 -04:00
Henrik Lissner
ddc447d9d5 tweak(tree-sitter): treesit-font-lock-level = 4
Fix: #8494
Close: #8487
2025-09-05 15:10:57 -04:00
Henrik Lissner
5ca9b7a37a fix(tree-sitter): autodef treesit-available-p
This way, whether the module is enabled or not, `treesit-available-p`
will exist, even in Emacs build without treesit.

Amend: a51690f033
2025-09-03 16:29:16 +02:00
Henrik Lissner
78068a8f31 fix(tree-sitter): more verbosity in debug mode
And slightly better logged message if the grammar is missing.
2025-09-03 16:28:45 +02:00
Henrik Lissner
d1289bf8cf fix(tree-sitter): remove *-ts-mode-maybe from {auto,interpreter}-mode-alist
Again, removing more over-eager entries.

Also fixes `set-tree-sitter!` not accepting multiple MODEs before.
2025-09-03 14:44:51 +02:00
Henrik Lissner
8dab364e46 fix(tree-sitter): suppress changes to {auto,interpreter}-mode-alist
...when auto-loading a ts-mode package.
2025-09-03 14:42:28 +02:00
Henrik Lissner
bbed615f17 feat(tree-sitter): batch grammar installs
Instead of being prompted 2-4 times to install each missing grammar,
batches them together into one prompt.
2025-09-02 16:16:02 +02:00
Henrik Lissner
79a9418cba fix(tree-sitter): backport treesit-*-abi-version
So we don't have to litter these checks with feature/fboundp
checks (there will potentially be many of them).
2025-09-02 03:28:40 +02:00
Henrik Lissner
a51690f033 fix(:lang): add treesit-available-p checks to *-ts-mode packages
Otherwise package installation will throw Emacs version errors for users
on 28 and under.
2025-09-01 20:11:02 +02:00
Henrik Lissner
84e8ae58d1 refactor(:lang): remove fboundp checks for *-ts-modes
The major-mode-remap advice will handle undefined modes, so all these
extra checks aren't needed.
2025-09-01 20:11:02 +02:00
Henrik Lissner
1dae2bf916 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.
2025-08-31 16:20:14 +02:00
Henrik Lissner
94a1fe64a8 fix(tree-sitter): suppress "Can't find grammar" warnings
In Emacs <=30, top-level `treesit-ready-p` calls in various *-ts-mode
packages (like lua-ts-mode or ruby-ts-mode) are commonplace, and they
throw up a warning popup if the grammar isn't available at load time.
This is intrusive. Instead, this forces it to log to *Messages* instead
before falling back to the normal major mode.

Fortunately, these top-level `treesit-ready-p` calls have been removed
in most *-ts-mode packages in 31+, but this still impacts users on <=30
or using third party *-ts-modes that haven't adapted.

However, this doesn't suppress the warning when opening a *-ts-mode.el
file (thanks to the byte-compiler).
2025-08-31 14:41:40 +02:00
Henrik Lissner
d545fccf47 fix(:lang): missing grammar recipes
I removed the grammar recipes in 3b58741 to avoid redundancy with the
upstream recipes, but didn't realize that those upstream recipes weren't
added until Emacs 31, so users on 30 and older would get errors when
trying to install any missing grammars.

This also establishes a hard dependency between :lang (php +tree-sitter)
and :lang ({javascript,web} +tree-sitter).

Amend: 3b58741522
2025-08-31 14:39:38 +02:00
Henrik Lissner
d9fd5cb8f3 fix(tree-sitter): treesit-enabled-modes: sort arity in <30
`sort`s signature changed in Emacs 30 from:

  (sort SEQ PREDICATE)

To

  (sort SEQ &key KEY LESSP REVERSE IN-PLACE)

Amend: 6009c2b838
2025-08-31 14:34:45 +02:00
Henrik Lissner
7dcedc16b5 refactor(tree-sitter): major mode remapping
This approach simplifies the hacks and uses fewer moving parts to be
less error prone (or prone to potentially overwriting user/module
configuration).
2025-08-30 09:41:25 +02:00
Henrik Lissner
702d976665 docs(tree-sitter): document module hacks 2025-08-29 14:37:10 +02:00
Henrik Lissner
cd5dd5279e fix(tree-sitter): major mode remapping on first-load
Also refactors +tree-sitter--major-mode-remaps-alist to be lighter.
2025-08-29 14:35:49 +02:00
Henrik Lissner
bd0bee92cc feat!(javascript): add treesit support
BREAKING CHANGE: This commit removes a number of core packages and
features from this module and only replaces a handful of them, so that
we can lean more on LSP and tree-sitter. To be specific:

- We used to rely on `rjsx-mode` (derived from js2-mode) for total
  JS/JSX support (though imperfect; Emacs was starved for options at the
  time). This has now been replaced with `js-ts-mode` (built-in after
  Emacs 29), falling back to `js-mode` (very rudimentary, but a decent
  fallback).
- This also meant the removal of `js2-mode`, which `skewer-mode`,
  `js2-refactor`, and `xref-js2` depended on, so those were removed
  too, and have *somewhat* been replaced with LSP integration (offers
  jump-to-definition/references and *some* refactoring actions, but no
  replacement for skewer's functionality).
- Typescript support no longer relies on the jury-rigged, web-mode-derived
  major mode (because TSX support in the upstream `typescript-mode`
  isn't great). We now use `typescript-ts-mode` (built-in into Emacs
  29.1+), falling back to `typescript-mode`.
- JSX/TSX support now *requires* tree-sitter (and Emacs 29.1+), where
  `tsx-ts-mode` is available and outshines all the alternatives (at the
  time of writing).

Due to the absolute chaos that is webdev, this module sacrifices some of
the graceful-degradation I've implemented for other modules and creates
a hard requirement on tree-sitter and Emacs 29.1+ for JSX/TSX. It still
tries to degrade gracefully for plain JS and TS, but the module's doctor
and docs will actively recommend tree-sitter.

Close: #5278
Fix: #6172
Fix: #7042
Close: #8447
Co-authored-by: ribaricplusplus <ribaricplusplus@users.noreply.github.com>
2025-08-29 14:35:49 +02:00
Henrik Lissner
64b4e565c3 refactor(tree-sitter): remove redundant grammars
Already registered by csharp and web module packages.

Amend: 5bf132a80f
Amend: c403bb5e2f
2025-08-28 14:32:08 +02:00
Henrik Lissner
3b58741522 refactor(tree-sitter): centralize grammar config & hacks
Easier to track and maintain.
2025-08-27 16:57:28 +02:00
Henrik Lissner
6009c2b838 fix(tree-sitter): backport treesit-{enabled-modes,major-mode-remap-alist}
And ignore `treesit-major-mode-remap-alist`, because they could
interfere with our UX improvements.
2025-08-23 18:43:14 +02:00
Henrik Lissner
2adbdf1360 feat(clojure): add treesit support 2025-06-30 15:16:26 +02:00
Henrik Lissner
7949d1bf27 fix(tree-sitter): void-variable +tree-sitter--major-mode-remaps-alist
This is a temporary solution and will be polished up before the treesit
branch is merged into master.

Ref: #7623
Amend: 617d8411e6
2025-06-30 14:48:54 +02:00
Henrik Lissner
a8ccd2d47a fix(tree-sitter): unable to find local grammars (part 2)
Ref: #7623
Amend: 4df993d683
2025-06-30 14:47:35 +02:00
Henrik Lissner
0d9cf54c84 refactor(tree-sitter): remove redundant dart grammar
Amend: a287a96aca
2025-06-28 21:17:15 +02:00
Henrik Lissner
7c6e1950e8 feat(go): add treesit support 2025-06-28 20:10:08 +02:00
Henrik Lissner
617d8411e6 fix(tree-sitter): ignore major-mode-remap-defaults for ts modes
...registered with `set-tree-sitter!`. Then we don't have to chase after
packages inconsistently modifying `major-mode-remap-defaults`.
2025-06-28 19:32:27 +02:00
Henrik Lissner
4df993d683 fix(tree-sitter): unable to find local grammars
Ref: #7623
2025-06-28 17:37:24 +02:00
Henrik Lissner
5b37bfee23 feat(nix): add treesit support 2025-05-24 17:27:30 +02:00
Henrik Lissner
3b2caa7dcd feat(docker): add treesit support 2025-05-24 17:11:40 +02:00
Henrik Lissner
7af7280f9e feat(json): add treesit support 2025-05-22 19:53:10 +02:00
Henrik Lissner
f5a1af4bf6 feat(kotlin): add treesit support 2025-05-22 19:50:29 +02:00
Henrik Lissner
c5dd2847ff feat(scala): add treesit support 2025-05-22 19:50:29 +02:00
Henrik Lissner
5db361b474 fix(tree-sitter): remove redundant yaml source
Amend: 2556cb58f2
2025-05-22 18:32:04 +02:00
Henrik Lissner
0c311a5172 feat(elixir): add treesit support 2025-05-22 18:32:03 +02:00
Henrik Lissner
a329d63f7d fix(tree-sitter): discard COMMIT recipe argument on <=30.x
Otherwise `treesit--install-language-grammar-1` will throw an arity
error on Emacs <=30.x when installing grammars.

Fix: #8393
2025-05-16 08:49:20 +02:00
Henrik Lissner
b546522257 docs(tree-sitter): revise doctor output 2025-05-15 18:58:29 +02:00
Henrik Lissner
1670ce2767 feat!(cc): add treesit support
BREAKING CHANGE: Besides treesit support, this removes a few
fontification enhancements (in favor of tree-sitter).
2025-05-15 13:01:40 +02:00
Henrik Lissner
46b87362f7 feat(julia): add treesit support 2025-05-15 13:01:40 +02:00
Henrik Lissner
f002424106 feat(lua): add treesit support 2025-05-15 13:01:40 +02:00
Henrik Lissner
445c982838 feat(ruby): add treesit support 2025-05-15 13:01:40 +02:00
Henrik Lissner
a372eba7cd feat(python): add treesit support 2025-05-15 13:01:39 +02:00
Henrik Lissner
1ac1b70d4e refactor!(tree-sitter): replace tree-sitter w/ treesit
BREAKING CHANGE: This rewrites the :tools tree-sitter module to use
treesit instead of tree-sitter.el. Users will need to adapt to treesit
and remove any tree-sitter-specific config in their dotfiles.

Ref: #7623
Ref: #7742
Ref: #8197
2025-05-15 13:01:29 +02:00
Henrik Lissner
50200762cd bump: :tools
doomelpa/code-review@fba8fe3343 -> doomelpa/code-review@303edcfbad
emacs-citar/citar@ce5e9644ed -> emacs-citar/citar@5ef097beba
emacs-lsp/lsp-mode@54251da4ff -> emacs-lsp/lsp-mode@c77ba14106
emacs-straight/dape@588a907c87 -> emacs-straight/dape@8dbe56d7c7
emacs-straight/eglot@6a9e0c76b9 -> emacs-straight/eglot@0b0f894713
emacs-tree-sitter/elisp-tree-sitter@12f92ef399 -> emacs-tree-sitter/elisp-tree-sitter@1c455b0953
emacs-tree-sitter/tree-sitter-langs@4eb4989d1a -> emacs-tree-sitter/tree-sitter-langs@becd29c756
emacsorphanage/quickrun@a5c9a5e8c6 -> emacsorphanage/quickrun@bae8efb8c5
karthink/gptel@1aa5f1c10d -> karthink/gptel@e1050ef6e5
magit/magit@531e7ca619 -> magit/magit@04ee83d93f
2025-05-15 11:39:50 +02:00