Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvim treesitter abi incorrect #119

Closed
auscyber opened this issue Jul 8, 2021 · 14 comments
Closed

Nvim treesitter abi incorrect #119

auscyber opened this issue Jul 8, 2021 · 14 comments

Comments

@auscyber
Copy link

auscyber commented Jul 8, 2021

Continuing neovim/neovim#15019

@mjlbach
Copy link
Contributor

mjlbach commented Jul 8, 2021

How are you compiling your tree-sitter parsers? Are they built by nix? I have the following in my HM config:

  xdg.configFile."nvim/parser/c.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-c}/parser";
  xdg.configFile."nvim/parser/lua.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-lua}/parser";
  xdg.configFile."nvim/parser/rust.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-rust}/parser";
  xdg.configFile."nvim/parser/python.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-python}/parser";

The version of TS used to compile them needs to match the runtime version linked by neovim

@auscyber
Copy link
Author

auscyber commented Jul 8, 2021

i have that config and the default, neither work, both say neovim is compiled with version 12 and the parser is 13

@auscyber
Copy link
Author

The problem has fixed itself, after i switched to unstable from master

@mjlbach
Copy link
Contributor

mjlbach commented Jul 11, 2021

Teto also bumped the flake in core/contrib, which this repo wraps

@scalavision
Copy link

scalavision commented Jul 16, 2021

I still have this problem after a fresh install of home-manager. I get this when opening a nix file:

Error detected while processing FileType Autocommands for "*":
E5108: Error executing lua ...ghtly/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch : supported between 9 and 12, found 1

I have this config related to neovim:

  nixpkgs.overlays = [    
    (import (builtins.fetchTarball {    
      url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz;    
    }))    
  ];

and enabling neovim (excerpt from the config):

in        
{              
  programs.neovim = {
    enable = true;
#    package = unstable.pkgs.neovim;
    package = pkgs.neovim-nightly;

    # install needed binaries here
    extraPackages = with pkgs; [
      # used to compile tree-sitter grammar
      tree-sitter
    ];

    plugins = with pkgs.vimPlugins; [
      # you can use plugins from the pkgs
      vim-which-key
      lspsaga-nvim

   ];
 
  };

}

I tried using the unstable channel, but since I am on NixOS using the stable channel, that was not working.

I think treesitter installed automatically by itself when opening a project.

It seems to me that 0.4 is still used by home-manager, is it possible to install the 0.5 release somehow, maybe using some kind of overlay? I am not that accustomed to home-manager yet. I think it could be a great option if possible, since I don't need to stay on the bleeding edge / nightly build of neovim anymore.

Thanks for making this available by the way!

@mjlbach
Copy link
Contributor

mjlbach commented Jul 16, 2021

It seems to me that 0.4 is still used by home-manager, is it possible to install the 0.5 release somehow, maybe using some kind of overlay? I am not that accustomed to home-manager yet. I think it could be a great option if possible, since I don't need to stay on the bleeding edge / nightly build of neovim anymore.

This is the overlay. FWIW tree-sitter is not guaranteed to work with 0.5, and nvim-treesitter (the plugin) may break compatibility with 0.5 at any time. 0.5 should be in nixpkgs-unstable now.

You shouldn't let tree-sitter install the parsers. You should install them from nixpkgs. Make sure you clear all parsers/disable automatic parser installation with treesitter (rm -rf ~/.local/share/nvim/parse) and then add the following to HM:

  xdg.configFile."nvim/parser/c.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-c}/parser";
  xdg.configFile."nvim/parser/lua.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-lua}/parser";
  xdg.configFile."nvim/parser/rust.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-rust}/parser";
  xdg.configFile."nvim/parser/python.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-python}/parser";

@jacksonludwig
Copy link

@mjlbach when you say not to let tree-sitter install parsers, do you mean don't do stuff like :TSInstall x in neovim, and instead install the desired parsers as you have given in you example?
Thanks.

@mjlbach
Copy link
Contributor

mjlbach commented Jul 17, 2021

Yes, if you're using a non-nixos system, this will guarantee that the runtime treesitter ABI and parser's ABI match

@scalavision
Copy link

scalavision commented Jul 18, 2021

Thanks @mjlbach , seems my problem is that the version of tree-sitter is 0.19+ in nixpkgs, while the supported version is 0.18+, not sure if this this something in my plugins or in neovim itself.

I tried to override these in my home.nix as follows:

  nixpkgs.overlays = [    
  (self: super: {    
    
    tree-sitter-updated = super.tree-sitter.overrideAttrs(oldAttrs: {    
    
      version = "0.18.3";    
      sha256 = "sha256-uQs80rxcPX7Q46irJYv2FfvuppwonSS4HVClFujaP+U=";    
      cargoSha256 = "sha256-fonlxLNh7KyewCj7G4vxa7cM/DlcHNFbQpp0SwVQ3j3=";    
    
      postInstall = ''    
        PREFIX=$out make install    
      '';    
    
    });    
    
    neovim-release-5 = super.neovim-unwrapped.overrideAttrs (oldAttrs: rec {    
      name = "neovim";    
      version = "0.5.0";    
      src = self.fetchurl {    
        url = "https://github.com/neovim/neovim/releases/download/v0.5.0/nvim-linux64.tar.gz";    
#        url = "https://github.com/neovim/neovim/archive/master.zip";    
        sha256 = "0zbkjfgws26dia58ynr0v5b3q0yw6y7brb7x7kjaf3ry2j2yhnfd";    
      };    
    
      nativeBuildInputs = with self.pkgs; [ unzip cmake pkgconfig gettext tree-sitter-updated ];    
    
    });    
    
   })    
    
  ];

But it seems to drag in tree-sitter 0.19 nevertheless:

$ home-manager switch              
these derivations will be built:
  /nix/store/nh4lzcvfh8ghzqfsm5rlj3vx3nksxsha-tree-sitter-0.18.3.drv
  /nix/store/372b1zdcvlk9m90niynln1j057y1n8mf-neovim.drv
  /nix/store/182cq002m51fp20r1gxjdm3cyxmwirk0-neovim-0.5.0.drv
  /nix/store/hdi5ya73hrjhmar35g0bfh9y9ldk5rjc-home-manager-path.drv
  /nix/store/j2ljh01r3pbab2agcy1fn3ih7w484ncg-activation-script.drv
  /nix/store/lk0v94ym8gg1f3x16v6g2jpxrnmvm5dv-hm_fontconfigconf.d10hmfonts.conf.drv
  /nix/store/jm5iwvkdp24k9jv1ajqgia6l48c47h8j-home-manager-files.drv
  /nix/store/4wfkiyc8va9pd0llygg82b1cmq7l8gy5-home-manager-generation.drv
building '/nix/store/nh4lzcvfh8ghzqfsm5rlj3vx3nksxsha-tree-sitter-0.18.3.drv'...
unpacking sources
unpacking source archive /nix/store/mcxwrpp3pvjx9xfpkphj7draylyavz1p-source
source root is source
Executing cargoSetupPostUnpackHook
unpacking source archive /nix/store/03d3p02b3ig3ql3kfp1s7qgi1qrs54z6-tree-sitter-0.19.3-vendor.tar.gz
Finished cargoSetupPostUnpackHook
patching sources
Executing cargoSetupPostPatchHook
Validating consistency between /build/source//Cargo.lock and /build/tree-sitter-0.19.3-vendor.tar.gz/Cargo.lock
Finished cargoSetupPostPatchHook
configuring
building
Executing cargoBuildHook
++ env CC_x86_64-unknown-linux-gnu=/nix/store/74kv08wjf06ifgk4dxrnra4qhzr5s1w4-gcc-wrapper-10.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/74kv08wjf06ifgk4dxrnra4qhzr5s1w4-gcc-wrapper-10.3.0/bin/c++ CC_x86_64-unknown-linux-gnu=/nix/store/74kv08wjf06ifgk4dxrnra4qhzr5s1w4-gcc-wrapper-10.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/74kv08wjf06ifgk4dxrnra4qhzr5s1w4-gcc-wrapper-10.3.0/bin/c++ cargo build -j 8 --target x86_64-unknown-linux-gnu --frozen --release

I might not be able to override the neovim build setup correctly I guess. Maybe there should be an override possibility to select custom version of tree-sitter used by neovim?

I've stumbled into this before and it seems to be a reoccurring problem.

@auscyber
Copy link
Author

auscyber commented Jul 29, 2021

again i come back, as neovim is linked to glibc 2.32, however treesitter requires, and the current glibc version is 2.33

@auscyber
Copy link
Author

auscyber commented Jul 29, 2021

i managed to just override the buildInputs to use the current nixpkgs gcc and glibc

@jacksonludwig
Copy link

Yes, if you're using a non-nixos system, this will guarantee that the runtime treesitter ABI and parser's ABI match

Should I be able to do this for all parsers? NBD but I noticed

xdg.configFile."nvim/parser/comment.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-comment}/parser";

results in

error: attribute 'tree-sitter-comment' missing

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-get-nvim-treesitter-working-for-latex-files/18908/1

@marcelarie
Copy link

i managed to just override the buildInputs to use the current nixpkgs gcc and glibc

can you show how you did this?

@Kranzes Kranzes closed this as completed May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants