mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 15:35:30 +00:00
Refactored to use the nvf library toLuaObject as well as other improvements and cleanups
This commit is contained in:
parent
ca9ab42048
commit
1bebf495dc
3 changed files with 119 additions and 129 deletions
|
|
@ -4,34 +4,71 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) bool str;
|
||||
inherit (lib.types) str nullOr;
|
||||
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
cfg = config.vim.languages.tex;
|
||||
|
||||
enabledBuildersCount = let
|
||||
# This function will sort through the builder options and count how many
|
||||
# builders have been enabled.
|
||||
getEnabledBuildersCount = {
|
||||
enabledBuildersCount ? 0,
|
||||
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 = cfg.build.builders.${currentBuilderName};
|
||||
nextIndex = index + 1;
|
||||
newEnabledBuildersCount =
|
||||
if currentBuilder.enable
|
||||
then enabledBuildersCount + 1
|
||||
else enabledBuildersCount;
|
||||
in
|
||||
if length builderNamesList > nextIndex
|
||||
then
|
||||
getEnabledBuildersCount {
|
||||
inherit builderNamesList;
|
||||
enabledBuildersCount = newEnabledBuildersCount;
|
||||
index = nextIndex;
|
||||
}
|
||||
else newEnabledBuildersCount;
|
||||
in (getEnabledBuildersCount {});
|
||||
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.
|
||||
enable =
|
||||
mkBool (
|
||||
if enabledBuildersCount > 1
|
||||
then throw "nvf-tex-language does not support having more than 1 builders enabled!"
|
||||
else (enabledBuildersCount == 1)
|
||||
) ''
|
||||
Whether to enable configuring the builder.
|
||||
|
||||
Note that enabling this property might have an impact on performance.
|
||||
By enabling any of the builders, this option will be automatically set.
|
||||
If you enable more than one builder then an error will be thrown.
|
||||
'';
|
||||
};
|
||||
|
||||
forwardSearchAfter = mkBool false "Set this property to true if you want to execute a forward search after a build.";
|
||||
|
||||
onSave = mkBool false "Set this property to true if you want to compile the project after saving a file.";
|
||||
|
||||
useFileList = mkBool false ''
|
||||
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 = ".";
|
||||
|
|
@ -42,6 +79,7 @@ in {
|
|||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
|
||||
logDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
|
|
@ -52,6 +90,7 @@ in {
|
|||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
|
||||
pdfDirectory = mkOption {
|
||||
type = str;
|
||||
default = ".";
|
||||
|
|
@ -62,9 +101,10 @@ in {
|
|||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||
'';
|
||||
};
|
||||
|
||||
filename = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
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.
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue