mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
fish: basic completions support
This commit is contained in:
parent
b18d302d44
commit
c22f3e1d29
1 changed files with 16 additions and 8 deletions
|
@ -14,13 +14,13 @@ let
|
||||||
mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases
|
mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases
|
||||||
);
|
);
|
||||||
|
|
||||||
fileType = types.submodule (
|
fileType = textGen: types.submodule (
|
||||||
{ name, config, ... }: {
|
{ name, config, ... }: {
|
||||||
options = {
|
options = {
|
||||||
body = mkOption {
|
body = mkOption {
|
||||||
default = null;
|
default = null;
|
||||||
type = types.nullOr types.lines;
|
type = types.nullOr types.lines;
|
||||||
description = "Body of the function.";
|
description = "Body of the file.";
|
||||||
};
|
};
|
||||||
|
|
||||||
source = mkOption {
|
source = mkOption {
|
||||||
|
@ -36,11 +36,7 @@ let
|
||||||
source = mkIf (config.body != null) (
|
source = mkIf (config.body != null) (
|
||||||
mkDefault (pkgs.writeTextFile {
|
mkDefault (pkgs.writeTextFile {
|
||||||
inherit name;
|
inherit name;
|
||||||
text = ''
|
text = textGen name config.body;
|
||||||
function ${name}
|
|
||||||
${config.body}
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
executable = true;
|
executable = true;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -125,12 +121,24 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.fish.functions = mkOption {
|
programs.fish.functions = mkOption {
|
||||||
type = types.attrsOf fileType;
|
type = types.attrsOf (fileType (name: body: ''
|
||||||
|
function ${name}
|
||||||
|
${body}
|
||||||
|
end
|
||||||
|
''));
|
||||||
default = {};
|
default = {};
|
||||||
description = ''
|
description = ''
|
||||||
Functions to add to fish.
|
Functions to add to fish.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.fish.completions = mkOption {
|
||||||
|
type = types.attrsOf (fileType (name: body: body));
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Completions to add to fish.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [{
|
config = mkIf cfg.enable (mkMerge [{
|
||||||
|
|
Loading…
Reference in a new issue