neovim: apply nixfmt

This commit is contained in:
Robert Helgesson 2020-10-12 22:50:49 +02:00
parent 18a05a9604
commit aecd4acfb4
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
2 changed files with 24 additions and 31 deletions

1
format
View File

@ -36,7 +36,6 @@ find . -name '*.nix' \
! -path ./modules/programs/firefox.nix \ ! -path ./modules/programs/firefox.nix \
! -path ./modules/programs/gpg.nix \ ! -path ./modules/programs/gpg.nix \
! -path ./modules/programs/lesspipe.nix \ ! -path ./modules/programs/lesspipe.nix \
! -path ./modules/programs/neovim.nix \
! -path ./modules/programs/ssh.nix \ ! -path ./modules/programs/ssh.nix \
! -path ./modules/programs/tmux.nix \ ! -path ./modules/programs/tmux.nix \
! -path ./modules/programs/vscode.nix \ ! -path ./modules/programs/vscode.nix \

View File

@ -9,18 +9,16 @@ let
extraPythonPackageType = mkOptionType { extraPythonPackageType = mkOptionType {
name = "extra-python-packages"; name = "extra-python-packages";
description = "python packages in python.withPackages format"; description = "python packages in python.withPackages format";
check = with types; (x: if isFunction x check = with types;
then isList (x pkgs.pythonPackages) (x: if isFunction x then isList (x pkgs.pythonPackages) else false);
else false);
merge = mergeOneOption; merge = mergeOneOption;
}; };
extraPython3PackageType = mkOptionType { extraPython3PackageType = mkOptionType {
name = "extra-python3-packages"; name = "extra-python3-packages";
description = "python3 packages in python.withPackages format"; description = "python3 packages in python.withPackages format";
check = with types; (x: if isFunction x check = with types;
then isList (x pkgs.python3Packages) (x: if isFunction x then isList (x pkgs.python3Packages) else false);
else false);
merge = mergeOneOption; merge = mergeOneOption;
}; };
@ -44,21 +42,20 @@ let
" ${p.plugin.pname} {{{ " ${p.plugin.pname} {{{
${p.config} ${p.config}
" }}} " }}}
'' else ""; '' else
"";
moduleConfigure = moduleConfigure = optionalAttrs (cfg.extraConfig != ""
optionalAttrs (cfg.extraConfig != "" || (lib.filter (hasAttr "config") cfg.plugins) != []) { || (lib.filter (hasAttr "config") cfg.plugins) != [ ]) {
customRC = cfg.extraConfig + customRC = cfg.extraConfig
pkgs.lib.concatMapStrings pluginConfig cfg.plugins; + pkgs.lib.concatMapStrings pluginConfig cfg.plugins;
} } // optionalAttrs (cfg.plugins != [ ]) {
// optionalAttrs (cfg.plugins != [] ) {
packages.home-manager.start = map (x: x.plugin or x) cfg.plugins; packages.home-manager.start = map (x: x.plugin or x) cfg.plugins;
}; };
extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != []) extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ])
'' --prefix PATH : "${lib.makeBinPath cfg.extraPackages}"''; ''--prefix PATH : "${lib.makeBinPath cfg.extraPackages}"'';
in
{ in {
options = { options = {
programs.neovim = { programs.neovim = {
enable = mkEnableOption "Neovim"; enable = mkEnableOption "Neovim";
@ -107,7 +104,7 @@ in
extraPythonPackages = mkOption { extraPythonPackages = mkOption {
type = with types; either extraPythonPackageType (listOf package); type = with types; either extraPythonPackageType (listOf package);
default = (_: []); default = (_: [ ]);
defaultText = "ps: []"; defaultText = "ps: []";
example = literalExample "(ps: with ps; [ pandas jedi ])"; example = literalExample "(ps: with ps; [ pandas jedi ])";
description = '' description = ''
@ -135,7 +132,7 @@ in
extraPython3Packages = mkOption { extraPython3Packages = mkOption {
type = with types; either extraPython3PackageType (listOf package); type = with types; either extraPython3PackageType (listOf package);
default = (_: []); default = (_: [ ]);
defaultText = "ps: []"; defaultText = "ps: []";
example = literalExample "(ps: with ps; [ python-language-server ])"; example = literalExample "(ps: with ps; [ python-language-server ])";
description = '' description = ''
@ -160,7 +157,7 @@ in
configure = mkOption { configure = mkOption {
type = types.attrs; type = types.attrs;
default = {}; default = { };
example = literalExample '' example = literalExample ''
configure = { configure = {
customRC = $'''' customRC = $''''
@ -233,20 +230,17 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [ assertions = [{
{ assertion = cfg.configure == { } || moduleConfigure == { };
assertion = cfg.configure == { } || moduleConfigure == { }; message = "The programs.neovim option configure is mutually exclusive"
message = "The programs.neovim option configure is mutually exclusive" + " with extraConfig and plugins.";
+ " with extraConfig and plugins."; }];
}
];
home.packages = [ cfg.finalPackage ]; home.packages = [ cfg.finalPackage ];
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package { programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
inherit (cfg) inherit (cfg)
extraPython3Packages withPython3 extraPython3Packages withPython3 extraPythonPackages withPython
extraPythonPackages withPython
withNodeJs withRuby viAlias vimAlias; withNodeJs withRuby viAlias vimAlias;
extraMakeWrapperArgs = extraMakeWrapperArgs; extraMakeWrapperArgs = extraMakeWrapperArgs;
@ -255,6 +249,6 @@ in
programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; }; programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
programs.fish.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; }; programs.fish.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
programs.zsh.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; }; programs.zsh.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
}; };
} }