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

vim plugin "LanguageClient-neovim" seems to miss dependencies #33391

Closed
matthiasbeyer opened this issue Jan 3, 2018 · 12 comments
Closed

vim plugin "LanguageClient-neovim" seems to miss dependencies #33391

matthiasbeyer opened this issue Jan 3, 2018 · 12 comments

Comments

@matthiasbeyer
Copy link
Contributor

matthiasbeyer commented Jan 3, 2018

Issue description

The vim plugin "LanguageClient-neovim" seems to miss a dependency, when installing it via configuration.nix, vim starts with warnings:

Error detected while processing /nix/store/ah9najhdvhhh1x0n8lymv3qr9yjag4wq-vimplugin-LanguageClient-neovim-2017-12-05/share/vim-plugins/LanguageClient-neovim/plugin/LanguageClient.vim:
line    8:
E117: Unknown function: yarp#py3
E15: Invalid expression: yarp#py3('LanguageClient_wrapper')

See also

It seems these are not yet packaged in nixpkgs.

Steps to reproduce

Install { name = "LanguageClient-neovim"; } in vim customization, then start vim after rebuilding.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.5, NixOS, 18.03pre124015.f59a0f7f1a6 (Impala)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 1.11.16
  • channels(root): "nixos-18.03pre124015.f59a0f7f1a6"
  • channels(m): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
@matthiasbeyer
Copy link
Contributor Author

This wont be that simple. nvim-yarp needs python3Packages.neovim, but I don't know how to add this dependency properly in a package definition for nvim-yarp... so things are complicated.

@matthiasbeyer
Copy link
Contributor Author

Ok. I tried adding the missing packages to my knownPlugins:

  "vim-hug-neovim-rpc" = buildVimPlugin {
    name = "vim-hug-neovim-rpc";
    src = fetchgit {
      url = "https://github.com/roxma/vim-hug-neovim-rpc";
      rev = "60093847f0ba0a57ace54df30bd17a8239a99d6f";
      sha256 = "0rim73si32z1h9rh0i2qs5gy010cpb6mz1zxr197agf85zdq7x0f";
    };
    dependencies = [];
    pythonDependencies = with pkgs.python3Packages; [ neovim ];
  };

  "nvim-yarp" = buildVimPlugin {
    name = "nvim-yarp";
    src = fetchgit {
      url = "https://github.com/roxma/nvim-yarp";
      rev = "b222af8dbbfb35c6d833fd76a940f6ca2fe322fa";
      sha256 = "0rialn5xmyd3n02j81cflvljrx2lld2mhggni66frrjdz5c45xkl";
    };
    dependencies = [];
    pythonDependencies = with pkgs.python3Packages; [ neovim ];
  };

and import them into my

pluginDictionaries = [
  /* others */
  { name = "LanguageClient-neovim"; }
  { name = "nvim-yarp"; }
  { name = "vim-hug-neovim-rpc"; }
];

But when firing up vim I still get

[vim-hug-neovim-rpc] Vim(pythonx):Traceback (most recent call last):
Error detected while processing function HandleCursorMoved[1]..yarp#core#notify[1]..yarp#core#wait_channel[5]..yarp#core#jobstart[2]..yarp#pyx#init[13]..yarp#core#serveraddr[1]..neovim_rpc#serveraddr:
line   15:
E605: Exception not caught: [vim-hug-neovim-rpc] requires `:pythonx import neovim` command to work

@matthiasbeyer
Copy link
Contributor Author

matthiasbeyer commented Jan 3, 2018

I guess I'll ping some vim guys now (because I don't know how to continue): @bjornfor @jagajaga and @garbas seem to contrib a lot commits in the vim-plugins tree... so you get pinged! 😄

@acertain
Copy link
Contributor

acertain commented Mar 10, 2018

Here's a working expression:

  LanguageClient-neovim = let x = rustPlatform.buildRustPackage {
    name = "vimplugin-LanguageClient-neovim-2018-03-10";
    src = fetchgit {
      url = "https://github.com/autozimu/LanguageClient-neovim";
      rev = "afd61dabf0989d081f0d2654d0e3888103faef75";
      sha256 = "1hcx48y52k4flz0lw95pvdcwkn9h969fz6mq9ixxmvvbzzcb34gl";
    };

    cargoSha256 = "0c2sklpvab63a1f1mhcq9abq5m2srkj52ypq7dq44g8ngn2a05ka";

    installPhase = ''
      cp target/release/languageclient bin/
      target=$out/${rtpPath}/LanguageClient-neovim
      mkdir -p $out/${rtpPath}
      cp -r . $target
      ${vimHelpTags}
      vimHelpTags $target
      if [ -n "$addonInfo" ]; then
        echo "$addonInfo" > $target/addon-info.json
      fi
    '';

  }; in x // {rtp = "${x}/${rtpPath}/LanguageClient-neovim";};

I think probably buildVimPlugin and/or buildRustPackage should be refactored so they can be combined more easily.

@johnchildren
Copy link
Contributor

johnchildren commented Mar 10, 2018

I also had a try at getting this to work

{
  LanguageClient-neovim =
    let
      LanguageClient-neovim-src = fetchgit {
        url = "https://github.com/autozimu/LanguageClient-neovim";
        rev = "fbc46862af7fa254f74f1108149fd0669c46f1ad";
        sha256 = "1wrrmikriyw8an8hn7240igcaca9a0ykh1j0dfy45kslxkmqkk3r";
      };
      LanguageClient-neovim-bin = rustPlatform.buildRustPackage {
        name = "LanguageClient-neovim-bin";
        src = LanguageClient-neovim-src;

        cargoSha256 = "0c2sklpvab63a1f1mhcq9abq5m2srkj52ypq7dq44g8ngn2a05ka";
      };
    in buildVimPluginFrom2Nix { # created by nix#NixDerivation
      name = "LanguageClient-neovim-2018-03-06";
      src = LanguageClient-neovim-src;
     
      dependencies = [];
      propogatedBuildInputs = [ LanguageClient-neovim-bin ];

      preFixup = ''
        substituteInPlace "$out"/share/vim-plugins/LanguageClient-neovim/plugin/LanguageClient.vim \
          --replace "let l:command = [s:root . '/bin/languageclient']" "let l:command = ['${LanguageClient-neovim-bin}/bin/languageclient']"
      '';
    };
}

I couldn't see a way to make it look reasonable as a patch for vim2nix though without at least 2 derivations (either in a let binding or a recursive set).

@garbas
Copy link
Member

garbas commented Mar 11, 2018

@johnchildren I think it is ok for some complicated plugins to just be done manually. Make sure to put it above # --- generated packages bellow this line --- comment. Would you be able to create a PR with this fix?

johnchildren pushed a commit to johnchildren/nixpkgs that referenced this issue Mar 11, 2018
Following up from issue NixOS#33391, building LanguageClient-neovim now
requires some rust dependencies. This patch makes the plugin now longer
listed in vim-plugin-names file so that it will not be automatically
generated and instead lists it in non-generated plugins.

Also adds rustPlatform to arguments for vim plugins set.
@johnchildren
Copy link
Contributor

johnchildren commented Mar 11, 2018

#36829 hopefully contains the requested changes.

edit: I don't know if this actually addresses the original issue though.

@garbas garbas mentioned this issue Mar 12, 2018
8 tasks
@garbas
Copy link
Member

garbas commented Mar 12, 2018

@matthiasbeyer you maybe have time to check if LanguageClient-neovim works for you now, since we merged #36856?

garbas pushed a commit to garbas/nixpkgs that referenced this issue Mar 12, 2018
Following up from issue NixOS#33391, building LanguageClient-neovim now
requires some rust dependencies. This patch makes the plugin now longer
listed in vim-plugin-names file so that it will not be automatically
generated and instead lists it in non-generated plugins.

Also adds rustPlatform to arguments for vim plugins set.
@matthiasbeyer
Copy link
Contributor Author

@garbas I'd love to. Unfortunately, because I bake vim directly into configuration.nix, I would need to rebuild a lot: these paths will be fetched (1077.08 MiB download, 3725.46 MiB unpacked):.

Is there a way to build only one package from configuration.nix?

Am trying with

{ pkgs ? (import <nixpkgs> {}) }:

let
  vim = import ./pkgs/vim.nix { pkgs = pkgs; lib = pkgs.lib; };
in

pkgs.stdenv.mkDerivation rec {
    name = "vim";
    src = /var/empty;
    version = "0.0.0";

    buildInputs = vim;

}

and nix-build script.nix -I nixpkgs=/my/checkout.

@matthiasbeyer
Copy link
Contributor Author

The above fails:

unpacking source archive /nix/store/9ljssglw74jabzzsqsl3lim4d5jgh4ya-empty
source root is empty
/nix/store/15kgcm8hnd99p7plqzx7p4lcr2jni4df-set-source-date-epoch-to-latest.sh: line 13: [: : integer expression expected
patching sources
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
installing
install flags: install
make: *** No rule to make target 'install'.  Stop.
builder for '/nix/store/6i35g99m9550ybfvibm7r1fa4x8lk1pd-vim.drv' failed with exit code 2
error: build of '/nix/store/6i35g99m9550ybfvibm7r1fa4x8lk1pd-vim.drv' failed

With master at 669cbb6

@matthiasbeyer
Copy link
Contributor Author

matthiasbeyer commented Mar 12, 2018

Cargo-culted with nix repl and loading the default.nix from master and then :b builtins.head (import ./pkgs/vim.nix { pkgs = pkgs; lib = pkgs.lib; }).

This results in a vim which does not print the error messages from this issue anymore. Will now do more tests.

@matthiasbeyer
Copy link
Contributor Author

I just renamed a function with RLS! Seems to work 🎉

garbas pushed a commit that referenced this issue Mar 12, 2018
Following up from issue #33391, building LanguageClient-neovim now
requires some rust dependencies. This patch makes the plugin now longer
listed in vim-plugin-names file so that it will not be automatically
generated and instead lists it in non-generated plugins.

Also adds rustPlatform to arguments for vim plugins set.
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

4 participants