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;
|
||||
};
|
||||
};
|
||||
}
|
||||
65
modules/plugins/languages/tex/build/builders/default.nix
Normal file
65
modules/plugins/languages/tex/build/builders/default.nix
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
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;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./custom.nix
|
||||
./tectonic.nix
|
||||
];
|
||||
|
||||
options.vim.languages.tex.build.builder = {
|
||||
name = mkOption {
|
||||
type = enum (attrNames cfg.build.builders);
|
||||
default = "tectonic";
|
||||
description = "The tex builder to use";
|
||||
};
|
||||
args = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = "The list of args to pass to the builder";
|
||||
};
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = cfg.build.builders.tectonic.package;
|
||||
description = "The tex builder package to use";
|
||||
};
|
||||
executable = mkOption {
|
||||
type = str;
|
||||
default = cfg.build.builders.tectonic.executable;
|
||||
description = "The tex builder executable to use";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
231
modules/plugins/languages/tex/build/builders/tectonic.nix
Normal file
231
modules/plugins/languages/tex/build/builders/tectonic.nix
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
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;
|
||||
});
|
||||
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
|
||||
|
||||
# --- Arg Collation Functions --
|
||||
collateArgs = buildConfig: let
|
||||
selfConfig = buildConfig.builders.tectonic;
|
||||
in (
|
||||
# Base args
|
||||
[
|
||||
"-X"
|
||||
"compile"
|
||||
"%f"
|
||||
]
|
||||
# Flags
|
||||
++ (
|
||||
if selfConfig.keepIntermediates
|
||||
then ["--keep-intermediates"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.keepLogs
|
||||
then ["--keep-logs"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.onlyCached
|
||||
then ["--only-cached"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.synctex
|
||||
then ["--synctex"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.untrustedInput
|
||||
then ["--untrusted"]
|
||||
else []
|
||||
)
|
||||
# Options
|
||||
++ (
|
||||
if selfConfig.reruns > 0
|
||||
then ["--reruns" "${toString selfConfig.reruns}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.bundle != ""
|
||||
then ["--bundle" "${toString selfConfig.bundle}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.webBundle != ""
|
||||
then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.outfmt != ""
|
||||
then ["--outfmt" "${toString selfConfig.outfmt}"]
|
||||
else []
|
||||
)
|
||||
++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
||||
++ (
|
||||
if selfConfig.format != ""
|
||||
then ["--format" "${toString selfConfig.format}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.color != ""
|
||||
then ["--color" "${toString selfConfig.color}"]
|
||||
else []
|
||||
)
|
||||
# Still options but these are not defined by builder specific options but
|
||||
# instead synchronize options between the global build options and builder
|
||||
# specific options
|
||||
++ (
|
||||
if !(elem buildConfig.pdfDirectory ["." ""])
|
||||
then ["--outdir" "${buildConfig.pdfDirectory}"]
|
||||
else []
|
||||
)
|
||||
);
|
||||
in {
|
||||
options.vim.languages.tex.build.builders.tectonic = {
|
||||
enable = mkEnableOption "Whether to enable Tex Compilation Via Tectonic";
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = pkgs.tectonic;
|
||||
description = "tectonic package";
|
||||
};
|
||||
|
||||
executable = mkOption {
|
||||
type = str;
|
||||
default = "tectonic";
|
||||
description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||
};
|
||||
|
||||
# -- Flags --
|
||||
keepIntermediates = mkEnableDefaultOption false ''
|
||||
Keep the intermediate files generated during processing.
|
||||
|
||||
If texlab is reporting build errors when there shouldn't be, disable this option.
|
||||
'';
|
||||
keepLogs = mkEnableDefaultOption true ''
|
||||
Keep the log files generated during processing.
|
||||
|
||||
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
||||
'';
|
||||
onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
||||
synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
||||
untrustedInput = mkEnableDefaultOption false "Input is untrusted -- disable all known-insecure features";
|
||||
|
||||
# -- Options --
|
||||
reruns = mkOption {
|
||||
type = ints.unsigned;
|
||||
default = 0;
|
||||
example = 2;
|
||||
description = "Rerun the TeX engine exactly this many times after the first";
|
||||
};
|
||||
|
||||
bundle = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
||||
};
|
||||
|
||||
webBundle = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "Use this URL to find resource files instead of the default";
|
||||
};
|
||||
|
||||
outfmt = mkOption {
|
||||
type = enum [
|
||||
"pdf"
|
||||
"html"
|
||||
"xdv"
|
||||
"aux"
|
||||
"fmt"
|
||||
""
|
||||
];
|
||||
default = "";
|
||||
description = "The kind of output to generate";
|
||||
};
|
||||
|
||||
hidePaths = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
example = [
|
||||
"./secrets.tex"
|
||||
"./passwords.tex"
|
||||
];
|
||||
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
||||
};
|
||||
|
||||
format = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "The name of the \"format\" file used to initialize the TeX engine";
|
||||
};
|
||||
|
||||
color = mkOption {
|
||||
type = enum [
|
||||
"always"
|
||||
"auto"
|
||||
"never"
|
||||
""
|
||||
];
|
||||
default = "";
|
||||
example = "always";
|
||||
description = "Enable/disable colorful log output";
|
||||
};
|
||||
|
||||
extraOptions = {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = ''
|
||||
Add extra command line options to include in the tectonic build command.
|
||||
Extra options added here will not overwrite the options set in as nvf options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable && cfg.build.builders.tectonic.enable) {
|
||||
vim.languages.tex.build.builder = {
|
||||
name = "tectonic";
|
||||
args = collateArgs cfg.build;
|
||||
package = cfg.build.builders.tectonic.package;
|
||||
};
|
||||
};
|
||||
}
|
||||
107
modules/plugins/languages/tex/build/default.nix
Normal file
107
modules/plugins/languages/tex/build/default.nix
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
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;
|
||||
});
|
||||
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
|
||||
in {
|
||||
imports = [
|
||||
./builders
|
||||
];
|
||||
|
||||
options.vim.languages.tex.build = {
|
||||
forwardSearchAfter = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Set this property to true if you want to execute a forward search after a build.";
|
||||
};
|
||||
onSave = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Set this property to true if you want to compile the project after saving a file.";
|
||||
};
|
||||
useFileList = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
When set to true, the server will use the .fls files produced by the TeX engine as an additional input for the project detection.
|
||||
|
||||
Note that enabling this property might have an impact on performance.
|
||||
'';
|
||||
};
|
||||
auxDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
description = ''
|
||||
When not using latexmk, provides a way to define the directory containing the .aux files.
|
||||
Note that you need to set the aux directory in latex.build.args too.
|
||||
|
||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
logDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
description = ''
|
||||
When not using latexmk, provides a way to define the directory containing the build log files.
|
||||
Note that you need to change the output directory in your build arguments too.
|
||||
|
||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
pdfDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
description = ''
|
||||
When not using latexmk, provides a way to define the directory containing the output files.
|
||||
Note that you need to set the output directory in latex.build.args too.
|
||||
|
||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
filename = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = ''
|
||||
Allows overriding the default file name of the build artifact. This setting is used to find the correct PDF file to open during forward search.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ in {
|
|||
imports = [
|
||||
./treesitter.nix
|
||||
./lsp
|
||||
./build
|
||||
];
|
||||
|
||||
options.vim.languages.tex = {
|
||||
|
|
|
|||
|
|
@ -56,85 +56,85 @@
|
|||
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
|
||||
|
||||
# --- Arg Collation Functions --
|
||||
collateArgs.lsp.texlab.build = {
|
||||
tectonic = buildConfig: let
|
||||
selfConfig = buildConfig.tectonic;
|
||||
in (
|
||||
# Base args
|
||||
[
|
||||
"-X"
|
||||
"compile"
|
||||
"%f"
|
||||
]
|
||||
# Flags
|
||||
++ (
|
||||
if selfConfig.keepIntermediates
|
||||
then ["--keep-intermediates"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.keepLogs
|
||||
then ["--keep-logs"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.onlyCached
|
||||
then ["--only-cached"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.synctex
|
||||
then ["--synctex"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.untrustedInput
|
||||
then ["--untrusted"]
|
||||
else []
|
||||
)
|
||||
# Options
|
||||
++ (
|
||||
if selfConfig.reruns > 0
|
||||
then ["--reruns" "${toString selfConfig.reruns}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.bundle != ""
|
||||
then ["--bundle" "${toString selfConfig.bundle}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.webBundle != ""
|
||||
then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.outfmt != ""
|
||||
then ["--outfmt" "${toString selfConfig.outfmt}"]
|
||||
else []
|
||||
)
|
||||
++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
||||
++ (
|
||||
if selfConfig.format != ""
|
||||
then ["--format" "${toString selfConfig.format}"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if selfConfig.color != ""
|
||||
then ["--color" "${toString selfConfig.color}"]
|
||||
else []
|
||||
)
|
||||
# Still options but these are not defined by builder specific options but
|
||||
# instead synchronize options between the global build options and builder
|
||||
# specific options
|
||||
++ (
|
||||
if !(elem buildConfig.pdfDirectory ["." ""])
|
||||
then ["--outdir" "${buildConfig.pdfDirectory}"]
|
||||
else []
|
||||
)
|
||||
);
|
||||
custom = buildConfig: buildConfig.custom.args;
|
||||
};
|
||||
# collateArgs.lsp.texlab.build = {
|
||||
# tectonic = buildConfig: let
|
||||
# selfConfig = buildConfig.tectonic;
|
||||
# in (
|
||||
# # Base args
|
||||
# [
|
||||
# "-X"
|
||||
# "compile"
|
||||
# "%f"
|
||||
# ]
|
||||
# # Flags
|
||||
# ++ (
|
||||
# if selfConfig.keepIntermediates
|
||||
# then ["--keep-intermediates"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.keepLogs
|
||||
# then ["--keep-logs"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.onlyCached
|
||||
# then ["--only-cached"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.synctex
|
||||
# then ["--synctex"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.untrustedInput
|
||||
# then ["--untrusted"]
|
||||
# else []
|
||||
# )
|
||||
# # Options
|
||||
# ++ (
|
||||
# if selfConfig.reruns > 0
|
||||
# then ["--reruns" "${toString selfConfig.reruns}"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.bundle != ""
|
||||
# then ["--bundle" "${toString selfConfig.bundle}"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.webBundle != ""
|
||||
# then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.outfmt != ""
|
||||
# then ["--outfmt" "${toString selfConfig.outfmt}"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
||||
# ++ (
|
||||
# if selfConfig.format != ""
|
||||
# then ["--format" "${toString selfConfig.format}"]
|
||||
# else []
|
||||
# )
|
||||
# ++ (
|
||||
# if selfConfig.color != ""
|
||||
# then ["--color" "${toString selfConfig.color}"]
|
||||
# else []
|
||||
# )
|
||||
# # Still options but these are not defined by builder specific options but
|
||||
# # instead synchronize options between the global build options and builder
|
||||
# # specific options
|
||||
# ++ (
|
||||
# if !(elem buildConfig.pdfDirectory ["." ""])
|
||||
# then ["--outdir" "${buildConfig.pdfDirectory}"]
|
||||
# else []
|
||||
# )
|
||||
# );
|
||||
# custom = buildConfig: buildConfig.custom.args; # Moved
|
||||
# };
|
||||
in {
|
||||
options.vim.languages.tex.lsp.texlab = {
|
||||
enable = mkEnableLspOption "Whether to enable Tex LSP support (texlab)";
|
||||
|
|
@ -145,199 +145,200 @@ in {
|
|||
description = "texlab package";
|
||||
};
|
||||
|
||||
build = {
|
||||
tectonic = {
|
||||
enable = mkEnableDefaultOption true "Whether to enable Tex Compilation Via Tectonic";
|
||||
# build = {
|
||||
# tectonic = {
|
||||
# enable = mkEnableDefaultOption true "Whether to enable Tex Compilation Via Tectonic";
|
||||
#
|
||||
# package = mkOption {
|
||||
# type = package;
|
||||
# default = pkgs.tectonic;
|
||||
# description = "tectonic package";
|
||||
# };
|
||||
#
|
||||
# executable = mkOption {
|
||||
# type = str;
|
||||
# default = "tectonic";
|
||||
# description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||
# };
|
||||
#
|
||||
# # -- Flags --
|
||||
# keepIntermediates = mkEnableDefaultOption false ''
|
||||
# Keep the intermediate files generated during processing.
|
||||
#
|
||||
# If texlab is reporting build errors when there shouldn't be, disable this option.
|
||||
# '';
|
||||
# keepLogs = mkEnableDefaultOption true ''
|
||||
# Keep the log files generated during processing.
|
||||
#
|
||||
# Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
||||
# '';
|
||||
# onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
||||
# synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
||||
# untrustedInput = mkEnableDefaultOption false "Input is untrusted -- disable all known-insecure features";
|
||||
#
|
||||
# # -- Options --
|
||||
# reruns = mkOption {
|
||||
# type = ints.unsigned;
|
||||
# default = 0;
|
||||
# example = 2;
|
||||
# description = "Rerun the TeX engine exactly this many times after the first";
|
||||
# };
|
||||
#
|
||||
# bundle = mkOption {
|
||||
# type = str;
|
||||
# default = "";
|
||||
# description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
||||
# };
|
||||
#
|
||||
# webBundle = mkOption {
|
||||
# type = str;
|
||||
# default = "";
|
||||
# description = "Use this URL to find resource files instead of the default";
|
||||
# };
|
||||
#
|
||||
# outfmt = mkOption {
|
||||
# type = enum [
|
||||
# "pdf"
|
||||
# "html"
|
||||
# "xdv"
|
||||
# "aux"
|
||||
# "fmt"
|
||||
# ""
|
||||
# ];
|
||||
# default = "";
|
||||
# description = "The kind of output to generate";
|
||||
# };
|
||||
#
|
||||
# hidePaths = mkOption {
|
||||
# type = listOf str;
|
||||
# default = [];
|
||||
# example = [
|
||||
# "./secrets.tex"
|
||||
# "./passwords.tex"
|
||||
# ];
|
||||
# description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
||||
# };
|
||||
#
|
||||
# format = mkOption {
|
||||
# type = str;
|
||||
# default = "";
|
||||
# description = "The name of the \"format\" file used to initialize the TeX engine";
|
||||
# };
|
||||
#
|
||||
# color = mkOption {
|
||||
# type = enum [
|
||||
# "always"
|
||||
# "auto"
|
||||
# "never"
|
||||
# ""
|
||||
# ];
|
||||
# default = "";
|
||||
# example = "always";
|
||||
# description = "Enable/disable colorful log output";
|
||||
# };
|
||||
#
|
||||
# extraOptions = {
|
||||
# type = listOf str;
|
||||
# default = [];
|
||||
# description = ''
|
||||
# Add extra command line options to include in the tectonic build command.
|
||||
# Extra options added here will not overwrite the options set in as nvf options.
|
||||
# '';
|
||||
# };
|
||||
# };
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = pkgs.tectonic;
|
||||
description = "tectonic package";
|
||||
};
|
||||
# # Moved
|
||||
# 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.
|
||||
# '';
|
||||
# };
|
||||
# };
|
||||
|
||||
executable = mkOption {
|
||||
type = str;
|
||||
default = "tectonic";
|
||||
description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||
};
|
||||
|
||||
# -- Flags --
|
||||
keepIntermediates = mkEnableDefaultOption false ''
|
||||
Keep the intermediate files generated during processing.
|
||||
|
||||
If texlab is reporting build errors when there shouldn't be, disable this option.
|
||||
'';
|
||||
keepLogs = mkEnableDefaultOption true ''
|
||||
Keep the log files generated during processing.
|
||||
|
||||
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
||||
'';
|
||||
onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
||||
synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
||||
untrustedInput = mkEnableDefaultOption false "Input is untrusted -- disable all known-insecure features";
|
||||
|
||||
# -- Options --
|
||||
reruns = mkOption {
|
||||
type = ints.unsigned;
|
||||
default = 0;
|
||||
example = 2;
|
||||
description = "Rerun the TeX engine exactly this many times after the first";
|
||||
};
|
||||
|
||||
bundle = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
||||
};
|
||||
|
||||
webBundle = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "Use this URL to find resource files instead of the default";
|
||||
};
|
||||
|
||||
outfmt = mkOption {
|
||||
type = enum [
|
||||
"pdf"
|
||||
"html"
|
||||
"xdv"
|
||||
"aux"
|
||||
"fmt"
|
||||
""
|
||||
];
|
||||
default = "";
|
||||
description = "The kind of output to generate";
|
||||
};
|
||||
|
||||
hidePaths = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
example = [
|
||||
"./secrets.tex"
|
||||
"./passwords.tex"
|
||||
];
|
||||
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
||||
};
|
||||
|
||||
format = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "The name of the \"format\" file used to initialize the TeX engine";
|
||||
};
|
||||
|
||||
color = mkOption {
|
||||
type = enum [
|
||||
"always"
|
||||
"auto"
|
||||
"never"
|
||||
""
|
||||
];
|
||||
default = "";
|
||||
example = "always";
|
||||
description = "Enable/disable colorful log output";
|
||||
};
|
||||
|
||||
extraOptions = {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = ''
|
||||
Add extra command line options to include in the tectonic build command.
|
||||
Extra options added here will not overwrite the options set in as nvf options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
forwardSearchAfter = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Set this property to true if you want to execute a forward search after a build.";
|
||||
};
|
||||
onSave = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Set this property to true if you want to compile the project after saving a file.";
|
||||
};
|
||||
useFileList = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
When set to true, the server will use the .fls files produced by the TeX engine as an additional input for the project detection.
|
||||
|
||||
Note that enabling this property might have an impact on performance.
|
||||
'';
|
||||
};
|
||||
auxDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
description = ''
|
||||
When not using latexmk, provides a way to define the directory containing the .aux files.
|
||||
Note that you need to set the aux directory in latex.build.args too.
|
||||
|
||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
logDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
description = ''
|
||||
When not using latexmk, provides a way to define the directory containing the build log files.
|
||||
Note that you need to change the output directory in your build arguments too.
|
||||
|
||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
pdfDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
description = ''
|
||||
When not using latexmk, provides a way to define the directory containing the output files.
|
||||
Note that you need to set the output directory in latex.build.args too.
|
||||
|
||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
filename = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = ''
|
||||
Allows overriding the default file name of the build artifact. This setting is used to find the correct PDF file to open during forward search.
|
||||
'';
|
||||
};
|
||||
};
|
||||
# forwardSearchAfter = mkOption {
|
||||
# type = bool;
|
||||
# default = false;
|
||||
# description = "Set this property to true if you want to execute a forward search after a build.";
|
||||
# };
|
||||
# onSave = mkOption {
|
||||
# type = bool;
|
||||
# default = false;
|
||||
# description = "Set this property to true if you want to compile the project after saving a file.";
|
||||
# };
|
||||
# useFileList = mkOption {
|
||||
# type = bool;
|
||||
# default = false;
|
||||
# description = ''
|
||||
# When set to true, the server will use the .fls files produced by the TeX engine as an additional input for the project detection.
|
||||
#
|
||||
# Note that enabling this property might have an impact on performance.
|
||||
# '';
|
||||
# };
|
||||
# auxDirectory = mkOption {
|
||||
# type = str;
|
||||
# default = ".";
|
||||
# description = ''
|
||||
# When not using latexmk, provides a way to define the directory containing the .aux files.
|
||||
# Note that you need to set the aux directory in latex.build.args too.
|
||||
#
|
||||
# When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
# '';
|
||||
# };
|
||||
# logDirectory = mkOption {
|
||||
# type = str;
|
||||
# default = ".";
|
||||
# description = ''
|
||||
# When not using latexmk, provides a way to define the directory containing the build log files.
|
||||
# Note that you need to change the output directory in your build arguments too.
|
||||
#
|
||||
# When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
# '';
|
||||
# };
|
||||
# pdfDirectory = mkOption {
|
||||
# type = str;
|
||||
# default = ".";
|
||||
# description = ''
|
||||
# When not using latexmk, provides a way to define the directory containing the output files.
|
||||
# Note that you need to set the output directory in latex.build.args too.
|
||||
#
|
||||
# When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
# '';
|
||||
# };
|
||||
# filename = mkOption {
|
||||
# type = str;
|
||||
# default = "";
|
||||
# description = ''
|
||||
# Allows overriding the default file name of the build artifact. This setting is used to find the correct PDF file to open during forward search.
|
||||
# '';
|
||||
# };
|
||||
# };
|
||||
|
||||
forwardSearch = {
|
||||
enable = mkOption {
|
||||
|
|
@ -416,7 +417,7 @@ in {
|
|||
config = mkIf (cfg.enable && (cfg.lsp.texlab.enable)) (
|
||||
let
|
||||
tl = cfg.lsp.texlab;
|
||||
build = tl.build;
|
||||
builder = cfg.build.builder;
|
||||
|
||||
listToLua = list: nullOnEmpty:
|
||||
if length list == 0
|
||||
|
|
@ -443,60 +444,87 @@ in {
|
|||
buildConfig = let
|
||||
# This function will sort through the builder options of ...texlab.build and count how many
|
||||
# builders have been enabled and get the attrs of the last enabled builder.
|
||||
getBuilder = {
|
||||
# getBuilder = {
|
||||
# enabledBuildersCount ? 0,
|
||||
# enabledBuilderName ? "",
|
||||
# index ? 0,
|
||||
# builderNamesList ? (
|
||||
# filter (
|
||||
# x: let
|
||||
# y = cfg.build.builders.${x};
|
||||
# in (isAttrs y && hasAttr "enable" y)
|
||||
# ) (attrNames cfg.build.builders)
|
||||
# ),
|
||||
# }: let
|
||||
# currentBuilderName = elemAt builderNamesList index;
|
||||
# currentBuilder = tl.build.${currentBuilderName};
|
||||
# nextIndex = index + 1;
|
||||
# currentState = {
|
||||
# enabledBuildersCount =
|
||||
# if currentBuilder.enable
|
||||
# then enabledBuildersCount + 1
|
||||
# else enabledBuildersCount;
|
||||
# enabledBuilderName =
|
||||
# if currentBuilder.enable
|
||||
# then currentBuilderName
|
||||
# else enabledBuilderName;
|
||||
# };
|
||||
# in
|
||||
# if length builderNamesList > nextIndex
|
||||
# then
|
||||
# getBuilder ({
|
||||
# inherit builderNamesList;
|
||||
# index = nextIndex;
|
||||
# }
|
||||
# // currentState)
|
||||
# else currentState;
|
||||
getEnabledBuildersCount = {
|
||||
enabledBuildersCount ? 0,
|
||||
enabledBuilderName ? "",
|
||||
index ? 0,
|
||||
builderNamesList ? (
|
||||
filter (
|
||||
x: let
|
||||
y = tl.build.${x};
|
||||
y = cfg.build.builders.${x};
|
||||
in (isAttrs y && hasAttr "enable" y)
|
||||
) (attrNames tl.build)
|
||||
) (attrNames cfg.build.builders)
|
||||
),
|
||||
}: let
|
||||
currentBuilderName = elemAt builderNamesList index;
|
||||
currentBuilder = tl.build.${currentBuilderName};
|
||||
currentBuilder = cfg.build.builders.${currentBuilderName};
|
||||
nextIndex = index + 1;
|
||||
currentState = {
|
||||
enabledBuildersCount =
|
||||
newEnabledBuildersCount =
|
||||
if currentBuilder.enable
|
||||
then enabledBuildersCount + 1
|
||||
else enabledBuildersCount;
|
||||
enabledBuilderName =
|
||||
if currentBuilder.enable
|
||||
then currentBuilderName
|
||||
else enabledBuilderName;
|
||||
};
|
||||
in
|
||||
if length builderNamesList > nextIndex
|
||||
then
|
||||
getBuilder ({
|
||||
getEnabledBuildersCount {
|
||||
inherit builderNamesList;
|
||||
enabledBuildersCount = newEnabledBuildersCount;
|
||||
index = nextIndex;
|
||||
}
|
||||
// currentState)
|
||||
else currentState;
|
||||
else newEnabledBuildersCount;
|
||||
|
||||
getBuilderResults = getBuilder {};
|
||||
builder = tl.build.${getBuilderResults.enabledBuilderName};
|
||||
builderArgs = collateArgs.lsp.texlab.build.${getBuilderResults.enabledBuilderName} tl.build;
|
||||
enabledBuildersCount = getEnabledBuildersCount {};
|
||||
# builder = tl.build.${getBuilderResults.enabledBuilderName};
|
||||
# builderArgs = collateArgs.lsp.texlab.build.${getBuilderResults.enabledBuilderName} tl.build;
|
||||
in
|
||||
if getBuilderResults.enabledBuildersCount == 0
|
||||
if enabledBuildersCount == 0
|
||||
then ""
|
||||
else if getBuilderResults.enabledBuildersCount > 1
|
||||
else if enabledBuildersCount > 1
|
||||
then throw "Texlab does not support having more than 1 builders enabled!"
|
||||
else ''
|
||||
build = {
|
||||
executable = "${builder.package}/bin/${builder.executable}",
|
||||
args = ${listToLua builderArgs false},
|
||||
forwardSearchAfter = ${boolToLua build.forwardSearchAfter},
|
||||
onSave = ${boolToLua build.onSave},
|
||||
useFileList = ${boolToLua build.useFileList},
|
||||
auxDirectory = ${stringToLua build.auxDirectory true},
|
||||
logDirectory = ${stringToLua build.logDirectory true},
|
||||
pdfDirectory = ${stringToLua build.pdfDirectory true},
|
||||
filename = ${stringToLua build.filename true},
|
||||
args = ${listToLua builder.args false},
|
||||
forwardSearchAfter = ${boolToLua cfg.build.forwardSearchAfter},
|
||||
onSave = ${boolToLua cfg.build.onSave},
|
||||
useFileList = ${boolToLua cfg.build.useFileList},
|
||||
auxDirectory = ${stringToLua cfg.build.auxDirectory true},
|
||||
logDirectory = ${stringToLua cfg.build.logDirectory true},
|
||||
pdfDirectory = ${stringToLua cfg.build.pdfDirectory true},
|
||||
filename = ${stringToLua cfg.build.filename true},
|
||||
},
|
||||
'';
|
||||
in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue