Managing tree-sitter-parsers via luarocks

With nvim-treesitter being archived a couple weeks ago, I’ve begun trying to manage my tree-sitter parsers manually the same way I do for language servers, which basically just entails downloading them with external package managers. Managing tree-sitter parsers seems to be more involved at the moment. I’m following this article here: Native Treesitter in Neovim • Steve Simkins

The process is basically using luarocks to download the parsers into the Neovim runtimepath so that when running vim.treesitter.start() it will load the parser, but I am running into some problems.

I installed luajitPackages.luarocks and I’ve also tried luajitPackages.luarocks-nix, though I don’t think it matters which one I use for this particular use case (correct me if I’m wrong). I’ve also tried installing tree-sitter and luajitPackages.tree-sitter-cli, but I’m not sure which one is the correct one and I can’t seem to find any information about it. When I run the command to install a parser (in this case tree-sitter-go) it gives me the following error (I included the full output just in case someone catches something I missed, but the error starts about halfway down):

luarocks --lua-version=5.1 --tree=$HOME/.local/share/nvim/site install tree-sitter-go
Installing luarocks.org/tree-sitter-go-0.0.44-1.src.rock

tree-sitter-go 0.0.44-1 depends on luarocks-build-treesitter-parser >= 6.0.2 (6.0.2-1 installed: success)

tree-sitter-go 0.0.44-1 depends on lua >= 5.1 (5.1-1 provided by VM: success)

Error: Failed initializing build back-end for build type 'treesitter-parser': module 'luarocks.build.treesitter-parser' not found:Failed loading module luarocks.build.treesitter-parser in LuaRocks rock luarocks-build-treesitter-parser 6.0.2-1
        no field package.preload['luarocks.build.treesitter-parser']
        no file '/nix/store/96zvl7pbipjvgyrs752gqmc2bm7lf8a5-luarocks-nix-nix_v3.5.0-1-unstable-2026-03-31/share/lua/5.1/luarocks/build/treesitter-parser.lua'
        no file '/nix/store/96zvl7pbipjvgyrs752gqmc2bm7lf8a5-luarocks-nix-nix_v3.5.0-1-unstable-2026-03-31/share/lua/5.1/luarocks/build/treesitter-parser/init.lua'
        no file '/home/winstonji/.luarocks/share/lua/5.1/luarocks/build/treesitter-parser.lua'
        no file '/home/winstonji/.luarocks/share/lua/5.1/luarocks/build/treesitter-parser/init.lua'
        no file 'luarocks/build/treesitter-parser.so'
        no file '/nix/store/96zvl7pbipjvgyrs752gqmc2bm7lf8a5-luarocks-nix-nix_v3.5.0-1-unstable-2026-03-31/share/lua/5.1/luarocks/build/treesitter-parser/init.lua'
        no file '/home/winstonji/.luarocks/lib/lua/5.1/luarocks/build/treesitter-parser.so'
        no file '/nix/store/96zvl7pbipjvgyrs752gqmc2bm7lf8a5-luarocks-nix-nix_v3.5.0-1-unstable-2026-03-31/lib/lua/5.1/luarocks/build/treesitter-parser.so'
        no file 'luarocks.so'
        no file '/nix/store/96zvl7pbipjvgyrs752gqmc2bm7lf8a5-luarocks-nix-nix_v3.5.0-1-unstable-2026-03-31/share/lua/5.1/luarocks/init.lua'
        no file '/home/winstonji/.luarocks/lib/lua/5.1/luarocks.so'
        no file '/nix/store/96zvl7pbipjvgyrs752gqmc2bm7lf8a5-luarocks-nix-nix_v3.5.0-1-unstable-2026-03-31/lib/lua/5.1/luarocks.so'

I wasn’t exactly sure what was going on but ChatGPT seems to think the problem is that luarocks can’t find the binary where it’s being installed. I’m not really sure why but I think it has something to do with missing environment variables that i need to configure. If anyone has ever tried this, I would really appreciate some pointers.

Not sure if it makes a difference in this case, but people trying to help me often want to know that I am using flakes and home-manager for my configuration, but I am managing my neovim configuration myself outside of home-manager. I have also migrated over to Neovim 0.12.2 using the native package manager instead of lazy.nvim.

From what I can see, ChatGPT wasn’t entirely wrong, you need to correctly set your LUA_PATH environment variable so Luarocks can locate the missing treesitter-parser build dependency on NixOS. I’m no expert, but that’s what I’d start looking into.

I can’t provide insight here, but I am interested in a solution.

Using Neovim (nightly, without Home Manager) on NixOS has been challenging whenever external binaries become involved. Treesitter, LSP, Mason, most things non-LUA — painful. I have temporarily resorted to disabling both Treesitter and LSP plugins, which is obviously not viable for long.

Just add LSPs to your environment.systemPackages (or, even better, your devShells). Don’t use Mason, it’s unneeded with Nix. Also, if you really don’t want HM but would like to have a more Nix-y experience with Neovim, I highly recommend the nix-wrapper-modules Neovim module, so you can manage Neovim plugins and LSPs from Nix without HM.

Mason is pulled in as a dependency by the nvim-lspconfig plugin. I share my Neovim configuration across platforms, and all but NixOS play nice with that arrangement. I want to change as little as possible to satisfy NixOS’s special nature, if only to keep my sanity. :wink:

For me nvim-treesitter.withAllGrammars just works. Even though it still depends on the abandoned nvim-treesitter, I am pretty sure, there will be a solution soon, that then requires a reorientation anyway.

Whether you use nixvim, nix-wrappers, mnw, nvf, HM or just “pure lua”. As soon as there is a recommended alternative, we have to find a way to adapt that into whatever style we use to manage our configurations.

2 Likes

Hmm, I don’t see any dependency between either of those, so I assume it’s something specific to your config. My best suggestion is to make your config so that lspconfig is not loading Mason so Mason can only loaded on non-NixOS platforms. For treesitter I think you just need to get nvim-treesitter.withAllGrammars loaded on NixOS with no :TSUpdate, but somehow loading nvim-treesitter the non-Nix way with :TSUpdate on non-Nix systems. There should be some way to do both of these. Or just set up HM and manage all your systems with Nix, which is honestly probably the simpler solution unless you have some absurdly restrictive corporate device that prevents you from installing Nix.

@bitbloxhub My current Neovim configuration is based on Kickstart.nvim, hence the dependency on Mason. Similarly, I have so far configured Treesitter in the way Kickstart recommends, but the author obviously has not taken NixOS into account. I understand that I need to make changes, of course, and I am not trying to be obstinate. This is just me trying to figure out how best to proceed in my specific situation.

@NobbZ Perhaps I have chosen an unopportune moment in time, given the current state of Treesitter. I am sure that changes are to be expected.

nixCats-nvim/templates/kickstart-nvim at main · BirdeeHub/nixCats-nvim · GitHub may be of some help, nixCats is the predecessor to the nix-wrapper-modules Neovim module, and you may be able to adapt some of it to the new nix-wrapper-modules lua APIs (require(vim.g.nix_info_plugin_name)).

@bitbloxhub nixCats looks interesting, as does the Neovim wrapper
module
. It is good to have options to investigate.

By the way, I have experimented with dropping Mason in general. It seems only to be used for the purpose of automatic installation of LSP binaries etc., and that is something I can do without.

1 Like

luarocks-nix is a fork of luarocks that generates nix expressions for nixkgs. So apart if you want to package luarocks packages in nix you shouldn’t have to use it (and even then you should use the nixpkgs lua updater instead).

The tree-sitter grammars uploaded to luarocks.org are done by the “neorocks“ organization mostly Search 'tree-sitter' - LuaRocks so these are not upstream packages and guess what they use nvim-treesitter as a source for their package, same as nixpkgs so you end up with the same grammar as vimPlugins.tree-sitter-XXX :slight_smile:

There is nothing broken yet so I think the best thing to do is to chill and see. Maintainer wanted to touch grass, maybe he will unarchive the project, maybe the neovim org will adopt it but for now the best solution is IMO to wait and see.

2 Likes

The original intent was to use luarocks to manage the treesitter parsers, but if there’s a way to install parsers with nix and have neovim be able to use them, I’d be interested in that solution as well.