# PSA: if you are on unstable, try out nvim-treesitter.withAllGrammars

**URL:** https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321
**Category:** Announcements
**Created:** [November 18, 2022, 2:13am UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321 "2022-11-18T02:13:52Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![figsoda](https://discourse.nixos.org/user_avatar/discourse.nixos.org/figsoda/32/7760_2.png) [@figsoda](https://discourse.nixos.org/u/figsoda)
#### Post date: [November 18, 2022, 2:13am UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/1 "2022-11-18T02:13:52Z")

</div>

Note: This is for people on {nixos,nixpkgs}-unstable only

If you were using `vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)`, you can now switch to `vimPlugins.nvim-treesitter.withAllGrammars` to use the versions of tree sitter grammars specified in nvim-treesitter’s lock file.

If you were experiencing breakages with `withPlugins` and switched to `:TSInstall`, you can give the new version a try.

Refer to the [new docs](https://nixos.org/manual/nixpkgs/unstable/#managing-plugins-with-vim-packages) (scroll down to the treesitter section) for more information

People using `nvim-treesitter.withPlugins (ps: [...])` should automatically get the updates without changing anything

---

<div class="post-metadata">

### Author: ![mlyxshi](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mlyxshi/32/7049_2.png) [@mlyxshi](https://discourse.nixos.org/u/mlyxshi)
#### Post date: [December 15, 2022, 3:09am UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/2 "2022-12-15T03:09:56Z")

</div>

I would like to know the reason why [vimPlugins.nvim-treesitter: remove parser directory](https://github.com/NixOS/nixpkgs/commit/2500c9270b8644f2456d0821f39b25d42a8e7f22)

I prefer to use `neovim-unwrapped` and configure neovim with minimal configuration. This doesn’t work after the commit

```auto
xdg.configFile = {
    "nvim/init.lua".text = ''
      -- Add Treesitter Path
      vim.opt.runtimepath = vim.opt.runtimepath + "${pkgs.vimPlugins.nvim-treesitter.withAllGrammars}"
      -- Invoke Real Start
      require("start")
    '';
  };

```

---

<div class="post-metadata">

### Author: ![figsoda](https://discourse.nixos.org/user_avatar/discourse.nixos.org/figsoda/32/7760_2.png) [@figsoda](https://discourse.nixos.org/u/figsoda)
#### Post date: [December 15, 2022, 3:13am UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/3 "2022-12-15T03:13:19Z")

</div>

That was probably broken by [vimPlugins.nvim-treesitter: add plugins to dependencies to avoid extending vimPlugins by figsoda · Pull Request #201548 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/pull/201548) then, all the grammars are added to dependencies instead

A way to fix this would be to also add all of `pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies` to runtimepath

Edit: If you are worried that runtimepath would be too long, you can do a `symlinkJoin` of these

---

<div class="post-metadata">

### Author: ![mlyxshi](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mlyxshi/32/7049_2.png) [@mlyxshi](https://discourse.nixos.org/u/mlyxshi)
#### Post date: [December 15, 2022, 4:22am UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/4 "2022-12-15T04:22:37Z")

</div>

Thanks a lot. This works

```auto
let
  treesitter-parsers = pkgs.symlinkJoin {
    name = "treesitter-parsers";
    paths =[
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.c] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.lua] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.nix] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.bash] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.json] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.typescript] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.cpp] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.rust] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.python] )).dependencies
      (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.markdown] )).dependencies
    ];
  };
in
{
  xdg.configFile = {
    "nvim/init.lua".text = ''
      -- Add Treesitter Plugin Path
      vim.opt.runtimepath:append("${pkgs.vimPlugins.nvim-treesitter}")
      -- Add Treesitter Parsers Path
      vim.opt.runtimepath:append("${treesitter-parsers}")
      -- Invoke Real Start
      require("start")
    '';
  };

  home.packages = with pkgs;
    [
      neovim-unwrapped
      fd
      ripgrep
    ]
}

```

---

<div class="post-metadata">

### Author: ![figsoda](https://discourse.nixos.org/user_avatar/discourse.nixos.org/figsoda/32/7760_2.png) [@figsoda](https://discourse.nixos.org/u/figsoda)
#### Post date: [December 15, 2022, 4:35am UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/5 "2022-12-15T04:35:41Z")

</div>

btw, you should be able to simplify that to

```nix
[...]
paths = (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [p.c p.lua p.nix p.bash ...])).dependencies
[...]

```

---

<div class="post-metadata">

### Author: ![wheelsandmetal](https://discourse.nixos.org/user_avatar/discourse.nixos.org/wheelsandmetal/32/3149_2.png) [@wheelsandmetal](https://discourse.nixos.org/u/wheelsandmetal)
#### Post date: [March 31, 2023, 4:40pm UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/6 "2023-03-31T16:40:16Z")

</div>

I’m on unstable and using home-manger to configure my neovim install.

```nix
{ config, pkgs, ...}:
let
    nvim-plugintree = (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [
        p.c
        p.lua
        p.nix
        p.bash
        p.cpp
        p.json
        p.python
        p.markdown
    ]));

    treesitter-parsers = pkgs.symlinkJoin {
      name = "treesitter-parsers";
      paths = nvim-plugintree.dependencies;
    };
in
{
  programs.neovim = {
    enable = true;
    vimAlias = true;
    plugins = with pkgs.vimPlugins; [
      nvim-plugintree
    ];

    extraConfig = ''
      lua require('init')
    '';
  };

  xdg.configFile = {
    "nvim/lua/init.lua".text = ''
      -- Add Treesitter Plugin Path
      vim.opt.runtimepath:append("${nvim-plugintree}")
      -- Add Treesitter Parsers Path
      vim.opt.runtimepath:append("${treesitter-parsers}")

      require('start')
    '';
    "nvim/lua/start.lua".source = ./start.lua;
  };

  home.packages = with pkgs; [
    tree-sitter
  ];
}

```

I think this is all the relevent parts of my config. I use nix flakes to build the system.

Opening neovim and it still errors with `read-only file system`. Weirdly though the highlighting is working.

This didn’t work for me properly before your change so it may be unrelated, any insights would be welcome though!

---

<div class="post-metadata">

### Author: ![figsoda](https://discourse.nixos.org/user_avatar/discourse.nixos.org/figsoda/32/7760_2.png) [@figsoda](https://discourse.nixos.org/u/figsoda)
#### Post date: [March 31, 2023, 5:01pm UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/7 "2023-03-31T17:01:42Z")

</div>

Do you have anywhere in your config that runs `TSUpdate` or `TSInstall`?

---

<div class="post-metadata">

### Author: ![wheelsandmetal](https://discourse.nixos.org/user_avatar/discourse.nixos.org/wheelsandmetal/32/3149_2.png) [@wheelsandmetal](https://discourse.nixos.org/u/wheelsandmetal)
#### Post date: [March 31, 2023, 5:05pm UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/8 "2023-03-31T17:05:00Z")

</div>

No, not in the config files. And running it manually in neovim ofc has the same error

---

<div class="post-metadata">

### Author: ![superpim](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@superpim](https://discourse.nixos.org/u/superpim)
#### Post date: [September 27, 2023, 4:44pm UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/9 "2023-09-27T16:44:12Z")

</div>

This might be late, but I had the same issue, and it was fixed when I flipped this:

```auto
require("nvim-treesitter.configs").setup({
    ....
    -- Automatically install missing parsers when entering buffer
    auto_install = false, <-- This was set to true before
    ....
})

```

This issue is cause by nvim either wanting to install something additionally as mentioned by @figsoda.

This is a late contribution, but I hope I point someone in the right direction. The pointers above helped me a lot.

If not this, look for other places where you automagically install things. That should especially be applicable when migrating an existing config to nix (as suddenly you move to read-only)

---

<div class="post-metadata">

### Author: ![lokeshmohanty](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lokeshmohanty/32/11607_2.png) [@lokeshmohanty](https://discourse.nixos.org/u/lokeshmohanty)
#### Post date: [November 16, 2023, 5:57am UTC](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321/10 "2023-11-16T05:57:34Z")

</div>

Hi, I am new to nixos and this works but I have a doubt.  
How do I find such packages? I tried the following

- nix search nixpkgs nvim-treesitter
- nix-env -qaP nvim-treesitter
- Queried on the nix packages search online

None of them showed this package. I want a similar package for emacs but don’t know how to find.
