Removed builderTemplate implementation in favour of an inline approach

This commit is contained in:
isaacST08 2025-12-19 14:30:30 -07:00
commit 0da99e05ae
6 changed files with 400 additions and 625 deletions

View file

@ -1,59 +1,57 @@
# TODO: I need testing.
{
pkgs,
config,
lib,
pkgs,
...
} @ moduleInheritancePackage: let
}: let
# The name of the builder
name = "latexmk";
# The builder template
template = import ./builderTemplate.nix;
inherit (lib) optionals;
inherit (lib.modules) mkIf;
inherit (lib.nvim.config) mkBool;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) bool package str;
in (
template {
inherit name moduleInheritancePackage;
inherit (lib.types) package str;
options = {
enable = mkEnableOption "Tex Compilation Via latexmk";
texCfg = config.vim.languages.tex;
cfg = texCfg.build.builders.${name};
in {
options.vim.languages.tex.build.builders.${name} = {
enable = mkEnableOption "Tex Compilation Via latexmk";
package = mkOption {
type = package;
default = pkgs.texlive.withPackages (ps: [ps.latexmk]);
description = "latexmk package";
};
executable = mkOption {
type = str;
default = "latexmk";
description = ''
The executable name from the build package that will be used to
build/compile the tex.
'';
};
# Flag options
pdfOutput = mkOption {
type = bool;
default = true;
example = false;
description = "Insure the output file is a pdf.";
};
package = mkOption {
type = package;
default = pkgs.texlive.withPackages (ps: [ps.latexmk]);
description = "latexmk package";
};
# Optional flags must come before the base args because of how the latexmk
# command works
args = builderCfg: (
# Flags
(optionals builderCfg.pdfOutput ["-pdf"])
# Base args
++ [
"-quiet"
"%f"
]
);
}
)
executable = mkOption {
type = str;
default = "latexmk";
description = ''
The executable name from the build package that will be used to
build/compile the tex.
'';
};
# Flag options
pdfOutput = mkBool true "Insure the output file is a pdf.";
};
config = mkIf (texCfg.enable && cfg.enable) {
vim.languages.tex.build.builder = {
inherit name;
inherit (cfg) package executable;
args = (
# Flags
(lib.lists.optional cfg.pdfOutput "-pdf")
# Base args
++ [
"-quiet"
"%f"
]
);
};
};
}