Closed RangHo closed 11 months ago
Thanks!
"Merged". (Side-note:)
Unfortunately this pull-request asks for your master
branch to be merged into ours. It is better to use a dedicated feature branch instead, as explained here. It is too late for this pull-request now, but the next time you open a pull-request (in any repository really), then please use a feature branch.
This is a canned response; it may not apply 100% in this case.
This change causes issues for Nix users; those of us who use Nix to install our tree-sitter grammars have our Emacs' treesit-extra-load-path
updated by Nix (using add-to-list
) to contain /nix/store/hash123-emacs-packages-deps/lib
: https://github.com/nixos/nixpkgs/blob/6a19af3e00770531136d8f27e3a452a549224bf4/pkgs/build-support/emacs/wrapper.nix#L166-L168
When I start up my Emacs, since this commit tosses out the Nix-prescribed update to treesit-extra-load-path
, Emacs does not know where to find my pre-installed grammars.
Consequently, I am now using this in my config:
(let ((old-val treesit-extra-load-path))
(use-package no-littering
:ensure t
:demand t
:config
(setq treesit-extra-load-path old-val)))
Ideally, upstream Emacs would use some defcustom
somewhere here instead of hard-coding: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/treesit.el?h=ff1f82cbe3fa9aee354581f2798faaae7163ea44#n3424
Reverting for now. I was on the fence about this. Will have to think about it more. Open to suggestions.
This change causes issues for Nix users; those of us who use Nix to install our tree-sitter grammars have our Emacs' treesit-extra-load-path updated by Nix
Geez, I was unaware of this. I shouldn't have assumed that distros don't meddle with default configurations... Sorry about that.
Ideally, upstream Emacs would use some defcustom somewhere here instead of hard-coding
I agree. Fiddling with the history variable as the initial commit I made was a pretty bad, but the only solution as well...
Since treesit-extra-load-path
is a list of search paths, would it be possible to use add-to-list
instead of regular setq
to register the alternative paths?
While this add-to-list-if-defined structure will deviate from the rest of the configurations using setq
only, I guess this is pretty much the only solution versatile enough to reconcile for differences in default configs. Well, until upstream creates a new custom variable, that is.
Let's wait until this has been improved upstream. (And by "wait", I mean "feel free to bring this up upstream". :grinning: )
Theme
treesit--install-language-grammar-out-dir-history
, andtreesit-extra-load-path
.The
treesit
component introduced since Emacs 29 requires that you build grammar libraries for each language you want to parse. Unfortunately, the default hard-coded search path for said libraries isuser-emacs-directory/tree-sitter
, littering our.emacs.d
once again.This patch reconciles this by:
var
directory (treesit-extra-load-path
),treesit-install-language-grammar
interactive function (treesit--install-language-grammar-out-dir-history
).Oddities
Unlike specified in the README file, the directory is named
tree-sitter
, instead oftreesit
, since it contains shared object artifacts that technically can be used by the legacy tree-sitter integration as well.Also, the variable
treesit--install-language-grammar-out-dir-history
is not yet present on Emacs 29.1.90, and the interactive functiontreesit-install-language-grammar
always litters the Emacs directory. The relevant patch was already made in April in commit emacs-mirror/emacs@c146bd893dfbc8a4c92f9d1f33def8f29e7ece1f, though.