mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 23:45:31 +00:00
Cleaned up tectonic args processing
This commit is contained in:
parent
2a55d0f0a4
commit
0b6cf496d1
1 changed files with 78 additions and 27 deletions
|
|
@ -14,7 +14,14 @@
|
||||||
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
|
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
|
||||||
inherit (lib.types) enum ints listOf str nullOr;
|
inherit (lib.types) enum ints listOf str nullOr;
|
||||||
inherit (lib.nvim.config) mkBool;
|
inherit (lib.nvim.config) mkBool;
|
||||||
inherit (builtins) concatLists elem map toString;
|
inherit (builtins) concatLists elem map toString attrNames filter isList;
|
||||||
|
|
||||||
|
notNull = x: x != null;
|
||||||
|
forceCheck = x: true;
|
||||||
|
toList = x:
|
||||||
|
if isList x
|
||||||
|
then x
|
||||||
|
else [x];
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
in (
|
in (
|
||||||
|
|
@ -148,31 +155,75 @@ in (
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
args = builderCfg: (
|
# args = builderCfg: (
|
||||||
# Base args
|
# # Base args
|
||||||
[
|
# [
|
||||||
"-X"
|
# "-X"
|
||||||
"compile"
|
# "compile"
|
||||||
"%f"
|
# "%f"
|
||||||
]
|
# ]
|
||||||
# Flags
|
# # Flags
|
||||||
++ (optionals builderCfg.keepIntermediates ["--keep-intermediates"])
|
# ++ (optionals builderCfg.keepIntermediates ["--keep-intermediates"])
|
||||||
++ (optionals builderCfg.keepLogs ["--keep-logs"])
|
# ++ (optionals builderCfg.keepLogs ["--keep-logs"])
|
||||||
++ (optionals builderCfg.onlyCached ["--only-cached"])
|
# ++ (optionals builderCfg.onlyCached ["--only-cached"])
|
||||||
++ (optionals builderCfg.synctex ["--synctex"])
|
# ++ (optionals builderCfg.synctex ["--synctex"])
|
||||||
++ (optionals builderCfg.untrustedInput ["--untrusted"])
|
# ++ (optionals builderCfg.untrustedInput ["--untrusted"])
|
||||||
# Options
|
# # Options
|
||||||
++ (optionals (builderCfg.reruns > 0) ["--reruns" "${toString builderCfg.reruns}"])
|
# ++ (optionals (builderCfg.reruns > 0) ["--reruns" "${toString builderCfg.reruns}"])
|
||||||
++ (optionals (builderCfg.bundle != null) ["--bundle" "${toString builderCfg.bundle}"])
|
# ++ (optionals (builderCfg.bundle != null) ["--bundle" "${toString builderCfg.bundle}"])
|
||||||
++ (optionals (builderCfg.webBundle != null) ["--web-bundle" "${toString builderCfg.webBundle}"])
|
# ++ (optionals (builderCfg.webBundle != null) ["--web-bundle" "${toString builderCfg.webBundle}"])
|
||||||
++ (optionals (builderCfg.outfmt != null) ["--outfmt" "${toString builderCfg.outfmt}"])
|
# ++ (optionals (builderCfg.outfmt != null) ["--outfmt" "${toString builderCfg.outfmt}"])
|
||||||
++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
|
# ++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
|
||||||
++ (optionals (builderCfg.format != null) ["--format" "${toString builderCfg.format}"])
|
# ++ (optionals (builderCfg.format != null) ["--format" "${toString builderCfg.format}"])
|
||||||
++ (optionals (builderCfg.color != null) ["--color" "${toString builderCfg.color}"])
|
# ++ (optionals (builderCfg.color != null) ["--color" "${toString builderCfg.color}"])
|
||||||
# Still options but these are not defined by builder specific options but
|
# # Still options but these are not defined by builder specific options but
|
||||||
# instead synchronize options between the global build options and builder
|
# # instead synchronize options between the global build options and builder
|
||||||
# specific options
|
# # specific options
|
||||||
++ (optionals (!(elem cfg.build.pdfDirectory ["." ""])) ["--outdir" "${cfg.build.pdfDirectory}"])
|
# ++ (optionals (!(elem cfg.build.pdfDirectory ["." ""])) ["--outdir" "${cfg.build.pdfDirectory}"])
|
||||||
);
|
# );
|
||||||
|
|
||||||
|
args = builderCfg: let
|
||||||
|
option = setCheck: flag: {inherit setCheck flag;};
|
||||||
|
args = {
|
||||||
|
baseArgs = ["-X" "compile" "%f"];
|
||||||
|
|
||||||
|
flags = {
|
||||||
|
keepIntermediates = "--keep-intermediates";
|
||||||
|
keepLogs = "--keep-logs";
|
||||||
|
onlyCached = "--only-cached";
|
||||||
|
synctex = "--synctex";
|
||||||
|
untrustedInput = "--untrusted";
|
||||||
|
};
|
||||||
|
|
||||||
|
options = {
|
||||||
|
reruns = option (x: x > 0) "--reruns";
|
||||||
|
bundle = option notNull "--bundle";
|
||||||
|
webBundle = option notNull "--web-bundle";
|
||||||
|
outfmt = option notNull "--outfmt";
|
||||||
|
format = option notNull "--format";
|
||||||
|
color = option notNull "--color";
|
||||||
|
hidePaths = option forceCheck "--hide";
|
||||||
|
};
|
||||||
|
|
||||||
|
externalOptions = concatLists [
|
||||||
|
(optionals (!(elem cfg.build.pdfDirectory ["." ""])) ["--outdir" "${cfg.build.pdfDirectory}"])
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
flags = map (flag: args.flags.${flag}) (filter (flag: builderCfg.${flag}) (attrNames args.flags));
|
||||||
|
options = let
|
||||||
|
getOptionFlagsList = opt:
|
||||||
|
concatLists (
|
||||||
|
map
|
||||||
|
(y: [args.options."${opt}".flag "${toString y}"])
|
||||||
|
(toList builderCfg."${opt}")
|
||||||
|
);
|
||||||
|
processOption = opt:
|
||||||
|
optionals
|
||||||
|
(args.options."${opt}".setCheck builderCfg."${opt}")
|
||||||
|
(getOptionFlagsList opt);
|
||||||
|
in (concatLists (map processOption (attrNames args.options)));
|
||||||
|
in
|
||||||
|
concatLists (with args; [baseArgs flags options externalOptions]);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue