Cleaned up documentation and other performed other code cleanups

This commit is contained in:
isaacST08 2025-02-11 21:14:24 -07:00
commit c3c720f4a2
13 changed files with 343 additions and 213 deletions

View file

@ -6,8 +6,7 @@
}: 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 (lib.nvim.config) mkBool; inherit (builtins) attrNames;
inherit (builtins) attrNames filter isAttrs hasAttr elemAt length;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
in { in {

View file

@ -29,7 +29,10 @@ in (
executable = mkOption { executable = mkOption {
type = str; type = str;
default = "latexmk"; default = "latexmk";
description = "The executable name from the build package that will be used to build/compile the tex."; description = ''
The executable name from the build package that will be used to
build/compile the tex.
'';
}; };
# Flag options # Flag options

View file

@ -12,7 +12,7 @@
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; inherit (lib.types) enum ints listOf str nullOr;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
inherit (builtins) concatLists elem map toString; inherit (builtins) concatLists elem map toString;
@ -29,23 +29,32 @@ in (
executable = mkOption { executable = mkOption {
type = str; type = str;
default = "tectonic"; default = "tectonic";
description = "The executable name from the build package that will be used to build/compile the tex."; description = ''
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 this option. If texlab is reporting build errors when there shouldn't be, disable
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 warnings. Without the keepLogs flag, texlab won't be able to report compilation
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 "Whether to input is untrusted -- disable all known-insecure features"; untrustedInput = mkBool false ''
Whether to diable all known-insecure features if the input is untrusted
'';
# -- Options -- # -- Options --
reruns = mkOption { reruns = mkOption {
@ -62,28 +71,37 @@ in (
}; };
bundle = mkOption { bundle = mkOption {
type = str; type = nullOr str;
default = ""; default = null;
description = "Use this directory or Zip-format bundle file to find resource files instead of the default"; description = ''
Use this directory or Zip-format bundle file to find resource files
instead of the default.
'';
}; };
webBundle = mkOption { webBundle = mkOption {
type = str; type = nullOr str;
default = ""; default = null;
description = "Use this URL to find resource files instead of the default"; description = ''
Use this URL to find resource files instead of the default.
'';
}; };
outfmt = mkOption { outfmt = mkOption {
type = enum [ type = nullOr (enum [
"pdf" "pdf"
"html" "html"
"xdv" "xdv"
"aux" "aux"
"fmt" "fmt"
"" ]);
]; default = null;
default = ""; description = ''
description = "The kind of output to generate"; 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 {
@ -93,23 +111,27 @@ in (
"./secrets.tex" "./secrets.tex"
"./passwords.tex" "./passwords.tex"
]; ];
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it."; description = ''
Tell the engine that no file at `<path/to/hide>` exists, if it tries
to read it.
'';
}; };
format = mkOption { format = mkOption {
type = str; type = nullOr str;
default = ""; default = null;
description = "The name of the \"format\" file used to initialize the TeX engine"; description = ''
The name of the \"format\" file used to initialize the TeX engine.
'';
}; };
color = mkOption { color = mkOption {
type = enum [ type = nullOr (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";
}; };
@ -118,8 +140,10 @@ in (
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Add extra command line options to include in the tectonic build command. Add extra command line options to include in the tectonic build
Extra options added here will not overwrite the options set in as nvf options. command.
Extra options added here will not overwrite the options set in as nvf
options.
''; '';
}; };
}; };
@ -139,12 +163,12 @@ in (
++ (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 != "") ["--bundle" "${toString builderCfg.bundle}"]) ++ (optionals (builderCfg.bundle != null) ["--bundle" "${toString builderCfg.bundle}"])
++ (optionals (builderCfg.webBundle != "") ["--web-bundle" "${toString builderCfg.webBundle}"]) ++ (optionals (builderCfg.webBundle != null) ["--web-bundle" "${toString builderCfg.webBundle}"])
++ (optionals (builderCfg.outfmt != "") ["--outfmt" "${toString builderCfg.outfmt}"]) ++ (optionals (builderCfg.outfmt != null) ["--outfmt" "${toString builderCfg.outfmt}"])
++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths)) ++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
++ (optionals (builderCfg.format != "") ["--format" "${toString builderCfg.format}"]) ++ (optionals (builderCfg.format != null) ["--format" "${toString builderCfg.format}"])
++ (optionals (builderCfg.color != "") ["--color" "${toString builderCfg.color}"]) ++ (optionals (builderCfg.color != null) ["--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

View file

@ -3,11 +3,11 @@
lib, lib,
... ...
}: let }: let
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf;
inherit (lib.types) str nullOr;
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt; inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
inherit (lib.modules) mkIf;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
inherit (lib.options) mkOption;
inherit (lib.types) str nullOr;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
@ -48,20 +48,28 @@ in {
]; ];
options.vim.languages.tex.build = { options.vim.languages.tex.build = {
enable = enable = mkBool (enabledBuildersCount == 1) ''
mkBool (enabledBuildersCount == 1) ''
Whether to enable configuring the builder. 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 "Set this property to true if you want to execute a forward search after a build."; 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."; 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.
'';
useFileList = mkBool false '' 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. 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. Note that enabling this property might have an impact on performance.
''; '';
@ -70,10 +78,12 @@ in {
type = str; type = str;
default = "."; default = ".";
description = '' description = ''
When not using latexmk, provides a way to define the directory containing the .aux files. When not using latexmk, provides a way to define the directory
Note that you need to set the aux directory in latex.build.args too. 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. When using a latexmkrc file, texlab will automatically infer the correct
setting.
''; '';
}; };
@ -81,10 +91,13 @@ in {
type = str; type = str;
default = "."; default = ".";
description = '' description = ''
When not using latexmk, provides a way to define the directory containing the build log files. When not using latexmk, provides a way to define the directory
Note that you need to change the output directory in your build arguments too. 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. When using a latexmkrc file, texlab will automatically infer the correct
setting.
''; '';
}; };
@ -92,10 +105,13 @@ in {
type = str; type = str;
default = "."; default = ".";
description = '' description = ''
When not using latexmk, provides a way to define the directory containing the output files. When not using latexmk, provides a way to define the directory
Note that you need to set the output directory in latex.build.args too. 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. When using a latexmkrc file, texlab will automatically infer the correct
setting.
''; '';
}; };
@ -104,17 +120,20 @@ 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 search. This setting is used to find the correct PDF file to open during forward
search.
''; '';
}; };
}; };
config = mkIf (enabledBuildersCount > 0) { config = mkIf (enabledBuildersCount > 0) {
assertions = [ assertions = [
{ {
assertion = (enabledBuildersCount < 2); assertion = enabledBuildersCount < 2;
message = "The nvf-tex-language implementation does not support having more than 1 builders enabled."; message = ''
The nvf-tex-language implementation does not support having more than
1 builders enabled.
'';
} }
]; ];
}; };

View file

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

View file

@ -4,24 +4,34 @@
lib, lib,
... ...
}: let }: let
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) attrs either enum ints listOf nullOr package path str submodule;
inherit (lib.nvim.config) mkBool;
inherit (builtins) isString map; inherit (builtins) isString map;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.config) mkBool;
inherit (lib.options) mkOption mkPackageOption;
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 "Whether to enable Tex LSP support (texlab)"; enable = mkBool config.vim.languages.enableLSP ''
Whether to enable Tex LSP support (texlab).
'';
package = mkOption { package = mkPackageOption pkgs "texlab" {};
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";
@ -35,7 +45,9 @@ in {
''; '';
}; };
onOpenAndSave = mkBool false "Lint using chktex after opening and saving a file."; onOpenAndSave = mkBool false ''
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.";
@ -43,7 +55,8 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Additional command line arguments that are passed to chktex after editing a file. Additional command line arguments that are passed to chktex after
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.
''; '';
}; };
@ -58,11 +71,15 @@ in {
]; ];
default = "fuzzy-ignore-case"; default = "fuzzy-ignore-case";
description = '' description = ''
Modifies the algorithm used to filter the completion items returned to the client. Possibles values are: Modifies the algorithm used to filter the completion items returned to
- fuzzy: Fuzzy string matching (case sensitive) the client.
- fuzzy-ignore-case: Fuzzy string matching (case insensitive) Possibles values are:
- prefix: Filter out items that do not start with the search text (case sensitive) - `fuzzy`: Fuzzy string matching (case sensitive).
- prefix-ignore-case: Filter out items that do not start with the search text (case insensitive) - `fuzzy-ignore-case`: Fuzzy string matching (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).
''; '';
}; };
@ -77,13 +94,16 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported diagnostics. A list of regular expressions used to filter the list of reported
If specified, only diagnostics that match at least one of the specified patterns are sent to the client. diagnostics.
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 allowed patterns are applied first. Hint: If both allowedPatterns and ignoredPatterns are set, then
Afterwards, the results are filtered with the ignored patterns. allowed patterns are applied first. Afterwards, the results are
filtered with the ignored patterns.
''; '';
}; };
@ -91,35 +111,48 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported diagnostics. A list of regular expressions used to filter the list of reported
If specified, only diagnostics that match none of the specified patterns are sent to the client. diagnostics.
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 "If set to true, dependencies of custom packages are resolved and included in the dependency graph."; followPackageLinks = mkBool false ''
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 = "Allows extending the list of environments which the server considers as math environments (for example `align*` or `equation`)."; description = ''
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 = "Allows extending the list of environments which the server considers as enumeration environments (for example `enumerate` or `itemize`)."; description = ''
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 as verbatim environments (for example `minted` or `lstlisting`). Allows extending the list of environments which the server considers
This can be used to suppress diagnostics from environments that do not contain LaTeX code. as verbatim environments (for example `minted` or `lstlisting`).
This can be used to suppress diagnostics from environments that do
not contain LaTeX code.
''; '';
}; };
@ -127,9 +160,11 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Allows extending the list of commands which the server considers as citation commands (for example `\cite`). Allows extending the list of commands which the server considers as
citation commands (for example `\cite`).
Hint: Additional commands need to be written without a leading `\` (e. g. `foo` instead of `\foo`). Hint: Additional commands need to be written without a leading `\`
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -139,7 +174,8 @@ 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 `\` (e. g. `foo` instead of `\foo`). Hint: Additional commands need to be written without a leading `\`
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -149,7 +185,8 @@ 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 `\` (e. g. `foo` instead of `\foo`). Hint: Additional commands need to be written without a leading `\`
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -159,7 +196,8 @@ 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 `\` (e. g. `foo` instead of `\foo`). Hint: Additional commands need to be written without a leading `\`
(e.g. `foo` instead of `\foo`).
''; '';
}; };
@ -167,13 +205,16 @@ in {
type = listOf (listOf str); type = listOf (listOf str);
default = []; default = [];
description = '' description = ''
Allows associating a label definition command with a custom prefix. Consider, Allows associating a label definition command with a custom prefix.
Consider,
``` ```
\newcommand{\theorem}[1]{\label{theorem:#1}} \newcommand{\theorem}[1]{\label{theorem:#1}}
\theorem{foo} \theorem{foo}
``` ```
Then setting `texlab.experimental.labelDefinitionPrefixes` to `[["theorem", "theorem:"]]` and adding "theorem" Then setting `texlab.experimental.labelDefinitionPrefixes` to
to `texlab.experimental.labelDefinitionCommands` will make the server recognize the `theorem:foo` label. `[["theorem", "theorem:"]]` and adding `theorem` to
`texlab.experimental.labelDefinitionCommands` will make the server
recognize the `theorem:foo` label.
''; '';
}; };
@ -195,7 +236,8 @@ in {
baz = 314; baz = 314;
}; };
description = '' description = ''
For any options that do not have options provided through nvf this can be used to add them. For any options that do not have options provided through nvf this can
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:
@ -218,10 +260,12 @@ 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 your chosen PDF viewer. Enable this option if you want to have the compiled document appear in
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 along with custom configs. Note this is not all the options, but can act as a guide to help you
along with custom configs.
''; '';
package = mkOption { package = mkOption {
@ -239,7 +283,8 @@ 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 support SyncTeX. Defines the executable of the PDF previewer. The previewer needs to
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.
''; '';
@ -249,28 +294,37 @@ 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 previewer to perform the forward search. Defines additional arguments that are passed to the configured
The placeholders %f, %p, %l will be replaced by the server. previewer to perform the forward search.
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.positive; type = ints.unsigned;
default = 80; default = 80;
description = "Defines the maximum amount of characters per line (0 = disable) when formatting BibTeX files."; description = ''
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 ["texlab" "latexindent"]; type = enum [
"texlab"
"latexindent"
];
default = "texlab"; default = "texlab";
description = '' description = ''
Defines the formatter to use for BibTeX formatting. Defines the formatter to use for BibTeX formatting.
@ -279,7 +333,10 @@ in {
}; };
latexFormatter = mkOption { latexFormatter = mkOption {
type = enum ["texlab" "latexindent"]; type = enum [
"texlab"
"latexindent"
];
default = "latexindent"; default = "latexindent";
description = '' description = ''
Defines the formatter to use for LaTeX formatting. Defines the formatter to use for LaTeX formatting.
@ -290,14 +347,23 @@ in {
}; };
inlayHints = { inlayHints = {
labelDefinitions = mkBool true "When enabled, the server will return inlay hints for `\\label`-like commands."; labelDefinitions = mkBool true ''
When enabled, the server will return inlay hints for `\label`-like
commands.
'';
labelReferences = mkBool true "When enabled, the server will return inlay hints for `\\ref``-like commands."; labelReferences = mkBool true ''
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 = "When set, the server will truncate the text of the inlay hints to the specified length."; description = ''
When set, the server will truncate the text of the inlay hints to the
specified length.
'';
}; };
}; };
@ -307,25 +373,33 @@ 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 used. By default the configuration inside the project root directory is
used.
''; '';
}; };
modifyLineBreaks = mkBool false '' modifyLineBreaks = mkBool false ''
Modifies linebreaks before, during, and at the end of code blocks when formatting with latexindent. Modifies linebreaks before, during, and at the end of code blocks when
This corresponds to the --modifylinebreaks flag of latexindent. formatting with latexindent.
This corresponds to the `--modifylinebreaks` flag of latexindent.
''; '';
replacement = mkOption { replacement = mkOption {
type = nullOr (enum ["-r" "-rv" "-rr"]); type = nullOr (enum [
"-r"
"-rv"
"-rr"
]);
default = null; default = null;
description = '' description = ''
Defines an additional replacement flag that is added when calling latexindent. This can be one of the following: Defines an additional replacement flag that is added when calling
- "-r" latexindent.
- "-rv" This can be one of the following:
- "-rr" - `-r`
- null - `-rv`
- `-rr`
- `null`
By default no replacement flag is passed. By default no replacement flag is passed.
''; '';
}; };
@ -338,15 +412,18 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported document symbols. A list of regular expressions used to filter the list of reported
If specified, only symbols that match at least one of the specified patterns are sent to the client. document symbols.
Symbols are filtered recursively so nested symbols can still be sent to the client even though the If specified, only symbols that match at least one of the specified
parent node is removed from the results. patterns are sent to the client.
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 allowed patterns are applied first. Hint: If both `allowedPatterns` and `ignoredPatterns` are set, then
Afterwards, the results are filtered with the ignored patterns. allowed patterns are applied first. Afterwards, the results are
filtered with the ignored patterns.
''; '';
}; };
@ -354,8 +431,10 @@ in {
type = listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
A list of regular expressions used to filter the list of reported document symbols. A list of regular expressions used to filter the list of reported
If specified, only symbols that match none of the specified patterns are sent to the client. document symbols.
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`.
''; '';
@ -371,10 +450,14 @@ in {
displayName = mkOption { displayName = mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
description = "The name shown in the document symbols. Defaults to the value of `name`."; description = ''
The name shown in the document symbols.
Defaults to the value of `name`.
'';
}; };
label = mkBool false '' label = mkBool false ''
If set, the server will try to match a label to environment and append its number. If set to `true`, the server will try to match a label to
environment and append its number.
''; '';
}; };
}); });
@ -387,9 +470,10 @@ in {
} }
]; ];
description = '' description = ''
A list of objects that allows extending the list of environments that are part of the document symbols. A list of objects that allows extending the list of environments that
are part of the document symbols.
See also texlab.symbols.allowedPatterns. See also `texlab.symbols.allowedPatterns`.
Type: listOf submodule: Type: listOf submodule:
- name: - name:
@ -402,11 +486,12 @@ in {
- default: <name> - default: <name>
- label: - label:
- type: boolean - type: boolean
- description: If set, the server will try to match a label to environment and append its number. - description: If set, the server will try to match a label to
environment and append its number.
- default: false - default: false
Note: This functionality may not be working, please follow https://github.com/latex-lsp/texlab/pull/1311 Note: This functionality may not be working, please follow
for status updates. https://github.com/latex-lsp/texlab/pull/1311 for status updates.
''; '';
}; };
}; };

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; inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.types) package str listOf; inherit (lib.types) str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,10 +18,8 @@ in (
options = { options = {
enable = mkEnableOption "enable using a custom pdf viewer."; enable = mkEnableOption "enable using a custom pdf viewer.";
package = mkOption { package = mkPackageOption pkgs "okular" {
type = package; extraDescription = "custom viewer package";
example = pkgs.okular;
description = "custom viewer package";
}; };
executable = mkOption { executable = mkOption {
@ -32,7 +30,10 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
example = ["--unique" "file:%p#src:%l%f"]; example = [
"--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; inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.types) package str listOf; inherit (lib.types) str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,11 +18,7 @@ in (
options = { options = {
enable = mkEnableOption "enable okular as the pdf file previewer."; enable = mkEnableOption "enable okular as the pdf file previewer.";
package = mkOption { package = mkPackageOption pkgs "okular" {};
type = package;
default = pkgs.okular;
description = "okular package";
};
executable = mkOption { executable = mkOption {
type = str; type = str;
@ -32,7 +28,10 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
default = ["--unique" "file:%p#src:%l%f"]; default = [
"--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; inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.types) package str listOf; inherit (lib.types) str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,11 +18,7 @@ in (
options = { options = {
enable = mkEnableOption "enable qpdfview as the pdf file previewer."; enable = mkEnableOption "enable qpdfview as the pdf file previewer.";
package = mkOption { package = mkPackageOption pkgs "qpdfview" {};
type = package;
default = pkgs.qpdfview;
description = "qpdfview package";
};
executable = mkOption { executable = mkOption {
type = str; type = str;
@ -32,7 +28,10 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
default = ["--unique" "%p#src:%f:%l:1"]; default = [
"--unique"
"%p#src:%f:%l:1"
];
description = "Arguments to pass to the viewer."; description = "Arguments to pass to the viewer.";
}; };
}; };

View file

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

View file

@ -56,7 +56,8 @@ in {
opts) opts)
options; options;
# Check that the language and this pdf viewer have been enabled before making any config. # Check that the language and this pdf viewer have been enabled before making
# 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; inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.types) package str listOf; inherit (lib.types) str listOf;
in ( in (
template { template {
inherit name moduleInheritancePackage; inherit name moduleInheritancePackage;
@ -18,11 +18,7 @@ in (
options = { options = {
enable = mkEnableOption "enable zathura as the pdf file previewer."; enable = mkEnableOption "enable zathura as the pdf file previewer.";
package = mkOption { package = mkPackageOption pkgs "zathura" {};
type = package;
default = pkgs.zathura;
description = "zathura package";
};
executable = mkOption { executable = mkOption {
type = str; type = str;
@ -32,7 +28,11 @@ in (
args = mkOption { args = mkOption {
type = listOf str; type = listOf str;
default = ["--synctex-forward" "%l:1:%f" "%p"]; default = [
"--synctex-forward"
"%l:1:%f"
"%p"
];
description = "Arguments to pass to the viewer."; description = "Arguments to pass to the viewer.";
}; };
}; };

View file

@ -4,22 +4,17 @@
lib, lib,
... ...
}: let }: let
# inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption mkEnableTreesitterOption; inherit (lib.nvim.types) mkGrammarOption mkEnableTreesitterOption;
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 "Whether to enable Latex treesitter";
enable = mkEnableTreesitterOption config "latex"; enable = mkEnableTreesitterOption config "latex";
package = mkGrammarOption pkgs "latex"; package = mkGrammarOption pkgs "latex";
}; };
bibtex = { bibtex = {
# enable = mkEnableTreesitterOption "Whether to enable Bibtex treesitter";
enable = mkEnableTreesitterOption config "bibtex"; enable = mkEnableTreesitterOption config "bibtex";
package = mkGrammarOption pkgs "bibtex"; package = mkGrammarOption pkgs "bibtex";
}; };