Treesitter not working when using home-manager + lazy.nvim

Hi everyone!

Sorry for the duplicate post. I looked through all the others and still could not get to a solution.

As the title suggests, I am trying to configure neovim using flakes + home-manager to install plugins and lazy.nvim for the configuration according to this guide

Unfortunately, no treesitter parsers are working besides the default parsers. Running checkhealth nvim-treesitter shows that it’s working find, just can’t find the parsers installed by nix.

I know this is a lazy.nvim thing overwriting/pointing to incorrect paths maybe (or not to the path in the nix store at all for the parsers) because when I comment out the lazy related code, the treesitter parsers work fine:

{ pkgs, config, inputs, ... }:
{
  programs.neovim = {
    enable = true;
    package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
    vimAlias = true;
    vimdiffAlias = true;
    withNodeJs = true;
    plugins = with pkgs.vimPlugins; [
      lazy-nvim
      nvim-treesitter
      nvim-treesitter.withAllGrammars
      plenary-nvim
      nui-nvim
      nvim-web-devicons
      neo-tree-nvim
      toggleterm-nvim
    ];
    extraLuaConfig = ''
      ${builtins.readFile ./lua/config/init.lua}
      
      require("lazy").setup({
        spec = {
          { import = "plugins" },
        },
      }, {
        performance = {
          reset_packpath = false,
          rtp = {
            reset = false,
          }
        },
        dev = {
          path = "${pkgs.vimUtils.packDir config.programs.neovim.finalPackage.passthru.packpathDirs}/pack/myNeovimPackages/start",
          patterns = {
            "nvim-treesitter",
            "akinsho",
            "utilyre",
            "SmiteshP",
            "nvim-neo-tree",
          },
        },
        install = {
          missing = false,
        },
      })

      require "nvim-treesitter.configs".setup {
        -- Managed with nixos
        auto_install = false,
        highlight = {
          enable = true
        },
        indent = {
          enable = true
        },
      }

    '';
  };

  xdg.configFile."nvim/lua" = {
    recursive = true;
    source = ./lua;
  };
}

here is my treesitter.lua

return {
  {
    "nvim-treesitter/nvim-treesitter",
    opts = {
      auto_install = false,
      ensure_installed = {},
    },
  },
}

.
β”œβ”€β”€ default.nix
└── lua
   β”œβ”€β”€ config
   β”‚  β”œβ”€β”€ init.lua
   β”‚  β”œβ”€β”€ keymaps.lua
   β”‚  └── options.lua
   └── plugins
      β”œβ”€β”€ neo-tree.lua
      β”œβ”€β”€ toggleterm.lua
      └── treesitter.lua

here is my repo, thank you in advance from a noob: repo

1 Like

I’m not sure whether this would be the source of the issue, but you shouldn’t have both of these. Only the latter.