nix-community / nixvim

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

Error with treesitter plugin #39

Closed gador closed 2 years ago

gador commented 2 years ago

Hi, I'm getting the following error:

Line   65:
Parser dir ' /nix/store/vhlasav5vp7c83ck32gq6csf205i06gg-vim-pack-dir/pack/myNeovimPackages/start/nvim-treesitter/parser ' should be read/write (see README on how to configure an alternative install location) /nix/store/vhlasav5vp7c83ck32gq6csf205i06gg-vim-pack-dir/pack/myNeovimPackages/start/nvim-treesitter/parser '

My config is the following:

programs.nixvim = {
        enable = true;
        colorschemes.base16 = {
          enable = true;
          colorscheme = "gruvbox-dark-medium";
        };
        plugins.gitgutter = {
          enable = true;
        };
        plugins.lsp = {
          enable = true;
          servers.rnix-lsp.enable = true;
          servers.pyright.enable = true;
        };

        plugins.nix.enable = true;
        plugins.airline.enable = true;
        plugins.airline.powerline = true;
        plugins.treesitter.enable = true;
        plugins.nvim-autopairs.enable = true;
        plugins.undotree.enable = true;
        plugins.startify = {
          enable = true;
          useUnicode = true;
        };
        plugins.treesitter.ensureInstalled = [
          "bash"
          "cpp"
          "css"
          "go"
          "html"
          "java"
          "json"
          "latex"
          "lua"
          "make"
          "nix"
          "python"
          "regex"
          "rust"
          "yaml"
        ];
        options = {
          number = true; # Show line numbers
          shiftwidth = 2; # Tab width should be 2
          mouse = "a";
          tabstop = 2;
          expandtab = true;
          smarttab = true;
          autoindent = true;
          cindent = true;
          linebreak = true;
          hidden = true;
        };
        extraPlugins = with pkgs.vimPlugins; [
          vim-autoformat
        ];
        maps = {
          normal."<F3>" = ":Autoformat<CR>";
        };
      };

This happens on 88fb867da5d3b4785c8c52ea9d0ca2185b0dd51a (current master)

pta2002 commented 2 years ago

Could you try manually setting plugins.treesitter.nixGrammars to both true and false? One of them might work.

Don't get me wrong, this is 100% a bug and I'm trying to figure it out, but I think I've had success with that workaround and manually doing :TSUninstall all followed by :TSInstall all

gador commented 2 years ago

Hi @pta2002 thanks for the promt answer! Unfortunately neither option helped. It always results in the same error message about treesitter not being able to read/write. Only disabling treesitter completely got rid of the error message..

pta2002 commented 2 years ago

This seems to be triggered by a change in treesitter. Upstream issue is here: https://github.com/NixOS/nixpkgs/issues/189838. For now, I'll see if I can implement the suggested workaround, but this seems like an upstream problem unfortunately

gador commented 2 years ago

ah, yes, I see. Thanks for investigating further!

pta2002 commented 2 years ago

Temporarily fixed by implementing the suggested workaround if nixGrammars = true. This bypasses nvim-treesitter's parser management and installs all of the parsers directly from nix. Should fix a few issues regarding mismatched libc versions, too.