Closed ktetzlaff closed 9 months ago
I kept flip-flopping in my head about whether the right way was an inclusion list or exclusion list for controlling which languages do/don't get used or installed, hence the seemingly duplicitous variables. Thanks for the motivating issue that tips the scales one way over the other.
I agree with the point about how the opt-out list should work, that seems like a pretty natural way for it to operate. I guess when first writing that I just assumed that if someone didn't want to use a tree-sitter mode, they'd remove it from their .emacs.d/tree-sitter
directory or treesit-extra-load-path
, but those don't count when libraries are installed under an admin directory, like /usr/lib or something where the user may or may not have editing privileges.
I entercounter this issue as well. Probably it's better to use existing built-in variables instead of introducing a new one?
I entercounter this issue as well. Probably it's better to use existing built-in variables instead of introducing a new one?
Concur — In fact, there is a global-treesit-auto-modes
variable that define-globalized-minor-mode
kind of declares by mistake, it would be nice if that variable did what it says in its doc string (AFAICT, right now it doesn't do anything at all)
Wild, I had no idea that global-treesit-auto-modes
even existed. So the idea here is that if an end user sets this variable directly, it would let them keep or remove specific modes for treesit-auto
?
For anyone stuck while waiting for a proper fix, this method works for me to prevent yaml-ts-mode
:
(when (require 'treesit nil t)
(use-package treesit-auto
:ensure t
:demand t
:config
(setq treesit-auto-install t)
(setq treesit-auto-opt-out-list '(yaml))
(treesit-auto-install-all)
(setq treesit-auto-install nil)
(global-treesit-auto-mode)))
Edit: You'll also have to delete the yaml tree-sitter .so
@ktetzlaff @theasp Feel free to try out the new feature on the treesit-auto-langs
branch.
treesit-auto-langs
behaves the way you describe in the OP; basically treesit-auto
will be completely disabled for anything not present in this list.(package-vc-install "https://github.com/renzmann/treesit-auto" "treesit-auto-langs")
I'm going to putz and test it a bit over the next day or two before merging in.
While experimenting with
treesit-auto
, I found it rather difficult to use tree sitter enabled modes for some/most languages and use non-tree-sitter modes for a few selected modes (like e.g. c/c++-mode).While it is great that
treesit-auto
provides an easy way to use treesit enabled modes, there doesn't seem to be an easy way to exclude certain languages from having the tree sitter support enabled automatically inmajor-mode-remap-alist
.There are the variables
treesit-auto-langs
andtreesit-auto-opt-out-list
. But both only seem to influencetreesit-auto-install-all
and thus do not inhibit languages from getting added tomajor-mode-remap-alist
.It would be great if e.g.
treesit-auto-opt-out-list
would be promoted to adefcustom
that actually not only stops languages from getting processed intreesit-auto-install-all
but also stops opted out languages from getting added tomajor-mode-remap-alist
.And by providing a real exclude option,
treesit-auto-langs
would probably not be needed anymore because it does not provide a way to add languages, but seems to be a more elaborate way to exclude languages (where, if you want to have tree-sitter support by default, you first need to build a list of all supported languages and then remove the ones which you don't want).I'd be happy to provide a pull request for that but would rather get some feedback first.