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_customizable: Include manpages in the output #56277

Merged
merged 2 commits into from Feb 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 45 additions & 7 deletions pkgs/misc/vim-plugins/vim-utils.nix
Expand Up @@ -359,19 +359,57 @@ rec {
inherit vimrcFile;

# shell script with custom name passing [-u vimrc] [-U gvimrc] to vim
vimWithRC = {vimExecutable, name ? null, vimrcFile ? null, gvimrcFile ? null}:
let rcOption = o: file: stdenv.lib.optionalString (file != null) "-${o} ${file}";
in writeScriptBin (if name == null then "vim" else name) ''
#!${stdenv.shell}
exec ${vimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@"
vimWithRC = {
vimExecutable,
gvimExecutable,
vimManPages,
wrapManual,
wrapGui,
name ? "vim",
vimrcFile ? null,
gvimrcFile ? null,
vimExecutableName,
gvimExecutableName,
}:
let
rcOption = o: file: stdenv.lib.optionalString (file != null) "-${o} ${file}";
vimWrapperScript = writeScriptBin vimExecutableName ''
#!${stdenv.shell}
exec ${vimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@"
'';
gvimWrapperScript = writeScriptBin gvimExecutableName ''
#!${stdenv.shell}
exec ${gvimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@"
'';
in
buildEnv {
inherit name;
paths = [
vimWrapperScript
] ++ lib.optional wrapGui gvimWrapperScript
++ lib.optional wrapManual vimManPages
;
};

# add a customize option to a vim derivation
makeCustomizable = vim: vim // {
customize = { name, vimrcConfig }: vimWithRC {
customize = {
name,
vimrcConfig,
wrapManual ? true,
wrapGui ? false,
vimExecutableName ? name,
gvimExecutableName ? (lib.concatStrings [ "g" name ]),
}: vimWithRC {
vimExecutable = "${vim}/bin/vim";
inherit name;
gvimExecutable = "${vim}/bin/gvim";
inherit name wrapManual wrapGui vimExecutableName gvimExecutableName;
vimrcFile = vimrcFile vimrcConfig;
vimManPages = buildEnv {
name = "vim-doc";
paths = [ vim ];
pathsToLink = [ "/share/man" ];
};
};

override = f: makeCustomizable (vim.override f);
Expand Down