Compare commits

..

No commits in common. "91a3f67a9e6d3d557849d4a3708daeb2b8df559a" and "739415da0f9f6a0dcb7d812f70bc12e9dc9fce2c" have entirely different histories.

15 changed files with 317 additions and 505 deletions

View file

@ -33,10 +33,10 @@
default = ["vimPlugins" "nvim-treesitter" "builtGrammars" grammar]; default = ["vimPlugins" "nvim-treesitter" "builtGrammars" grammar];
}; };
mkEnableTreesitterOption = defaultCondition: language: mkEnableTreesitterOption = config: language:
mkOption { mkOption {
type = bool; type = bool;
default = defaultCondition; default = config.vim.languages.enableTreesitter;
description = "Whether to enable ${language} treesitter"; description = "Whether to enable ${language} treesitter";
}; };
in { in {

View file

@ -6,7 +6,8 @@
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) enum listOf package str; inherit (lib.types) enum listOf package str;
inherit (builtins) attrNames; inherit (lib.nvim.config) mkBool;
inherit (builtins) attrNames filter isAttrs hasAttr elemAt length;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
in { in {

View file

@ -29,10 +29,7 @@ in (
executable = mkOption { executable = mkOption {
type = str; type = str;
default = "latexmk"; default = "latexmk";
description = '' description = "The executable name from the build package that will be used to build/compile the tex.";
The executable name from the build package that will be used to
build/compile the tex.
'';
}; };
# Flag options # Flag options
@ -44,8 +41,6 @@ in (
}; };
}; };
# Optional flags must come before the base args because of how the latexmk
# command works
args = builderCfg: ( args = builderCfg: (
# Flags # Flags
(optionals builderCfg.pdfOutput ["-pdf"]) (optionals builderCfg.pdfOutput ["-pdf"])

View file

@ -12,16 +12,9 @@
inherit (lib) optionals; inherit (lib) optionals;
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;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
inherit (builtins) concatLists elem map toString attrNames filter isList; inherit (builtins) concatLists elem map toString;
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 (
@ -36,32 +29,23 @@ in (
executable = mkOption { executable = mkOption {
type = str; type = str;
default = "tectonic"; default = "tectonic";
description = '' description = "The executable name from the build package that will be used to build/compile the tex.";
The executable name from the build package that will be used to
build/compile the tex.
'';
}; };
# -- Flags -- # -- Flags --
keepIntermediates = mkBool false '' keepIntermediates = mkBool false ''
Whether to keep the intermediate files generated during processing. Whether to keep the intermediate files generated during processing.
If texlab is reporting build errors when there shouldn't be, disable If texlab is reporting build errors when there shouldn't be, disable this option.
this option.
''; '';
keepLogs = mkBool true '' keepLogs = mkBool true ''
Whether to keep the log files generated during processing. Whether to keep the log files generated during processing.
Without the keepLogs flag, texlab won't be able to report compilation Without the keepLogs flag, texlab won't be able to report compilation warnings.
warnings.
'';
onlyCached = mkBool false ''
Whether to use only resource files cached locally
''; '';
onlyCached = mkBool false "Whether to use only resource files cached locally";
synctex = mkBool true "Whether to generate SyncTeX data"; synctex = mkBool true "Whether to generate SyncTeX data";
untrustedInput = mkBool false '' untrustedInput = mkBool false "Whether to input is untrusted -- disable all known-insecure features";
Whether to diable all known-insecure features if the input is untrusted
'';
# -- Options -- # -- Options --
reruns = mkOption { reruns = mkOption {
@ -78,37 +62,28 @@ in (
}; };
bundle = mkOption { bundle = mkOption {
type = nullOr str; type = str;
default = null; default = "";
description = '' description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
The directory or Zip-format bundle file to find resource files instead
of the default.
'';
}; };
webBundle = mkOption { webBundle = mkOption {
type = nullOr str; type = str;
default = null; default = "";
description = '' description = "Use this URL to find resource files instead of the default";
Use this URL to find resource files instead of the default.
'';
}; };
outfmt = mkOption { outfmt = mkOption {
type = nullOr (enum [ type = enum [
"pdf" "pdf"
"html" "html"
"xdv" "xdv"
"aux" "aux"
"fmt" "fmt"
]); ""
default = null; ];
description = '' default = "";
The kind of output to generate. description = "The kind of output to generate";
Setting this to `null` (default) will let tectonic decide the most
appropriate output format, which usually be a pdf.
'';
}; };
hidePaths = mkOption { hidePaths = mkOption {
@ -118,27 +93,23 @@ in (
"./secrets.tex" "./secrets.tex"
"./passwords.tex" "./passwords.tex"
]; ];
description = '' description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
Tell the engine that no file at `<path/to/hide>` exists, if it tries
to read it.
'';
}; };
format = mkOption { format = mkOption {
type = nullOr str; type = str;
default = null; default = "";
description = '' description = "The name of the \"format\" file used to initialize the TeX engine";
The name of the \"format\" file used to initialize the TeX engine.
'';
}; };
color = mkOption { color = mkOption {
type = nullOr (enum [ type = enum [
"always" "always"
"auto" "auto"
"never" "never"
]); ""
default = null; ];
default = "";
example = "always"; example = "always";
description = "Enable/disable colorful log output"; description = "Enable/disable colorful log output";
}; };
@ -147,83 +118,37 @@ in (
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Add extra command line options to include in the tectonic build Add extra command line options to include in the tectonic build command.
command. Extra options added here will not overwrite the options set in as nvf options.
Extra options added here will not overwrite the options set in as nvf
options.
''; '';
}; };
}; };
# 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 != "") ["--bundle" "${toString builderCfg.bundle}"])
# ++ (optionals (builderCfg.webBundle != null) ["--web-bundle" "${toString builderCfg.webBundle}"]) ++ (optionals (builderCfg.webBundle != "") ["--web-bundle" "${toString builderCfg.webBundle}"])
# ++ (optionals (builderCfg.outfmt != null) ["--outfmt" "${toString builderCfg.outfmt}"]) ++ (optionals (builderCfg.outfmt != "") ["--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 != "") ["--format" "${toString builderCfg.format}"])
# ++ (optionals (builderCfg.color != null) ["--color" "${toString builderCfg.color}"]) ++ (optionals (builderCfg.color != "") ["--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]);
} }
) )

View file

@ -3,11 +3,11 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
inherit (lib.modules) mkIf;
inherit (lib.nvim.config) mkBool;
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.modules) mkIf;
inherit (lib.types) str nullOr; inherit (lib.types) str nullOr;
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
inherit (lib.nvim.config) mkBool;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
@ -48,28 +48,20 @@ in {
]; ];
options.vim.languages.tex.build = { options.vim.languages.tex.build = {
enable = mkBool (enabledBuildersCount == 1) '' enable =
Whether to enable configuring the builder. mkBool (enabledBuildersCount == 1) ''
Whether to enable configuring the builder.
By enabling any of the builders, this option will be automatically set. 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. If you enable more than one builder then an error will be thrown.
''; '';
forwardSearchAfter = mkBool false '' forwardSearchAfter = mkBool false "Set this property to true if you want to execute a forward search after a build.";
Set this property to `true` if you want to execute a forward search after
a build.
This can also be thought of as enabling auto updating for your pdf viewer. onSave = mkBool false "Set this property to true if you want to compile the project after saving a file.";
'';
onSave = mkBool false ''
Set this property to `true` if you want to compile the project after
saving a file.
'';
useFileList = mkBool false '' useFileList = mkBool false ''
When set to `true`, the server will use the `.fls` files produced by the When set to `true`, the server will use the `.fls` files produced by the TeX engine as an additional input for the project detection.
TeX engine as an additional input for the project detection.
Note that enabling this property might have an impact on performance. Note that enabling this property might have an impact on performance.
''; '';
@ -78,12 +70,10 @@ in {
type = str; type = str;
default = "."; default = ".";
description = '' description = ''
When not using latexmk, provides a way to define the directory When not using latexmk, provides a way to define the directory containing the .aux files.
containing the `.aux` files. Note that you need to set the aux directory in latex.build.args too.
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 When using a latexmkrc file, texlab will automatically infer the correct setting.
setting.
''; '';
}; };
@ -91,13 +81,10 @@ in {
type = str; type = str;
default = "."; default = ".";
description = '' description = ''
When not using latexmk, provides a way to define the directory When not using latexmk, provides a way to define the directory containing the build log files.
containing the build log files. Note that you need to change the output directory in your build arguments too.
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 When using a latexmkrc file, texlab will automatically infer the correct setting.
setting.
''; '';
}; };
@ -105,13 +92,10 @@ in {
type = str; type = str;
default = "."; default = ".";
description = '' description = ''
When not using latexmk, provides a way to define the directory When not using latexmk, provides a way to define the directory containing the output files.
containing the output files. Note that you need to set the output directory in latex.build.args too.
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 When using a latexmkrc file, texlab will automatically infer the correct setting.
setting.
''; '';
}; };
@ -120,20 +104,17 @@ in {
default = null; default = null;
description = '' description = ''
Allows overriding the default file name of the build artifact. Allows overriding the default file name of the build artifact.
This setting is used to find the correct PDF file to open during forward This setting is used to find the correct PDF file to open during forward search.
search.
''; '';
}; };
}; };
config = mkIf (enabledBuildersCount > 0) { config = mkIf (enabledBuildersCount > 0) {
assertions = [ assertions = [
{ {
assertion = enabledBuildersCount < 2; assertion = (enabledBuildersCount < 2);
message = '' message = "The nvf-tex-language implementation does not support having more than 1 builders enabled.";
The nvf-tex-language implementation does not support having more than
1 builders enabled.
'';
} }
]; ];
}; };

View file

@ -4,17 +4,16 @@
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.config) mkBool;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum; inherit (lib.types) bool str;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
in { in {
imports = [ imports = [
./build
./lsp
./pdfViewer
./treesitter.nix ./treesitter.nix
./lsp
./build
./pdfViewer
]; ];
options.vim.languages.tex = { options.vim.languages.tex = {
@ -22,46 +21,38 @@ in {
extraOpts = { extraOpts = {
texFlavor = { texFlavor = {
enable = mkBool false '' enable = mkOption {
Whether to set the `vim.g.tex_flavor` (`g:tex_flavor`) option in type = bool;
your Lua config. default = false;
example = true;
description = ''
Whether to set the `vim.g.tex_flavor` (`g:tex_flavor`) option in your Lua config.
When opening a `.tex` file vim will try to automatically try to When opening a .tex file vim will try to automatically try to determine the file type from
determine the file type from the three options: `plaintex` (for the three options: plaintex (for plain TeX), context (for ConTeXt), or tex (for LaTeX).
plain TeX), `context` (for ConTeXt), or `tex` (for LaTeX). This can either be done by a indicator line of the form `%&<format>` on the first line or
This can either be done by a indicator line of the form `%&<format>` if absent vim will search the file for keywords to try and determine the filetype.
on the first line or, if absent, vim will search the file for If no filetype can be determined automatically then by default it will fallback to plaintex.
keywords to try and determine the filetype. If no filetype can be
determined automatically then by default it will fallback to
plaintex.
This option will enable setting the tex flavor in your lua config This option will enable setting the tex flavor in your lua config and you can set its value
and you can set its value using the using the `vim.languages.tex.lsp.extraOpts.texFlavor.flavor = <flavor>` in your nvf config.
`vim.languages.tex.lsp.extraOpts.texFlavor.flavor = <flavor>` in
your nvf config.
Setting this option to `false` will omit the Setting this option to `false` will omit the `vim.g.tex_flavor = <flavor>` line from your lua
`vim.g.tex_flavor = <flavor>` line from your lua config entirely config entirely (unless you manually set it elsewhere of course).
(unless you manually set it elsewhere of course). '';
''; };
flavor = mkOption { flavor = mkOption {
type = enum [ type = str;
"plaintex"
"contex"
"tex"
];
default = "plaintex"; default = "plaintex";
example = "tex"; example = "tex";
description = '' description = ''
The flavor to set as a fallback for when vim cannot automatically The flavor to set as a fallback for when vim cannot automatically determine the tex flavor when
determine the tex flavor when opening a `.tex` document. opening a .tex document.
The options are: `plaintex` (for plain TeX), `context` (for The options are: plaintex (for plain TeX), context (for ConTeXt), or tex (for LaTeX).
ConTeXt), or `tex` (for LaTeX).
This can be particularly useful for when using This can be particularly useful for when using `vim.utility.new-file-template` options for
`vim.utility.new-file-template` options for creating templates when creating templates when no context has yet been added to a new file.
no context has yet been added to a new file.
''; '';
}; };
}; };

View file

@ -4,35 +4,24 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) isString map; inherit (lib.options) mkOption;
inherit (lib) optionalAttrs;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) attrs either enum ints listOf nullOr package path str submodule;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
inherit (lib.options) mkOption mkPackageOption; inherit (builtins) isString map;
inherit
(lib.types)
attrs
either
enum
ints
listOf
nullOr
package
path
str
submodule
;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
texlabCfg = cfg.lsp.texlab; texlabCfg = cfg.lsp.texlab;
builderCfg = cfg.build.builder; builderCfg = cfg.build.builder;
in { in {
options.vim.languages.tex.lsp.texlab = { options.vim.languages.tex.lsp.texlab = {
enable = mkBool config.vim.languages.enableLSP '' enable = mkBool config.vim.languages.enableLSP "Whether to enable Tex LSP support (texlab)";
Whether to enable Tex LSP support (texlab).
'';
package = mkPackageOption pkgs "texlab" {}; package = mkOption {
type = package;
default = pkgs.texlab;
description = "texlab package";
};
chktex = { chktex = {
enable = mkBool false "Whether to enable linting via chktex"; enable = mkBool false "Whether to enable linting via chktex";
@ -46,9 +35,7 @@ in {
''; '';
}; };
onOpenAndSave = mkBool false '' onOpenAndSave = mkBool false "Lint using chktex after opening and saving a file.";
Lint using chktex after opening and saving a file.
'';
onEdit = mkBool false "Lint using chktex after editing a file."; onEdit = mkBool false "Lint using chktex after editing a file.";
@ -56,8 +43,7 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Additional command line arguments that are passed to chktex after Additional command line arguments that are passed to chktex after editing a file.
editing a file.
Don't redefine the `-I` and `-f` flags as they are set by the server. Don't redefine the `-I` and `-f` flags as they are set by the server.
''; '';
}; };
@ -72,15 +58,11 @@ in {
]; ];
default = "fuzzy-ignore-case"; default = "fuzzy-ignore-case";
description = '' description = ''
Modifies the algorithm used to filter the completion items returned to Modifies the algorithm used to filter the completion items returned to the client. Possibles values are:
the client. - fuzzy: Fuzzy string matching (case sensitive)
Possibles values are: - fuzzy-ignore-case: Fuzzy string matching (case insensitive)
- `fuzzy`: Fuzzy string matching (case sensitive). - prefix: Filter out items that do not start with the search text (case sensitive)
- `fuzzy-ignore-case`: Fuzzy string matching (case insensitive). - prefix-ignore-case: Filter out items that do not start with the search text (case insensitive)
- `prefix`: Filter out items that do not start with the search text
(case sensitive).
- `prefix-ignore-case`: Filter out items that do not start with the
search text (case insensitive).
''; '';
}; };
@ -95,16 +77,13 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported A list of regular expressions used to filter the list of reported diagnostics.
diagnostics. If specified, only diagnostics that match at least one of the specified patterns are sent to the client.
If specified, only diagnostics that match at least one of the
specified patterns are sent to the client.
See also `texlab.diagnostics.ignoredPatterns`. See also texlab.diagnostics.ignoredPatterns.
Hint: If both allowedPatterns and ignoredPatterns are set, then Hint: If both allowedPatterns and ignoredPatterns are set, then allowed patterns are applied first.
allowed patterns are applied first. Afterwards, the results are Afterwards, the results are filtered with the ignored patterns.
filtered with the ignored patterns.
''; '';
}; };
@ -112,48 +91,35 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported A list of regular expressions used to filter the list of reported diagnostics.
diagnostics. If specified, only diagnostics that match none of the specified patterns are sent to the client.
If specified, only diagnostics that match none of the specified
patterns are sent to the client.
See also `texlab.diagnostics.allowedPatterns`. See also texlab.diagnostics.allowedPatterns.
''; '';
}; };
}; };
experimental = { experimental = {
followPackageLinks = mkBool false '' followPackageLinks = mkBool false "If set to true, dependencies of custom packages are resolved and included in the dependency graph.";
If set to `true`, dependencies of custom packages are resolved and
included in the dependency graph.
'';
mathEnvironments = mkOption { mathEnvironments = mkOption {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = "Allows extending the list of environments which the server considers as math environments (for example `align*` or `equation`).";
Allows extending the list of environments which the server considers
as math environments (for example `align*` or `equation`).
'';
}; };
enumEnvironments = mkOption { enumEnvironments = mkOption {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = "Allows extending the list of environments which the server considers as enumeration environments (for example `enumerate` or `itemize`).";
Allows extending the list of environments which the server considers
as enumeration environments (for example `enumerate` or `itemize`).
'';
}; };
verbatimEnvironments = mkOption { verbatimEnvironments = mkOption {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Allows extending the list of environments which the server considers Allows extending the list of environments which the server considers as verbatim environments (for example `minted` or `lstlisting`).
as verbatim environments (for example `minted` or `lstlisting`). This can be used to suppress diagnostics from environments that do not contain LaTeX code.
This can be used to suppress diagnostics from environments that do
not contain LaTeX code.
''; '';
}; };
@ -161,11 +127,9 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Allows extending the list of commands which the server considers as Allows extending the list of commands which the server considers as citation commands (for example `\cite`).
citation commands (for example `\cite`).
Hint: Additional commands need to be written without a leading `\` Hint: Additional commands need to be written without a leading `\` (e. g. `foo` instead of `\foo`).
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -175,8 +139,7 @@ in {
description = '' description = ''
Allows extending the list of `\label`-like commands. Allows extending the list of `\label`-like commands.
Hint: Additional commands need to be written without a leading `\` Hint: Additional commands need to be written without a leading `\` (e. g. `foo` instead of `\foo`).
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -186,8 +149,7 @@ in {
description = '' description = ''
Allows extending the list of `\ref`-like commands. Allows extending the list of `\ref`-like commands.
Hint: Additional commands need to be written without a leading `\` Hint: Additional commands need to be written without a leading `\` (e. g. `foo` instead of `\foo`).
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -197,8 +159,7 @@ in {
description = '' description = ''
Allows extending the list of `\crefrange`-like commands. Allows extending the list of `\crefrange`-like commands.
Hint: Additional commands need to be written without a leading `\` Hint: Additional commands need to be written without a leading `\` (e. g. `foo` instead of `\foo`).
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -206,16 +167,13 @@ in {
type = listOf (listOf str); type = listOf (listOf str);
default = []; default = [];
description = '' description = ''
Allows associating a label definition command with a custom prefix. Allows associating a label definition command with a custom prefix. Consider,
Consider,
``` ```
\newcommand{\theorem}[1]{\label{theorem:#1}} \newcommand{\theorem}[1]{\label{theorem:#1}}
\theorem{foo} \theorem{foo}
``` ```
Then setting `texlab.experimental.labelDefinitionPrefixes` to Then setting `texlab.experimental.labelDefinitionPrefixes` to `[["theorem", "theorem:"]]` and adding "theorem"
`[["theorem", "theorem:"]]` and adding `theorem` to to `texlab.experimental.labelDefinitionCommands` will make the server recognize the `theorem:foo` label.
`texlab.experimental.labelDefinitionCommands` will make the server
recognize the `theorem:foo` label.
''; '';
}; };
@ -237,8 +195,7 @@ in {
baz = 314; baz = 314;
}; };
description = '' description = ''
For any options that do not have options provided through nvf this can For any options that do not have options provided through nvf this can be used to add them.
be used to add them.
Options already declared in nvf config will NOT be overridden. Options already declared in nvf config will NOT be overridden.
Options will be placed in: Options will be placed in:
@ -261,12 +218,10 @@ in {
enable = mkBool false '' enable = mkBool false ''
Whether to enable forward search. Whether to enable forward search.
Enable this option if you want to have the compiled document appear in Enable this option if you want to have the compiled document appear in your chosen PDF viewer.
your chosen PDF viewer.
For some options see [here](https://github.com/latex-lsp/texlab/wiki/Previewing). For some options see [here](https://github.com/latex-lsp/texlab/wiki/Previewing).
Note this is not all the options, but can act as a guide to help you Note this is not all the options, but can act as a guide to help you along with custom configs.
along with custom configs.
''; '';
package = mkOption { package = mkOption {
@ -284,8 +239,7 @@ in {
type = str; type = str;
default = cfg.pdfViewer.executable; default = cfg.pdfViewer.executable;
description = '' description = ''
Defines the executable of the PDF previewer. The previewer needs to Defines the executable of the PDF previewer. The previewer needs to support SyncTeX.
support SyncTeX.
By default it is set to the executable of the pdfViewer option. By default it is set to the executable of the pdfViewer option.
''; '';
@ -295,37 +249,28 @@ in {
type = listOf str; type = listOf str;
default = cfg.pdfViewer.args; default = cfg.pdfViewer.args;
description = '' description = ''
Defines additional arguments that are passed to the configured Defines additional arguments that are passed to the configured previewer to perform the forward search.
previewer to perform the forward search. The placeholders %f, %p, %l will be replaced by the server.
The placeholders `%f`, `%p`, `%l` will be replaced by the server.
By default it is set to the args of the pdfViewer option. By default it is set to the args of the pdfViewer option.
Placeholders: Placeholders:
- `%f`: The path of the current TeX file. - %f: The path of the current TeX file.
- `%p`: The path of the current PDF file. - %p: The path of the current PDF file.
- `%l`: The current line number. - %l: The current line number.
''; '';
}; };
}; };
formatter = { formatter = {
formatterLineLength = mkOption { formatterLineLength = mkOption {
type = ints.unsigned; type = ints.positive;
default = 80; default = 80;
description = '' description = "Defines the maximum amount of characters per line (0 = disable) when formatting BibTeX files.";
Defines the maximum amount of characters per line when formatting
BibTeX files.
Setting this value to 0 will disable this option.
'';
}; };
bibtexFormatter = mkOption { bibtexFormatter = mkOption {
type = enum [ type = enum ["texlab" "latexindent"];
"texlab"
"latexindent"
];
default = "texlab"; default = "texlab";
description = '' description = ''
Defines the formatter to use for BibTeX formatting. Defines the formatter to use for BibTeX formatting.
@ -334,10 +279,7 @@ in {
}; };
latexFormatter = mkOption { latexFormatter = mkOption {
type = enum [ type = enum ["texlab" "latexindent"];
"texlab"
"latexindent"
];
default = "latexindent"; default = "latexindent";
description = '' description = ''
Defines the formatter to use for LaTeX formatting. Defines the formatter to use for LaTeX formatting.
@ -348,23 +290,14 @@ in {
}; };
inlayHints = { inlayHints = {
labelDefinitions = mkBool true '' labelDefinitions = mkBool true "When enabled, the server will return inlay hints for `\\label`-like commands.";
When enabled, the server will return inlay hints for `\label`-like
commands.
'';
labelReferences = mkBool true '' labelReferences = mkBool true "When enabled, the server will return inlay hints for `\\ref``-like commands.";
When enabled, the server will return inlay hints for `\ref`-like
commands.
'';
maxLength = mkOption { maxLength = mkOption {
type = nullOr ints.positive; type = nullOr ints.positive;
default = null; default = null;
description = '' description = "When set, the server will truncate the text of the inlay hints to the specified length.";
When set, the server will truncate the text of the inlay hints to the
specified length.
'';
}; };
}; };
@ -374,33 +307,25 @@ in {
default = null; default = null;
description = '' description = ''
Defines the path of a file containing the latexindent configuration. Defines the path of a file containing the latexindent configuration.
This corresponds to the `--local=file.yaml` flag of latexindent. This corresponds to the --local=file.yaml flag of latexindent.
By default the configuration inside the project root directory is By default the configuration inside the project root directory is used.
used.
''; '';
}; };
modifyLineBreaks = mkBool false '' modifyLineBreaks = mkBool false ''
Modifies linebreaks before, during, and at the end of code blocks when Modifies linebreaks before, during, and at the end of code blocks when formatting with latexindent.
formatting with latexindent. This corresponds to the --modifylinebreaks flag of latexindent.
This corresponds to the `--modifylinebreaks` flag of latexindent.
''; '';
replacement = mkOption { replacement = mkOption {
type = nullOr (enum [ type = nullOr (enum ["-r" "-rv" "-rr"]);
"-r"
"-rv"
"-rr"
]);
default = null; default = null;
description = '' description = ''
Defines an additional replacement flag that is added when calling Defines an additional replacement flag that is added when calling latexindent. This can be one of the following:
latexindent. - "-r"
This can be one of the following: - "-rv"
- `-r` - "-rr"
- `-rv` - null
- `-rr`
- `null`
By default no replacement flag is passed. By default no replacement flag is passed.
''; '';
}; };
@ -413,18 +338,15 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported A list of regular expressions used to filter the list of reported document symbols.
document symbols. If specified, only symbols that match at least one of the specified patterns are sent to the client.
If specified, only symbols that match at least one of the specified Symbols are filtered recursively so nested symbols can still be sent to the client even though the
patterns are sent to the client. parent node is removed from the results.
Symbols are filtered recursively so nested symbols can still be sent
to the client even though the parent node is removed from the results.
See also `texlab.symbols.ignoredPatterns`. See also `texlab.symbols.ignoredPatterns`.
Hint: If both `allowedPatterns` and `ignoredPatterns` are set, then Hint: If both allowedPatterns and ignoredPatterns are set, then allowed patterns are applied first.
allowed patterns are applied first. Afterwards, the results are Afterwards, the results are filtered with the ignored patterns.
filtered with the ignored patterns.
''; '';
}; };
@ -432,10 +354,8 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported A list of regular expressions used to filter the list of reported document symbols.
document symbols. If specified, only symbols that match none of the specified patterns are sent to the client.
If specified, only symbols that match none of the specified patterns
are sent to the client.
See also `texlab.symbols.allowedPatterns`. See also `texlab.symbols.allowedPatterns`.
''; '';
@ -451,14 +371,10 @@ in {
displayName = mkOption { displayName = mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
description = '' description = "The name shown in the document symbols. Defaults to the value of `name`.";
The name shown in the document symbols.
Defaults to the value of `name`.
'';
}; };
label = mkBool false '' label = mkBool false ''
If set to `true`, the server will try to match a label to If set, the server will try to match a label to environment and append its number.
environment and append its number.
''; '';
}; };
}); });
@ -471,10 +387,9 @@ in {
} }
]; ];
description = '' description = ''
A list of objects that allows extending the list of environments that A list of objects that allows extending the list of environments that are part of the document symbols.
are part of the document symbols.
See also `texlab.symbols.allowedPatterns`. See also texlab.symbols.allowedPatterns.
Type: listOf submodule: Type: listOf submodule:
- name: - name:
@ -487,12 +402,11 @@ in {
- default: <name> - default: <name>
- label: - label:
- type: boolean - type: boolean
- description: If set, the server will try to match a label to - description: If set, the server will try to match a label to environment and append its number.
environment and append its number.
- default: false - default: false
Note: This functionality may not be working, please follow Note: This functionality may not be working, please follow https://github.com/latex-lsp/texlab/pull/1311
https://github.com/latex-lsp/texlab/pull/1311 for status updates. for status updates.
''; '';
}; };
}; };
@ -530,54 +444,70 @@ in {
} }
# #
# -- Build -- # -- Build --
// (optionalAttrs cfg.build.enable { // (
build = { if cfg.build.enable
inherit then {
(cfg.build) build = {
onSave inherit
useFileList (cfg.build)
auxDirectory onSave
logDirectory useFileList
pdfDirectory auxDirectory
filename logDirectory
forwardSearchAfter pdfDirectory
; filename
inherit (builderCfg) args; forwardSearchAfter
executable = "${builderCfg.package}/bin/${builderCfg.executable}"; ;
}; inherit (builderCfg) args;
}) executable = "${builderCfg.package}/bin/${builderCfg.executable}";
};
}
else {}
)
# #
# -- Chktex -- # -- Chktex --
// (optionalAttrs texlabCfg.chktex.enable { // (
chktex = { if texlabCfg.chktex.enable
inherit (texlabCfg.chktex) onOpenAndSave onEdit additionalArgs; then {
}; chktex = {
}) inherit (texlabCfg.chktex) onOpenAndSave onEdit additionalArgs;
};
}
else {}
)
# #
# -- Forward Search -- # -- Forward Search --
// (optionalAttrs texlabCfg.forwardSearch.enable { // (
forwardSearch = { if texlabCfg.forwardSearch.enable
inherit (texlabCfg.forwardSearch) args; then {
executable = "${texlabCfg.forwardSearch.package}/bin/${texlabCfg.forwardSearch.executable}"; forwardSearch = {
}; inherit (texlabCfg.forwardSearch) args;
}) executable = "${texlabCfg.forwardSearch.package}/bin/${texlabCfg.forwardSearch.executable}";
};
}
else {}
)
# #
# -- Symbols -- # -- Symbols --
// (optionalAttrs texlabCfg.symbols.enable { // (
symbols = { if texlabCfg.symbols.enable
inherit (texlabCfg.symbols) allowedPatterns ignoredPatterns; then {
symbols = {
inherit (texlabCfg.symbols) allowedPatterns ignoredPatterns;
customEnvironments = customEnvironments =
map (x: { map (x: {
inherit (x) name label; inherit (x) name label;
displayName = displayName =
if isString x.displayName if isString x.displayName
then x.displayName then x.displayName
else x.name; else x.name;
}) })
texlabCfg.symbols.customEnvironments; texlabCfg.symbols.customEnvironments;
}; };
}) }
else {}
)
# #
# -- Extra Settings -- # -- Extra Settings --
// texlabCfg.extraLuaSettings // texlabCfg.extraLuaSettings

View file

@ -9,8 +9,8 @@
# The viewer template # The viewer template
template = import ./viewerTemplate.nix; template = import ./viewerTemplate.nix;
inherit (lib.options) mkOption mkEnableOption mkPackageOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str listOf; inherit (lib.types) package str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,8 +18,10 @@ in (
options = { options = {
enable = mkEnableOption "enable using a custom pdf viewer."; enable = mkEnableOption "enable using a custom pdf viewer.";
package = mkPackageOption pkgs "okular" { package = mkOption {
extraDescription = "custom viewer package"; type = package;
example = pkgs.okular;
description = "custom viewer package";
}; };
executable = mkOption { executable = mkOption {
@ -30,10 +32,7 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
example = [ example = ["--unique" "file:%p#src:%l%f"];
"--unique"
"file:%p#src:%l%f"
];
description = "Arguments to pass to the viewer."; description = "Arguments to pass to the viewer.";
}; };
}; };

View file

@ -5,10 +5,9 @@
}: let }: let
defaultPdfViewerName = "okular"; defaultPdfViewerName = "okular";
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) str package listOf; inherit (lib.types) str package listOf;
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
viewerCfg = cfg.pdfViewer; viewerCfg = cfg.pdfViewer;
@ -45,11 +44,14 @@
# Get the index that will be used for the next iteration # Get the index that will be used for the next iteration
nextIndex = index + 1; nextIndex = index + 1;
# Increment the count that is recording the number of enabled pdf viewers # Increment the count that is recording the number of enabled pdf viewers if
# if this viewer is enabled, otherwise leave it as is. # this viewer is enabled, otherwise leave it as is.
newEnabledPdfViewersCount = newEnabledPdfViewersCount =
if currentPdfViewer.enable if currentPdfViewer.enable
then enabledPdfViewersCount + 1 then
if enabledPdfViewersCount > 0
then throw "nvf-tex-language does not support having more than 1 pdf viewer enabled!"
else enabledPdfViewersCount + 1
else enabledPdfViewersCount; else enabledPdfViewersCount;
# If this pdf viewer is enabled, set is as the enabled viewer. # If this pdf viewer is enabled, set is as the enabled viewer.
@ -82,8 +84,8 @@ in {
imports = [ imports = [
./custom.nix ./custom.nix
./okular.nix ./okular.nix
./qpdfview.nix
./sioyek.nix ./sioyek.nix
./qpdfview.nix
./zathura.nix ./zathura.nix
]; ];
@ -94,12 +96,10 @@ in {
description = '' description = ''
The name of the pdf viewer to use. The name of the pdf viewer to use.
This value will be automatically set when any of the viewers are This value will be automatically set when any of the viewers are enabled.
enabled.
Setting this option option manually is not recommended but can be used Setting this option option manually is not recommended but can be used for some very technical nix-ing.
for some very technical nix-ing. If you wish to use a custom viewer, If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
please use the `custom` entry provided under `viewers`.
''; '';
}; };
@ -109,12 +109,10 @@ in {
description = '' description = ''
The package of the pdf viewer to use. The package of the pdf viewer to use.
This value will be automatically set when any of the viewers are This value will be automatically set when any of the viewers are enabled.
enabled.
Setting this option option manually is not recommended but can be used Setting this option option manually is not recommended but can be used for some very technical nix-ing.
for some very technical nix-ing. If you wish to use a custom viewer, If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
please use the `custom` entry provided under `viewers`.
''; '';
}; };
@ -124,12 +122,10 @@ in {
description = '' description = ''
The executable for the pdf viewer to use. The executable for the pdf viewer to use.
This value will be automatically set when any of the viewers are This value will be automatically set when any of the viewers are enabled.
enabled.
Setting this option option manually is not recommended but can be used Setting this option option manually is not recommended but can be used for some very technical nix-ing.
for some very technical nix-ing. If you wish to use a custom viewer, If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
please use the `custom` entry provided under `viewers`.
''; '';
}; };
@ -139,25 +135,11 @@ in {
description = '' description = ''
The command line arguments to use when calling the pdf viewer command. The command line arguments to use when calling the pdf viewer command.
This value will be automatically set when any of the viewers are This value will be automatically set when any of the viewers are enabled.
enabled.
Setting this option option manually is not recommended but can be used Setting this option option manually is not recommended but can be used for some very technical nix-ing.
for some very technical nix-ing. If you wish to use a custom viewer, If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
please use the `custom` entry provided under `viewers`.
''; '';
}; };
}; };
config = mkIf (enabledPdfViewersInfo.count > 0) {
assertions = [
{
assertion = enabledPdfViewersInfo.count < 2;
message = ''
The nvf-tex-language implementation does not support having more than
1 pdf viewers enabled.
'';
}
];
};
} }

View file

@ -9,8 +9,8 @@
# The viewer template # The viewer template
template = import ./viewerTemplate.nix; template = import ./viewerTemplate.nix;
inherit (lib.options) mkOption mkEnableOption mkPackageOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str listOf; inherit (lib.types) package str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,7 +18,11 @@ in (
options = { options = {
enable = mkEnableOption "enable okular as the pdf file previewer."; enable = mkEnableOption "enable okular as the pdf file previewer.";
package = mkPackageOption pkgs "okular" {}; package = mkOption {
type = package;
default = pkgs.okular;
description = "okular package";
};
executable = mkOption { executable = mkOption {
type = str; type = str;
@ -28,10 +32,7 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
default = [ default = ["--unique" "file:%p#src:%l%f"];
"--unique"
"file:%p#src:%l%f"
];
description = "Arguments to pass to the viewer."; description = "Arguments to pass to the viewer.";
}; };
}; };

View file

@ -9,8 +9,8 @@
# The viewer template # The viewer template
template = import ./viewerTemplate.nix; template = import ./viewerTemplate.nix;
inherit (lib.options) mkOption mkEnableOption mkPackageOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str listOf; inherit (lib.types) package str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,7 +18,11 @@ in (
options = { options = {
enable = mkEnableOption "enable qpdfview as the pdf file previewer."; enable = mkEnableOption "enable qpdfview as the pdf file previewer.";
package = mkPackageOption pkgs "qpdfview" {}; package = mkOption {
type = package;
default = pkgs.qpdfview;
description = "qpdfview package";
};
executable = mkOption { executable = mkOption {
type = str; type = str;
@ -28,10 +32,7 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
default = [ default = ["--unique" "%p#src:%f:%l:1"];
"--unique"
"%p#src:%f:%l:1"
];
description = "Arguments to pass to the viewer."; description = "Arguments to pass to the viewer.";
}; };
}; };

View file

@ -9,16 +9,20 @@
# The viewer template # The viewer template
template = import ./viewerTemplate.nix; template = import ./viewerTemplate.nix;
inherit (lib.options) mkOption mkEnableOption mkPackageOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str listOf; inherit (lib.types) package str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
options = { options = {
enable = mkEnableOption "sioyek as the pdf file previewer."; enable = mkEnableOption "enable sioyek as the pdf file previewer.";
package = mkPackageOption pkgs "sioyek" {}; package = mkOption {
type = package;
default = pkgs.sioyek;
description = "sioyek package";
};
executable = mkOption { executable = mkOption {
type = str; type = str;
@ -43,9 +47,9 @@ in (
description = '' description = ''
Arguments to pass to the viewer. Arguments to pass to the viewer.
By default, this is the only viewer that supports the inverse search By default, this is the only viewer that supports the inverse search feature by
feature by command line arguments and doesn't explicitly require extra command line arguments and doesn't explicitly require extra tinkering else where
tinkering else where in your config. in your config.
''; '';
}; };
}; };

View file

@ -56,8 +56,7 @@ in {
opts) opts)
options; options;
# Check that the language and this pdf viewer have been enabled before making # Check that the language and this pdf viewer have been enabled before making any config.
# any config.
config = mkIf (cfg.enable && viewerCfg.enable) { config = mkIf (cfg.enable && viewerCfg.enable) {
vim.languages.tex.pdfViewer = { vim.languages.tex.pdfViewer = {
inherit name; inherit name;

View file

@ -9,8 +9,8 @@
# The viewer template # The viewer template
template = import ./viewerTemplate.nix; template = import ./viewerTemplate.nix;
inherit (lib.options) mkOption mkEnableOption mkPackageOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str listOf; inherit (lib.types) package str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,7 +18,11 @@ in (
options = { options = {
enable = mkEnableOption "enable zathura as the pdf file previewer."; enable = mkEnableOption "enable zathura as the pdf file previewer.";
package = mkPackageOption pkgs "zathura" {}; package = mkOption {
type = package;
default = pkgs.zathura;
description = "zathura package";
};
executable = mkOption { executable = mkOption {
type = str; type = str;
@ -28,11 +32,7 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
default = [ default = ["--synctex-forward" "%l:1:%f" "%p"];
"--synctex-forward"
"%l:1:%f"
"%p"
];
description = "Arguments to pass to the viewer."; description = "Arguments to pass to the viewer.";
}; };
}; };

View file

@ -4,20 +4,23 @@
lib, lib,
... ...
}: let }: let
# inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption mkEnableTreesitterOption;
mkEnableTreesitterOption = lib.nvim.types.mkEnableTreesitterOption config.vim.languages.enableTreesitter;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
# mkEnableTreesitterOption = description: mkEnableOption description // {default = config.vim.languages.enableTreesitter;};
in { in {
options.vim.languages.tex.treesitter = { options.vim.languages.tex.treesitter = {
latex = { latex = {
enable = mkEnableTreesitterOption "latex"; # enable = mkEnableTreesitterOption "Whether to enable Latex treesitter";
enable = mkEnableTreesitterOption config "latex";
package = mkGrammarOption pkgs "latex"; package = mkGrammarOption pkgs "latex";
}; };
bibtex = { bibtex = {
enable = mkEnableTreesitterOption "bibtex"; # enable = mkEnableTreesitterOption "Whether to enable Bibtex treesitter";
enable = mkEnableTreesitterOption config "bibtex";
package = mkGrammarOption pkgs "bibtex"; package = mkGrammarOption pkgs "bibtex";
}; };
}; };