How to setup the new nvim-treesitter via home-manager?

Hello.

I’m using home-manager to setup my neovim and all was good until nvim-treesitter changed to a new version (nixpkgsnow tracks the plugin from the main branch, which is not backwards-compatible).

I had this home-manager configuration:

programs.neovim.plugins = with pkgs.vimPlugins; [
  {
    plugin = nvim-treesitter.withAllGrammars;
    type = "lua";
    config =
      ''
        require('nvim-treesitter.configs').setup {
          highlight = {
            enable = true,
          },
          indent = {
            enable = true,
          },
        }
      '';
  }
]

This was enough to bring all grammars for syntax highlight. But this config is broken for the new plugin.

I’m trying to configure the new version, but I’m failing to get proper syntax highlight. This is what I currently have:

programs.neovim.plugins = with pkgs.vimPlugins; [
  {
    plugin = nvim-treesitter
    type = "lua";
    config =
      ''
        -- Setup parsers
        require('nvim-treesitter').install({
          'bash',
          'go',
          -- etc
        })

        -- Highlight
        vim.api.nvim_create_autocmd('FileType', {
          pattern = { '<filetypes>' },
          callback = function() vim.treesitter.start() end,
        })

        -- Fold
        vim.wo[0][0].foldexpr = 'v:lua.vim.treesitter.foldexpr()'
        vim.wo[0][0].foldmethod = 'expr'

        -- Indentation
        vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
      '';
  }
]

I also had to add tree-sitter to environment.systemPackages. Also, :checkhealth looks fine.

This new config is not giving me good syntax highlight, like I had before. What am i missing? How do I setup this new version via home-manager?

treesitter doesn’t support the filetype <filetypes>, and it is unlikely you even have such a filetype.

Please register one autocmd for each filetype you actually use.

I have this function:

And I use it like this: