nix-community / nixvim

Configure Neovim with Nix! [maintainer=@GaetanLepage, @traxys, @mattsturgeon, @khaneliman]
https://nix-community.github.io/nixvim
MIT License
1.56k stars 242 forks source link

treesitter: clarify docs relating to `nixGrammars` and `ensure_installed` #1865

Open wskeele opened 1 month ago

wskeele commented 1 month ago
Field Description
Plugin treesitter
Nixpkgs unstable

Description

Previous behavior for treesitter was that each grammar package was built and installed by nix. Now I get this message when opening nvim, which prevents it from being usable:

[nvim-treesitter] [244/281] Treesitter parser for odin has been installed
[nvim-treesitter] [245/281] Treesitter parser for agda has been installed
[nvim-treesitter] [246/281] Treesitter parser for ruby has been installed
[nvim-treesitter] [247/281] Treesitter parser for elixir has been installed
[nvim-treesitter] [248/281] Treesitter parser for hlsl has been installed
[nvim-treesitter] [249/281] Treesitter parser for cuda has been installed
[nvim-treesitter] [250/281] Treesitter parser for llvm has been installed
[nvim-treesitter] [251/281] Treesitter parser for typst has been installed
[nvim-treesitter] [252/281] Treesitter parser for vim has been installed
[nvim-treesitter] [253/281] Treesitter parser for unison has been installed
[nvim-treesitter] [254/281] Treesitter parser for cue has been installed
[nvim-treesitter] [255/281] Treesitter parser for haskell has been installed
[nvim-treesitter] [256/281] Treesitter parser for snakemake has been installed
[nvim-treesitter] [257/281] Treesitter parser for slang has been installed
[nvim-treesitter] [258/281] Treesitter parser for d has been installed
[nvim-treesitter] [259/281] Treesitter parser for elvish has been installed
[nvim-treesitter] [260/281] Treesitter parser for kotlin has been installed
[nvim-treesitter] [261/281] Treesitter parser for sql has been installed
[nvim-treesitter] [262/281] Treesitter parser for purescript has been installed
[nvim-treesitter] [263/281] Treesitter parser for c_sharp has been installed
[nvim-treesitter] [264/281] Treesitter parser for norg has been installed
[nvim-treesitter] [265/281] Treesitter parser for ocaml_interface has been installed
[nvim-treesitter] [266/281] Treesitter parser for perl has been installed
[nvim-treesitter] [267/281] Treesitter parser for scala has been installed
[nvim-treesitter] [268/281] Treesitter parser for verilog has been installed
[nvim-treesitter] [269/281] Treesitter parser for ocaml has been installed
[nvim-treesitter] [270/281] Treesitter parser for gitcommit has been installed
[nvim-treesitter] [271/281] Treesitter parser for tlaplus has been installed
-- More --

At some point "more" just freezes and it becomes impossible to use or exit nvim at all.

Minimal, Reproducible Example (MRE)

programs.nixvim = {
  enable = true;
  plugins.treesitter = {
    enable = true;
    settings.ensure_installed = "all";
  };
}
MattSturgeon commented 1 month ago

Not sure what's going on here, because grammarPackages defaults to plugins.treesitter.package.passthru.allGrammars and nixGrammars defaults to true. So the nix grammars are installed by default, as was done before.

Maybe the plugin's (upstream) option ensure_installed doesn't know about nix grammar packages so it tries to build its own?

Since you set that explicitly, we will just pass it to the plugin to do as it likes with your value. We used to silently ignore ensure_installed when nixGrammars was true.

I think the proper fix is to print a warning when nixGrammars is used together with ensure_installed.

wskeele commented 1 month ago

Ok, so at least, a simple workaround is just to remove the line:

settings.ensure_installed = "all";
khaneliman commented 2 weeks ago

Not exactly sure how to approach a warning here. I could see explaining the interaction of these options better in the docs, but there would be a real use case for someone wanting stuff installed through nixGrammars and then having something else provided from ensure_installed.

MattSturgeon commented 2 weeks ago

That's reasonable. Since we don't have a way to silence warnings I think updating the descriptions is the best approach.

We should probably note in the ensure_installed description that it relates to grammars installed by the plugin and usually isn't needed when using nixGrammars.