emacs-tree-sitter / elisp-tree-sitter

Emacs Lisp bindings for tree-sitter
https://emacs-tree-sitter.github.io
MIT License
827 stars 74 forks source link

Setting (global-tree-sitter-mode) in config.el causes warning on Emacs startup #286

Open mayersj1 opened 5 months ago

mayersj1 commented 5 months ago

Adding (global-tree-sitter-mode) in my config.el causes the following warning to be thrown:

error No language registered for major mode 'fundamental-mode'

Shouldn't this just be a no-op for fundamental-mode. The entire purpose of (global-tree-sitter-mode) is so that I don't need to add my own hooks for each and every mode.

offbyone commented 5 months ago

For me it actually breaks startup; I'm using the doom emacs configuration, with fold enabled. fold triggers (ts-fold-mode +1) which triggers a tree-sitter--handle-dependent macro. That macro runs this:

         (progn
           (tree-sitter--error-protect
               ;; Make sure `tree-sitter-mode' is enabled before MODE.
               (progn
                 (unless tree-sitter-mode
                   (tree-sitter-mode))
                 ,setup)
             ;; Setup failed. Clean things up, leave no trace.
             (setq ,mode nil)
             ,teardown) ...

For whatever reason, this unwind-protect isn't working; running doom with fold and tree-sitter enabled results in an init error, and running it with --debug-init gives me the trace that led me here.

Doom is 3.0.0-pre tree-sitter-mode is at 02fe7b8