mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
Merge pull request #52767 from timokau/vim-plugin-updates
Fix vim-plugin dependencies
This commit is contained in:
commit
22d0f320e8
@ -48,7 +48,7 @@ neovim.override {
|
||||
|
||||
## Managing plugins with Vim packages
|
||||
|
||||
To store you plugins in Vim packages the following example can be used:
|
||||
To store you plugins in Vim packages (the native vim plugin manager, see `:help packages`) the following example can be used:
|
||||
|
||||
```
|
||||
vim_configurable.customize {
|
||||
@ -56,6 +56,8 @@ vim_configurable.customize {
|
||||
# loaded on launch
|
||||
start = [ youcompleteme fugitive ];
|
||||
# manually loadable by calling `:packadd $plugin-name`
|
||||
# however, if a vim plugin has a dependency that is not explicitly listed in
|
||||
# opt that dependency will always be added to start to avoid confusion.
|
||||
opt = [ phpCompletion elm-vim ];
|
||||
# To automatically load a plugin when opening a filetype, add vimrc lines like:
|
||||
# autocmd FileType php :packadd phpCompletion
|
||||
@ -63,6 +65,7 @@ vim_configurable.customize {
|
||||
}
|
||||
```
|
||||
|
||||
`myVimPackage` is an arbitrary name for the generated package. You can choose any name you like.
|
||||
For Neovim the syntax is:
|
||||
|
||||
```
|
||||
@ -74,6 +77,8 @@ neovim.override {
|
||||
packages.myVimPackage = with pkgs.vimPlugins; {
|
||||
# see examples below how to use custom packages
|
||||
start = [ ];
|
||||
# If a vim plugin has a dependency that is not explicitly listed in
|
||||
# opt that dependency will always be added to start to avoid confusion.
|
||||
opt = [ ];
|
||||
};
|
||||
};
|
||||
|
54
pkgs/misc/vim-plugins/build-vim-plugin.nix
Normal file
54
pkgs/misc/vim-plugins/build-vim-plugin.nix
Normal file
@ -0,0 +1,54 @@
|
||||
{ stdenv
|
||||
, rtpPath ? "share/vim-plugins"
|
||||
, vim
|
||||
}:
|
||||
|
||||
rec {
|
||||
addRtp = path: attrs: derivation:
|
||||
derivation // { rtp = "${derivation}/${path}"; } // {
|
||||
overrideAttrs = f: buildVimPlugin (attrs // f attrs);
|
||||
};
|
||||
|
||||
buildVimPlugin = attrs@{
|
||||
name ? "${attrs.pname}-${attrs.version}",
|
||||
namePrefix ? "vimplugin-",
|
||||
src,
|
||||
unpackPhase ? "",
|
||||
configurePhase ? "",
|
||||
buildPhase ? "",
|
||||
preInstall ? "",
|
||||
postInstall ? "",
|
||||
path ? (builtins.parseDrvName name).name,
|
||||
addonInfo ? null,
|
||||
...
|
||||
}:
|
||||
addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
|
||||
name = namePrefix + name;
|
||||
|
||||
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
target=$out/${rtpPath}/${path}
|
||||
mkdir -p $out/${rtpPath}
|
||||
cp -r . $target
|
||||
|
||||
# build help tags
|
||||
if [ -d "$target/doc" ]; then
|
||||
${vim}/bin/vim -N -u NONE -i NONE -n -E -s -c "helptags $1/doc" +quit! || echo "docs to build failed"
|
||||
fi
|
||||
|
||||
if [ -n "$addonInfo" ]; then
|
||||
echo "$addonInfo" > $target/addon-info.json
|
||||
fi
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
}));
|
||||
|
||||
buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
|
||||
buildPhase = ":";
|
||||
configurePhase =":";
|
||||
} // attrs);
|
||||
}
|
@ -5,8 +5,8 @@ let
|
||||
|
||||
inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix;
|
||||
|
||||
generated = callPackage ./generated.nix {
|
||||
inherit buildVimPluginFrom2Nix;
|
||||
plugins = callPackage ./generated.nix {
|
||||
inherit buildVimPluginFrom2Nix overrides;
|
||||
};
|
||||
|
||||
# TL;DR
|
||||
@ -22,10 +22,8 @@ let
|
||||
inherit llvmPackages;
|
||||
};
|
||||
|
||||
overriden = generated // (overrides generated);
|
||||
|
||||
aliases = lib.optionalAttrs (config.allowAliases or true) (import ./aliases.nix lib overriden);
|
||||
aliases = lib.optionalAttrs (config.allowAliases or true) (import ./aliases.nix lib plugins);
|
||||
|
||||
in
|
||||
|
||||
overriden // aliases
|
||||
plugins // aliases
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,9 @@
|
||||
{config, lib, stdenv
|
||||
, python, cmake, vim, vimUtils, ruby
|
||||
{ lib, stdenv
|
||||
, python, cmake, vim, ruby
|
||||
, which, fetchgit, llvmPackages, rustPlatform
|
||||
, xkb_switch, fzf, skim
|
||||
, python3, boost, icu, ncurses
|
||||
, ycmd, rake
|
||||
, pythonPackages, python3Packages
|
||||
, substituteAll
|
||||
, languagetool
|
||||
, Cocoa, CoreFoundation, CoreServices
|
||||
@ -17,34 +16,22 @@
|
||||
, impl, iferr, gocode, gocode-gomod, go-tools
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
_skim = skim;
|
||||
|
||||
in
|
||||
|
||||
generated:
|
||||
|
||||
with generated;
|
||||
|
||||
{
|
||||
self: super: {
|
||||
|
||||
vim2nix = buildVimPluginFrom2Nix {
|
||||
name = "vim2nix";
|
||||
src = ./vim2nix;
|
||||
dependencies = ["vim-addon-manager"];
|
||||
dependencies = with super; [ vim-addon-manager ];
|
||||
};
|
||||
|
||||
fzfWrapper = buildVimPluginFrom2Nix {
|
||||
name = fzf.name;
|
||||
src = fzf.src;
|
||||
dependencies = [];
|
||||
};
|
||||
|
||||
skim = buildVimPluginFrom2Nix {
|
||||
name = _skim.name;
|
||||
src = _skim.vim;
|
||||
dependencies = [];
|
||||
name = skim.name;
|
||||
src = skim.vim;
|
||||
};
|
||||
|
||||
LanguageClient-neovim = let
|
||||
@ -70,7 +57,6 @@ with generated;
|
||||
name = "LanguageClient-neovim-2018-09-07";
|
||||
src = LanguageClient-neovim-src;
|
||||
|
||||
dependencies = [];
|
||||
propogatedBuildInputs = [ LanguageClient-neovim-bin ];
|
||||
|
||||
preFixup = ''
|
||||
@ -87,10 +73,9 @@ with generated;
|
||||
rev = "69cce66defdf131958f152ea7a7b26c21ca9d009";
|
||||
sha256 = "1363b2fmv69axrl2hm74dmx51cqd8k7rk116890qllnapzw1zjgc";
|
||||
};
|
||||
dependencies = [];
|
||||
};
|
||||
|
||||
clang_complete = clang_complete.overrideAttrs(old: {
|
||||
clang_complete = super.clang_complete.overrideAttrs(old: {
|
||||
# In addition to the arguments you pass to your compiler, you also need to
|
||||
# specify the path of the C++ std header (if you are using C++).
|
||||
# These usually implicitly set by cc-wrapper around clang (pkgs/build-support/cc-wrapper).
|
||||
@ -107,14 +92,14 @@ with generated;
|
||||
'';
|
||||
});
|
||||
|
||||
clighter8 = clighter8.overrideAttrs(old: {
|
||||
clighter8 = super.clighter8.overrideAttrs(old: {
|
||||
preFixup = ''
|
||||
sed "/^let g:clighter8_libclang_path/s|')$|${llvmPackages.clang.cc.lib}/lib/libclang.so')|" \
|
||||
-i "$out"/share/vim-plugins/clighter8/plugin/clighter8.vim
|
||||
'';
|
||||
});
|
||||
|
||||
command-t = command-t.overrideAttrs(old: {
|
||||
command-t = super.command-t.overrideAttrs(old: {
|
||||
buildInputs = [ ruby rake ];
|
||||
buildPhase = ''
|
||||
rake make
|
||||
@ -122,7 +107,7 @@ with generated;
|
||||
'';
|
||||
});
|
||||
|
||||
cpsm = cpsm.overrideAttrs(old: {
|
||||
cpsm = super.cpsm.overrideAttrs(old: {
|
||||
buildInputs = [
|
||||
python3
|
||||
stdenv
|
||||
@ -138,7 +123,7 @@ with generated;
|
||||
'';
|
||||
});
|
||||
|
||||
ctrlp-cmatcher = ctrlp-cmatcher.overrideAttrs(old: {
|
||||
ctrlp-cmatcher = super.ctrlp-cmatcher.overrideAttrs(old: {
|
||||
buildInputs = [ python ];
|
||||
buildPhase = ''
|
||||
patchShebangs .
|
||||
@ -146,7 +131,7 @@ with generated;
|
||||
'';
|
||||
});
|
||||
|
||||
deoplete-go = deoplete-go.overrideAttrs(old: {
|
||||
deoplete-go = super.deoplete-go.overrideAttrs(old: {
|
||||
buildInputs = [ python3 ];
|
||||
buildPhase = ''
|
||||
pushd ./rplugin/python3/deoplete/ujson
|
||||
@ -156,114 +141,106 @@ with generated;
|
||||
'';
|
||||
});
|
||||
|
||||
ensime-vim = ensime-vim.overrideAttrs(old: {
|
||||
ensime-vim = super.ensime-vim.overrideAttrs(old: {
|
||||
passthru.python3Dependencies = ps: with ps; [ sexpdata websocket_client ];
|
||||
dependencies = ["vimproc" "vimshell" "self" "forms"];
|
||||
dependencies = with super; [ vimproc-vim vimshell-vim super.self forms ];
|
||||
});
|
||||
|
||||
forms = forms.overrideAttrs(old: {
|
||||
dependencies = ["self"];
|
||||
forms = super.forms.overrideAttrs(old: {
|
||||
dependencies = with super; [ super.self ];
|
||||
});
|
||||
|
||||
gist-vim = gist-vim.overrideAttrs(old: {
|
||||
dependencies = ["webapi-vim"];
|
||||
gist-vim = super.gist-vim.overrideAttrs(old: {
|
||||
dependencies = with super; [ webapi-vim ];
|
||||
});
|
||||
|
||||
gitv = gitv.overrideAttrs(old: {
|
||||
dependencies = ["gitv"];
|
||||
ncm2 = super.ncm2.overrideAttrs(old: {
|
||||
dependencies = with super; [ nvim-yarp ];
|
||||
});
|
||||
|
||||
ncm2 = ncm2.overrideAttrs(old: {
|
||||
dependencies = ["nvim-yarp"];
|
||||
ncm2-jedi = super.ncm2-jedi.overrideAttrs(old: {
|
||||
dependencies = with super; [ nvim-yarp ncm2 ];
|
||||
passthru.python3Dependencies = ps: with ps; [ jedi ];
|
||||
});
|
||||
|
||||
ncm2-ultisnips = ncm2-ultisnips.overrideAttrs(old: {
|
||||
dependencies = ["ultisnips"];
|
||||
ncm2-ultisnips = super.ncm2-ultisnips.overrideAttrs(old: {
|
||||
dependencies = with super; [ ultisnips ];
|
||||
});
|
||||
|
||||
taglist-vim = taglist-vim.overrideAttrs(old: {
|
||||
setSourceRoot = ''
|
||||
export sourceRoot=taglist
|
||||
mkdir taglist
|
||||
mv doc taglist
|
||||
mv plugin taglist
|
||||
'';
|
||||
vimshell-vim = super.vimshell-vim.overrideAttrs(old: {
|
||||
dependencies = with super; [ vimproc-vim ];
|
||||
});
|
||||
|
||||
vimshell-vim = vimshell-vim.overrideAttrs(old: {
|
||||
dependencies = [ "vimproc-vim" ];
|
||||
});
|
||||
|
||||
vim-addon-manager = vim-addon-manager.overrideAttrs(old: {
|
||||
vim-addon-manager = super.vim-addon-manager.overrideAttrs(old: {
|
||||
buildInputs = stdenv.lib.optional stdenv.isDarwin Cocoa;
|
||||
});
|
||||
|
||||
vim-addon-actions = vim-addon-actions.overrideAttrs(old: {
|
||||
dependencies = [ "vim-addon-mw-utils" "tlib" ];
|
||||
vim-addon-actions = super.vim-addon-actions.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
|
||||
});
|
||||
|
||||
vim-addon-async = vim-addon-async.overrideAttrs(old: {
|
||||
dependencies = [ "vim-addon-signs" ];
|
||||
vim-addon-async = super.vim-addon-async.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-signs ];
|
||||
});
|
||||
|
||||
vim-addon-background-cmd = vim-addon-background-cmd.overrideAttrs(old: {
|
||||
dependencies = [ "vim-addon-mw-utils" ];
|
||||
vim-addon-background-cmd = super.vim-addon-background-cmd.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-mw-utils ];
|
||||
});
|
||||
|
||||
vim-addon-completion = vim-addon-completion.overrideAttrs(old: {
|
||||
dependencies = [ "tlib" ];
|
||||
vim-addon-completion = super.vim-addon-completion.overrideAttrs(old: {
|
||||
dependencies = with super; [ tlib_vim ];
|
||||
});
|
||||
|
||||
vim-addon-goto-thing-at-cursor = vim-addon-goto-thing-at-cursor.overrideAttrs(old: {
|
||||
dependencies = [ "tlib" ];
|
||||
vim-addon-goto-thing-at-cursor = super.vim-addon-goto-thing-at-cursor.overrideAttrs(old: {
|
||||
dependencies = with super; [ tlib_vim ];
|
||||
});
|
||||
|
||||
vim-addon-mru = vim-addon-mru.overrideAttrs(old: {
|
||||
dependencies = ["vim-addon-other" "vim-addon-mw-utils"];
|
||||
vim-addon-mru = super.vim-addon-mru.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-other vim-addon-mw-utils ];
|
||||
});
|
||||
|
||||
vim-addon-nix = vim-addon-nix.overrideAttrs(old: {
|
||||
dependencies = [
|
||||
"vim-addon-completion"
|
||||
"vim-addon-goto-thing-at-cursor"
|
||||
"vim-addon-errorformats"
|
||||
"vim-addon-actions"
|
||||
"vim-addon-mw-utils" "tlib"
|
||||
vim-addon-nix = super.vim-addon-nix.overrideAttrs(old: {
|
||||
dependencies = with super; [
|
||||
vim-addon-completion
|
||||
vim-addon-goto-thing-at-cursor
|
||||
vim-addon-errorformats
|
||||
vim-addon-actions
|
||||
vim-addon-mw-utils tlib_vim
|
||||
];
|
||||
});
|
||||
|
||||
vim-addon-sql = vim-addon-sql.overrideAttrs(old: {
|
||||
dependencies = ["vim-addon-completion" "vim-addon-background-cmd" "tlib"];
|
||||
vim-addon-sql = super.vim-addon-sql.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-completion vim-addon-background-cmd tlib_vim ];
|
||||
});
|
||||
|
||||
vim-addon-syntax-checker = vim-addon-syntax-checker.overrideAttrs(old: {
|
||||
dependencies = ["vim-addon-mw-utils" "tlib"];
|
||||
vim-addon-syntax-checker = super.vim-addon-syntax-checker.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
|
||||
});
|
||||
|
||||
vim-addon-toggle-buffer = vim-addon-toggle-buffer.overrideAttrs(old: {
|
||||
dependencies = [ "vim-addon-mw-utils" "tlib" ];
|
||||
vim-addon-toggle-buffer = super.vim-addon-toggle-buffer.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
|
||||
});
|
||||
|
||||
vim-addon-xdebug = vim-addon-xdebug.overrideAttrs(old: {
|
||||
dependencies = [ "WebAPI" "vim-addon-mw-utils" "vim-addon-signs" "vim-addon-async" ];
|
||||
vim-addon-xdebug = super.vim-addon-xdebug.overrideAttrs(old: {
|
||||
dependencies = with super; [ webapi-vim vim-addon-mw-utils vim-addon-signs vim-addon-async ];
|
||||
});
|
||||
|
||||
vim-bazel = vim-bazel.overrideAttrs(old: {
|
||||
dependencies = ["maktaba"];
|
||||
vim-bazel = super.vim-bazel.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-maktaba ];
|
||||
});
|
||||
|
||||
vim-codefmt = vim-codefmt.overrideAttrs(old: {
|
||||
dependencies = ["maktaba"];
|
||||
vim-codefmt = super.vim-codefmt.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-maktaba ];
|
||||
});
|
||||
|
||||
vim-easytags = vim-easytags.overrideAttrs(old: {
|
||||
dependencies = ["vim-misc"];
|
||||
vim-easytags = super.vim-easytags.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-misc ];
|
||||
});
|
||||
|
||||
# change the go_bin_path to point to a path in the nix store. See the code in
|
||||
# fatih/vim-go here
|
||||
# https://github.com/fatih/vim-go/blob/155836d47052ea9c9bac81ba3e937f6f22c8e384/autoload/go/path.vim#L154-L159
|
||||
vim-go = vim-go.overrideAttrs(old: let
|
||||
vim-go = super.vim-go.overrideAttrs(old: let
|
||||
binPath = lib.makeBinPath [
|
||||
asmfmt
|
||||
delve
|
||||
@ -291,7 +268,7 @@ with generated;
|
||||
'';
|
||||
});
|
||||
|
||||
vim-grammarous = vim-grammarous.overrideAttrs(old: {
|
||||
vim-grammarous = super.vim-grammarous.overrideAttrs(old: {
|
||||
# use `:GrammarousCheck` to initialize checking
|
||||
# In neovim, you also want to use set
|
||||
# let g:grammarous#show_first_error = 1
|
||||
@ -304,31 +281,31 @@ with generated;
|
||||
];
|
||||
});
|
||||
|
||||
vim-hier = vim-hier.overrideAttrs(old: {
|
||||
vim-hier = super.vim-hier.overrideAttrs(old: {
|
||||
buildInputs = [ vim ];
|
||||
});
|
||||
|
||||
vim-isort = vim-isort.overrideAttrs(old: {
|
||||
vim-isort = super.vim-isort.overrideAttrs(old: {
|
||||
postPatch = ''
|
||||
substituteInPlace ftplugin/python_vimisort.vim \
|
||||
--replace 'import vim' 'import vim; import sys; sys.path.append("${pythonPackages.isort}/${python.sitePackages}")'
|
||||
--replace 'import vim' 'import vim; import sys; sys.path.append("${python.pkgs.isort}/${python.sitePackages}")'
|
||||
'';
|
||||
});
|
||||
|
||||
vim-snipmate = vim-snipmate.overrideAttrs(old: {
|
||||
dependencies = ["vim-addon-mw-utils" "tlib"];
|
||||
vim-snipmate = super.vim-snipmate.overrideAttrs(old: {
|
||||
dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
|
||||
});
|
||||
|
||||
|
||||
vim-wakatime = vim-wakatime.overrideAttrs(old: {
|
||||
vim-wakatime = super.vim-wakatime.overrideAttrs(old: {
|
||||
buildInputs = [ python ];
|
||||
});
|
||||
|
||||
vim-xdebug = vim-xdebug.overrideAttrs(old: {
|
||||
vim-xdebug = super.vim-xdebug.overrideAttrs(old: {
|
||||
postInstall = false;
|
||||
});
|
||||
|
||||
vim-xkbswitch = vim-xkbswitch.overrideAttrs(old: {
|
||||
vim-xkbswitch = super.vim-xkbswitch.overrideAttrs(old: {
|
||||
patchPhase = ''
|
||||
substituteInPlace plugin/xkbswitch.vim \
|
||||
--replace /usr/local/lib/libxkbswitch.so ${xkb_switch}/lib/libxkbswitch.so
|
||||
@ -336,14 +313,14 @@ with generated;
|
||||
buildInputs = [ xkb_switch ];
|
||||
});
|
||||
|
||||
vim-yapf = vim-yapf.overrideAttrs(old: {
|
||||
vim-yapf = super.vim-yapf.overrideAttrs(old: {
|
||||
buildPhase = ''
|
||||
substituteInPlace ftplugin/python_yapf.vim \
|
||||
--replace '"yapf"' '"${python3Packages.yapf}/bin/yapf"'
|
||||
--replace '"yapf"' '"${python3.pkgs.yapf}/bin/yapf"'
|
||||
'';
|
||||
});
|
||||
|
||||
vimproc-vim = vimproc-vim.overrideAttrs(old: {
|
||||
vimproc-vim = super.vimproc-vim.overrideAttrs(old: {
|
||||
buildInputs = [ which ];
|
||||
|
||||
buildPhase = ''
|
||||
@ -355,11 +332,11 @@ with generated;
|
||||
'';
|
||||
});
|
||||
|
||||
YankRing-vim = YankRing-vim.overrideAttrs(old: {
|
||||
YankRing-vim = super.YankRing-vim.overrideAttrs(old: {
|
||||
sourceRoot = ".";
|
||||
});
|
||||
|
||||
youcompleteme = youcompleteme.overrideAttrs(old: {
|
||||
youcompleteme = super.youcompleteme.overrideAttrs(old: {
|
||||
buildPhase = ''
|
||||
substituteInPlace plugin/youcompleteme.vim \
|
||||
--replace "'ycm_path_to_python_interpreter', '''" \
|
||||
@ -378,9 +355,9 @@ with generated;
|
||||
};
|
||||
});
|
||||
|
||||
jedi-vim = jedi-vim.overrideAttrs(old: {
|
||||
jedi-vim = super.jedi-vim.overrideAttrs(old: {
|
||||
# checking for python3 support in vim would be neat, too, but nobody else seems to care
|
||||
buildInputs = [ python3Packages.jedi ];
|
||||
buildInputs = [ python3.pkgs.jedi ];
|
||||
meta = {
|
||||
description = "code-completion for python using python-jedi";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
|
@ -309,7 +309,8 @@ def generate_nix(plugins: List[Tuple[str, str, Plugin]]):
|
||||
f.write(
|
||||
f"""
|
||||
{plugin.normalized_name} = buildVimPluginFrom2Nix {{
|
||||
name = "{plugin.normalized_name}-{plugin.version}";
|
||||
pname = "{plugin.normalized_name}";
|
||||
version = "{plugin.version}";
|
||||
src = fetchFromGitHub {{
|
||||
owner = "{owner}";
|
||||
repo = "{repo}";
|
||||
|
@ -197,6 +197,7 @@ navicore/vissort.vim
|
||||
nbouscal/vim-stylish-haskell
|
||||
ncm2/ncm2
|
||||
ncm2/ncm2-bufword
|
||||
ncm2/ncm2-jedi
|
||||
ncm2/ncm2-path
|
||||
ncm2/ncm2-tmux
|
||||
ncm2/ncm2-ultisnips
|
||||
|
@ -150,23 +150,35 @@ vim_with_plugins can be installed like any other application within Nix.
|
||||
let
|
||||
inherit (stdenv) lib;
|
||||
|
||||
toNames = x:
|
||||
# transitive closure of plugin dependencies
|
||||
transitiveClosure = knownPlugins: plugin:
|
||||
let
|
||||
# vam puts out a list of strings as the dependency list, we need to be able to deal with that.
|
||||
# Because of that, "plugin" may be a string or a derivation. If it is a string, it is resolved
|
||||
# using `knownPlugins`. Otherwise `knownPlugins` can be null.
|
||||
knownPlugins' = if knownPlugins == null then vimPlugins else knownPlugins;
|
||||
pluginDrv = if builtins.isString plugin then knownPlugins'.${plugin} else plugin;
|
||||
in
|
||||
[ pluginDrv ] ++ (
|
||||
lib.unique (builtins.concatLists (map (transitiveClosure knownPlugins) pluginDrv.dependencies or []))
|
||||
);
|
||||
|
||||
findDependenciesRecursively = knownPlugins: plugins: lib.concatMap (transitiveClosure knownPlugins) plugins;
|
||||
|
||||
attrnamesToPlugins = { knownPlugins, names }:
|
||||
map (name: if builtins.isString name then knownPlugins.${name} else name) knownPlugins;
|
||||
|
||||
pluginToAttrname = plugin:
|
||||
plugin.pname;
|
||||
|
||||
pluginsToAttrnames = plugins: map pluginToAttrname plugins;
|
||||
|
||||
vamDictToNames = x:
|
||||
if builtins.isString x then [x]
|
||||
else (lib.optional (x ? name) x.name)
|
||||
++ (x.names or []);
|
||||
findDependenciesRecursively = {knownPlugins, names}:
|
||||
|
||||
let depsOf = name: (builtins.getAttr name knownPlugins).dependencies or [];
|
||||
|
||||
recurseNames = path: names: lib.concatMap (name: recurse ([name]++path)) names;
|
||||
|
||||
recurse = path:
|
||||
let name = builtins.head path;
|
||||
in if builtins.elem name (builtins.tail path)
|
||||
then throw "recursive vim dependencies"
|
||||
else [name] ++ recurseNames path (depsOf name);
|
||||
|
||||
in lib.uniqList { inputList = recurseNames [] names; };
|
||||
rtpPath = "share/vim-plugins";
|
||||
|
||||
vimrcFile = {
|
||||
packages ? null,
|
||||
@ -183,11 +195,11 @@ let
|
||||
(let
|
||||
knownPlugins = pathogen.knownPlugins or vimPlugins;
|
||||
|
||||
plugins = map (name: knownPlugins.${name}) (findDependenciesRecursively { inherit knownPlugins; names = pathogen.pluginNames; });
|
||||
plugins = findDependenciesRecursively knownPlugins pathogen.pluginNames;
|
||||
|
||||
pluginsEnv = buildEnv {
|
||||
name = "pathogen-plugin-env";
|
||||
paths = map (x: "${x}/${vimPlugins.rtpPath}") plugins;
|
||||
paths = map (x: "${x}/${rtpPath}") plugins;
|
||||
};
|
||||
in
|
||||
''
|
||||
@ -228,7 +240,7 @@ let
|
||||
(let
|
||||
knownPlugins = vam.knownPlugins or vimPlugins;
|
||||
|
||||
names = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
|
||||
plugins = findDependenciesRecursively knownPlugins (lib.concatMap vamDictToNames vam.pluginDictionaries);
|
||||
|
||||
# Vim almost reads JSON, so eventually JSON support should be added to Nix
|
||||
# TODO: proper quoting
|
||||
@ -242,9 +254,9 @@ let
|
||||
in assert builtins.hasAttr "vim-addon-manager" knownPlugins;
|
||||
''
|
||||
let g:nix_plugin_locations = {}
|
||||
${lib.concatMapStrings (name: ''
|
||||
let g:nix_plugin_locations['${name}'] = "${knownPlugins.${name}.rtp}"
|
||||
'') names}
|
||||
${lib.concatMapStrings (plugin: ''
|
||||
let g:nix_plugin_locations['${plugin.pname}'] = "${plugin.rtp}"
|
||||
'') plugins}
|
||||
let g:nix_plugin_locations['vim-addon-manager'] = "${knownPlugins."vim-addon-manager".rtp}"
|
||||
|
||||
let g:vim_addon_manager = {}
|
||||
@ -281,8 +293,18 @@ let
|
||||
(let
|
||||
link = (packageName: dir: pluginPath: "ln -sf ${pluginPath}/share/vim-plugins/* $out/pack/${packageName}/${dir}");
|
||||
packageLinks = (packageName: {start ? [], opt ? []}:
|
||||
let
|
||||
# `nativeImpl` expects packages to be derivations, not strings (as
|
||||
# opposed to older implementations that have to maintain backwards
|
||||
# compatibility). Therefore we don't need to deal with "knownPlugins"
|
||||
# and can simply pass `null`.
|
||||
depsOfOptionalPlugins = lib.subtractLists opt (findDependenciesRecursively null opt);
|
||||
startWithDeps = findDependenciesRecursively null start;
|
||||
in
|
||||
["mkdir -p $out/pack/${packageName}/start"]
|
||||
++ (builtins.map (link packageName "start") 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)))
|
||||
++ ["mkdir -p $out/pack/${packageName}/opt"]
|
||||
++ (builtins.map (link packageName "opt") opt)
|
||||
);
|
||||
@ -381,61 +403,9 @@ rec {
|
||||
'';
|
||||
};
|
||||
|
||||
rtpPath = "share/vim-plugins";
|
||||
|
||||
vimHelpTags = ''
|
||||
vimHelpTags(){
|
||||
if [ -d "$1/doc" ]; then
|
||||
${vim}/bin/vim -N -u NONE -i NONE -n -E -s -c "helptags $1/doc" +quit! || echo "docs to build failed"
|
||||
fi
|
||||
}
|
||||
'';
|
||||
|
||||
addRtp = path: attrs: derivation:
|
||||
derivation // { rtp = "${derivation}/${path}"; } // {
|
||||
overrideAttrs = f: buildVimPlugin (attrs // f attrs);
|
||||
};
|
||||
|
||||
buildVimPlugin = a@{
|
||||
name,
|
||||
namePrefix ? "vimplugin-",
|
||||
src,
|
||||
unpackPhase ? "",
|
||||
configurePhase ? "",
|
||||
buildPhase ? "",
|
||||
preInstall ? "",
|
||||
postInstall ? "",
|
||||
path ? (builtins.parseDrvName name).name,
|
||||
addonInfo ? null,
|
||||
...
|
||||
}:
|
||||
addRtp "${rtpPath}/${path}" a (stdenv.mkDerivation (a // {
|
||||
name = namePrefix + name;
|
||||
|
||||
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
target=$out/${rtpPath}/${path}
|
||||
mkdir -p $out/${rtpPath}
|
||||
cp -r . $target
|
||||
${vimHelpTags}
|
||||
vimHelpTags $target
|
||||
if [ -n "$addonInfo" ]; then
|
||||
echo "$addonInfo" > $target/addon-info.json
|
||||
fi
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
}));
|
||||
|
||||
vim_with_vim2nix = vim_configurable.customize { name = "vim"; vimrcConfig.vam.pluginDictionaries = [ "vim-addon-vim2nix" ]; };
|
||||
|
||||
buildVimPluginFrom2Nix = a: buildVimPlugin ({
|
||||
buildPhase = ":";
|
||||
configurePhase =":";
|
||||
} // a);
|
||||
inherit (import ./build-vim-plugin.nix { inherit stdenv rtpPath vim; }) buildVimPlugin buildVimPluginFrom2Nix;
|
||||
|
||||
requiredPlugins = {
|
||||
packages ? {},
|
||||
@ -450,13 +420,13 @@ rec {
|
||||
if vam != null && vam ? knownPlugins then vam.knownPlugins else
|
||||
if pathogen != null && pathogen ? knownPlugins then pathogen.knownPlugins else
|
||||
vimPlugins;
|
||||
pathogenNames = map (name: knownPlugins.${name}) (findDependenciesRecursively { inherit knownPlugins; names = pathogen.pluginNames; });
|
||||
vamNames = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
|
||||
pathogenNames = findDependenciesRecursively knownPlugins pathogen.pluginNames;
|
||||
vamNames = findDependenciesRecursively knownPlugins (lib.concatMap vamDictToNames vam.pluginDictionaries);
|
||||
names = (lib.optionals (pathogen != null) pathogenNames) ++
|
||||
(lib.optionals (vam != null) vamNames);
|
||||
nonNativePlugins = map (name: knownPlugins.${name}) names ++ (lib.optionals (plug != null) plug.plugins);
|
||||
nativePluginsConfigs = lib.attrsets.attrValues packages;
|
||||
nativePlugins = lib.concatMap ({start?[], opt?[]}: start++opt) nativePluginsConfigs;
|
||||
nativePlugins = lib.concatMap ({start?[], opt?[], knownPlugins?vimPlugins}: start++opt) nativePluginsConfigs;
|
||||
in
|
||||
nativePlugins ++ nonNativePlugins;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user