Nixpkgs: onedark-vim: Error detected while processing package

Created on 23 Aug 2020  ยท  6Comments  ยท  Source: NixOS/nixpkgs

Describe the bug
For some reason, onedark.vim is failing to load.

Error detected while processing /nix/store/462h5wxl2g88nyj5mck4x85fqfhf79i7-vim
plugin-onedark-vim-2020-08-12/share/vim-plugins/onedark-vim/colors/onedark.vim:

line  133:
E117: Unknown function: onedark#GetColors
E15: Invalid expression: onedark#GetColors()
line  135:
E121: Undefined variable: s:colors
E15: Invalid expression: s:colors.red
line  136:
E121: Undefined variable: s:colors
E15: Invalid expression: s:colors.dark_red
line  137:
E121: Undefined variable: s:colors
E15: Invalid expression: s:colors.green
line  138:
E121: Undefined variable: s:colors
E15: Invalid expression: s:colors.yellow
line  139:
E121: Undefined variable: s:colors
E15: Invalid expression: s:colors.dark_yellow
line  140:

To Reproduce
Steps to reproduce the behavior (if using home-manager)

programs.neovim = {
      enable = true;
      configure = {
      customRC = ''
         colorscheme onedark
        '';
      packages.myVimPackage = with pkgs.vimPlugins; {
        start = [
            onedark-vim

          ];
        };
    };
  };

or

  programs.neovim = {
      enable = true;
      extraConfig = ''
         colorscheme onedark
        '';
      plugins = with pkgs.vimPlugins; [
            onedark-vim
          ];
    };

if the customRC attribute is left out, onedark-vim loads fine if invoked manually after neovim start.

Furthermore, this can be fixed by ammending the rtp:
The following amendment to rtp fixes it:

{ config, pkgs, libs, ... }:

let 

    loadPlugin = plugin: ''
      set rtp^=${plugin.rtp}
      set rtp+=${plugin.rtp}/after
    '';
    plugins = with pkgs.vimPlugins; [
          onedark-vim
        ];
in
{
  home.packages = with pkgs;  with stdenv.lib; [
    # neovim
    rnix-lsp
  ] ++ optionals stdenv.isLinux [ python-language-server ] ;
  # xdg.configFile."nvim/init.vim".source = ../configs/neovim/init.vim;
  programs.neovim = {
      enable = true;
      extraConfig = ''
            " Workaround for broken handling of packpath by vim8/neovim for ftplugins -- see https://github.com/NixOS/nixpkgs/issues/39364#issuecomment-425536054 for more info
            filetype off | syn off
            ${builtins.concatStringsSep "\n"
            (map loadPlugin plugins)}
            filetype indent plugin on | syn on
            colorscheme onedark
        '';
    };
}

Metadata
โฏ nix-shell -p nix-info --run "nix-info -m"
these paths will be fetched (0.00 MiB download, 0.00 MiB unpacked):
/nix/store/1hg7ssk7dzpmccsz018p8vb9jr3pq47i-nix-info
copying path '/nix/store/1hg7ssk7dzpmccsz018p8vb9jr3pq47i-nix-info' from 'https://cache.nixos.org'...

  • system: "x86_64-linux"
  • host os: Linux 5.7.15-200.fc32.x86_64, Fedora, 32 (Workstation Edition)
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix) 2.3.7
  • channels(michael): "nixos-unstable-20.09pre239318.c59ea8b8a0e, nixpkgs-20.09pre239803.909539e6a09"
  • nixpkgs: /home/michael/.nix-defexpr/channels/nixpkgs

This seems like it's related to: https://github.com/NixOS/nixpkgs/issues/39364 https://github.com/NixOS/nixpkgs/pull/78385

bug vim

All 6 comments

really wish we didn't have like 3 different conventions in how to configure vim. Makes it really confusing as to which one is preferred.

The home-manager's neovim configuration is separate from nixpkgs/nixos as you can see at https://github.com/rycee/home-manager/blob/master/modules/programs/neovim.nix. Nixos/nixpkgs does not have a programs.neovim option ?

Home-manager uses the same infrastructure for neovim/vim plugin management as nix, the issue can be reproduced without home-manager using the following nix-shell:

{ pkgs ? import <nixpkgs> { } }:
let
  neovim = pkgs.neovim.override {
    configure = {
      customRC = ''
        colorscheme onedark
      '';
      packages.myVimPackage = with pkgs.vimPlugins; {
        # see examples below how to use custom packages
        start = [ onedark-vim ];
      };
    };
  };
in
pkgs.mkShell {
  buildInputs = [ neovim ];
}

Onedark color scheme has installation instructions for vim8 package manager: https://github.com/joshdick/onedark.vim#installation

{ pkgs ? import <nixpkgs> { } }:
let
  neovim = pkgs.neovim.override {
    configure = {
      customRC = ''
        packadd! onedark-vim
        colorscheme onedark
      '';
      packages.myVimPackage = with pkgs.vimPlugins; {
        # see examples below how to use custom packages
        opt = [ onedark-vim ];
      };
    };
  };
in
pkgs.mkShell {
  buildInputs = [ neovim ];
}

It's not a nixpkgs problem.

@basilgood That works. Is this the intended behavior of vim packages in nixpkgs? It seems odd that some modules work without manually activating them with packadd! and some do not (nvim-lsp, onedark-vim)

@mjlbach It's a vim8 native package manager behavior.
Nixpkgs follows the same behavior.
In this case (onedark.vim) it's a colorscheme plugin and they probably didn't expect from a colorscheme plugin to contain an autoload folder and so autoload it's not loaded.
Same thing with dracula colorscheme and probably with some other plugins which does not follow vim8 pack rules.
But nvim-lsp in my experience works out of the box either in start or opt.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomberek picture tomberek  ยท  3Comments

ghost picture ghost  ยท  3Comments

copumpkin picture copumpkin  ยท  3Comments

matthiasbeyer picture matthiasbeyer  ยท  3Comments

sid-kap picture sid-kap  ยท  3Comments