diff --git a/maintainers/scripts/luarocks-packages.csv b/maintainers/scripts/luarocks-packages.csv index b092a58b2d108..c5cee697c8fd6 100644 --- a/maintainers/scripts/luarocks-packages.csv +++ b/maintainers/scripts/luarocks-packages.csv @@ -1,4 +1,4 @@ -# nix name, luarocks name, server, version,luaversion,maintainers +# nix name,luarocks name,server,version,luaversion,maintainers alt-getopt,,,,,arobyn ansicolors,,,,, argparse,,,,, @@ -16,6 +16,7 @@ cyrussasl,,,,, digestif,,,,lua5_3, dkjson,,,,, fifo,,,,, +gitsigns.nvim,,,,lua5_1, http,,,,,vcunat inspect,,,,, ldbus,,http://luarocks.org/dev,,, diff --git a/pkgs/misc/vim-plugins/default.nix b/pkgs/misc/vim-plugins/default.nix index cbc6ec7380ba8..b56dced897175 100644 --- a/pkgs/misc/vim-plugins/default.nix +++ b/pkgs/misc/vim-plugins/default.nix @@ -1,5 +1,5 @@ # TODO check that no license information gets lost -{ callPackage, config, lib, vimUtils, vim, darwin, llvmPackages }: +{ callPackage, config, lib, vimUtils, vim, darwin, llvmPackages, luaPackages }: let @@ -7,7 +7,15 @@ let inherit (lib) extends; - initialPackages = self: {}; + initialPackages = self: { + # Convert derivation to a vim plugin. + toVimPlugin = drv: + drv.overrideAttrs(oldAttrs: { + passthru = (oldAttrs.passthru or {}) // { + vimPlugin = true; + }; + }); + }; plugins = callPackage ./generated.nix { inherit buildVimPluginFrom2Nix; @@ -22,7 +30,7 @@ let overrides = callPackage ./overrides.nix { inherit (darwin.apple_sdk.frameworks) Cocoa CoreFoundation CoreServices; inherit buildVimPluginFrom2Nix; - inherit llvmPackages; + inherit llvmPackages luaPackages; }; aliases = if (config.allowAliases or true) then (import ./aliases.nix lib) else final: prev: {}; diff --git a/pkgs/misc/vim-plugins/overrides.nix b/pkgs/misc/vim-plugins/overrides.nix index 669ca2cb9eede..b2dd6f0f5f0d5 100644 --- a/pkgs/misc/vim-plugins/overrides.nix +++ b/pkgs/misc/vim-plugins/overrides.nix @@ -86,6 +86,8 @@ , iferr , impl , reftools +# must be lua51Packages +, luaPackages }: self: super: { @@ -282,6 +284,8 @@ self: super: { dependencies = with self; [ plenary-nvim ]; }); + plenary-nvim = super.toVimPlugin(luaPackages.plenary-nvim); + gruvbox-nvim = super.gruvbox-nvim.overrideAttrs (old: { dependencies = with self; [ lush-nvim ]; }); diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 5ca3aef235885..ca5381c597246 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -2,6 +2,7 @@ { lib, stdenv, vim, vimPlugins, vim_configurable, buildEnv, writeText, writeScriptBin , nix-prefetch-hg, nix-prefetch-git , fetchFromGitHub, runtimeShell +, hasLuaModule }: /* @@ -186,7 +187,21 @@ let nativeImpl = packages: (let - link = (packageName: dir: pluginPath: "ln -sf ${pluginPath}/share/vim-plugins/* $out/pack/${packageName}/${dir}"); + # dir is "start" or "opt" + linkLuaPlugin = plugin: packageName: dir: '' + mkdir -p $out/pack/${packageName}/${dir}/${plugin.pname}/lua + ln -sf ${plugin}/share/lua/5.1/* $out/pack/${packageName}/${dir}/${plugin.pname}/lua + ln -sf ${plugin}/${plugin.pname}-${plugin.version}-rocks/${plugin.pname}/${plugin.version}/* $out/pack/${packageName}/${dir}/${plugin.pname}/ + ''; + + linkVimlPlugin = pluginPath: packageName: dir: + "ln -sf ${pluginPath}/${rtpPath}/* $out/pack/${packageName}/${dir}"; + + # (builtins.trace pluginPath ) + link = pluginPath: if hasLuaModule pluginPath + then linkLuaPlugin pluginPath + else linkVimlPlugin pluginPath; + packageLinks = (packageName: {start ? [], opt ? []}: let # `nativeImpl` expects packages to be derivations, not strings (as @@ -199,9 +214,9 @@ let [ "mkdir -p $out/pack/${packageName}/start" ] # To avoid confusion, even dependencies of optional plugins are added # to `start` (except if they are explicitly listed as optional plugins). - ++ (builtins.map (link packageName "start") (lib.unique (startWithDeps ++ depsOfOptionalPlugins))) + ++ (builtins.map (x: link x packageName "start") (lib.unique (startWithDeps ++ depsOfOptionalPlugins))) ++ ["mkdir -p $out/pack/${packageName}/opt"] - ++ (builtins.map (link packageName "opt") opt) + ++ (builtins.map (x: link x packageName "opt") opt) ); packDir = (packages: stdenv.mkDerivation { @@ -217,6 +232,18 @@ let set runtimepath^=${packDir packages} ''); + /* Generates a vimrc string + + packages is an attrset with {name: { start = [ vim derivations ]; opt = [ vim derivations ]; } + Example: + vimrcContent { + + packages = { home-manager = { start = [vimPlugins.vim-fugitive]; opt = [];}; + beforePlugins = ''; + customRc = ''let mapleader = " "''; + + }; + */ vimrcContent = { packages ? null, vam ? null, diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f3273d52d5535..cf4e86402b87d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -32195,10 +32195,14 @@ with pkgs; viewnior = callPackage ../applications/graphics/viewnior { }; - vimUtils = callPackage ../misc/vim-plugins/vim-utils.nix { }; + + vimUtils = callPackage ../misc/vim-plugins/vim-utils.nix { + inherit (lua51Packages) hasLuaModule; + }; vimPlugins = recurseIntoAttrs (callPackage ../misc/vim-plugins { llvmPackages = llvmPackages_6; + luaPackages = lua51Packages; }); vimb-unwrapped = callPackage ../applications/networking/browsers/vimb { }; diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 62ddc14ff93a3..f16917a943946 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -83,7 +83,7 @@ with self; { }; - inherit toLuaModule lua-setup-hook; + inherit toLuaModule hasLuaModule lua-setup-hook; inherit buildLuarocksPackage buildLuaApplication; inherit requiredLuaModules luaOlder luaAtLeast isLua51 isLua52 isLua53 isLuaJIT lua callPackage;