mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 15:35:30 +00:00
Created build module
This commit is contained in:
parent
48674a46fa
commit
44959a0c8a
6 changed files with 820 additions and 302 deletions
86
modules/plugins/languages/tex/build/builders/custom.nix
Normal file
86
modules/plugins/languages/tex/build/builders/custom.nix
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit
|
||||
(lib.types)
|
||||
bool
|
||||
enum
|
||||
ints
|
||||
listOf
|
||||
package
|
||||
str
|
||||
;
|
||||
inherit
|
||||
(builtins)
|
||||
attrNames
|
||||
concatLists
|
||||
concatStringsSep
|
||||
elem
|
||||
elemAt
|
||||
filter
|
||||
hasAttr
|
||||
isAttrs
|
||||
length
|
||||
map
|
||||
throw
|
||||
toString
|
||||
;
|
||||
|
||||
cfg = config.vim.languages.tex;
|
||||
|
||||
# --- Enable Options ---
|
||||
mkEnableDefaultOption = default: description: (mkOption {
|
||||
type = bool;
|
||||
default = default;
|
||||
example = !default;
|
||||
description = description;
|
||||
});
|
||||
|
||||
collateArgs = buildConfig: buildConfig.builders.custom.args;
|
||||
in {
|
||||
options.vim.languages.tex.build.builders.custom = {
|
||||
enable = mkEnableDefaultOption false "Whether to enable using a custom build package";
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = pkgs.tectonic;
|
||||
description = "build/compiler package";
|
||||
};
|
||||
executable = mkOption {
|
||||
type = str;
|
||||
default = "tectonic";
|
||||
description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||
};
|
||||
args = mkOption {
|
||||
type = listOf str;
|
||||
default = [
|
||||
"-X"
|
||||
"compile"
|
||||
"%f"
|
||||
"--synctex"
|
||||
"--keep-logs"
|
||||
"--keep-intermediates"
|
||||
];
|
||||
description = ''
|
||||
Defines additional arguments that are passed to the configured LaTeX build tool.
|
||||
Note that flags and their arguments need to be separate elements in this array.
|
||||
To pass the arguments -foo bar to a build tool, args needs to be ["-foo" "bar"].
|
||||
The placeholder `%f` will be replaced by the server.
|
||||
|
||||
Placeholders:
|
||||
- `%f`: The path of the TeX file to compile.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable && cfg.build.builders.custom.enable) {
|
||||
vim.languages.tex.build.builder = {
|
||||
name = "custom";
|
||||
args = collateArgs cfg.build;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue