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];
};
mkEnableTreesitterOption = defaultCondition: language:
mkEnableTreesitterOption = config: language:
mkOption {
type = bool;
default = defaultCondition;
default = config.vim.languages.enableTreesitter;
description = "Whether to enable ${language} treesitter";
};
in {

View file

@ -6,7 +6,8 @@
}: let
inherit (lib.options) mkOption;
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;
in {

View file

@ -29,10 +29,7 @@ in (
executable = mkOption {
type = str;
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
@ -44,8 +41,6 @@ in (
};
};
# Optional flags must come before the base args because of how the latexmk
# command works
args = builderCfg: (
# Flags
(optionals builderCfg.pdfOutput ["-pdf"])

View file

@ -12,16 +12,9 @@
inherit (lib) optionals;
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 (builtins) concatLists elem map toString attrNames filter isList;
notNull = x: x != null;
forceCheck = x: true;
toList = x:
if isList x
then x
else [x];
inherit (builtins) concatLists elem map toString;
cfg = config.vim.languages.tex;
in (
@ -36,32 +29,23 @@ in (
executable = mkOption {
type = str;
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 --
keepIntermediates = mkBool false ''
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 ''
Whether to keep the log files generated during processing.
Without the keepLogs flag, texlab won't be able to report compilation
warnings.
'';
onlyCached = mkBool false ''
Whether to use only resource files cached locally
Without the keepLogs flag, texlab won't be able to report compilation warnings.
'';
onlyCached = mkBool false "Whether to use only resource files cached locally";
synctex = mkBool true "Whether to generate SyncTeX data";
untrustedInput = mkBool false ''
Whether to diable all known-insecure features if the input is untrusted
'';
untrustedInput = mkBool false "Whether to input is untrusted -- disable all known-insecure features";
# -- Options --
reruns = mkOption {
@ -78,37 +62,28 @@ in (
};
bundle = mkOption {
type = nullOr str;
default = null;
description = ''
The directory or Zip-format bundle file to find resource files instead
of the default.
'';
type = str;
default = "";
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
};
webBundle = mkOption {
type = nullOr str;
default = null;
description = ''
Use this URL to find resource files instead of the default.
'';
type = str;
default = "";
description = "Use this URL to find resource files instead of the default";
};
outfmt = mkOption {
type = nullOr (enum [
type = enum [
"pdf"
"html"
"xdv"
"aux"
"fmt"
]);
default = null;
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.
'';
""
];
default = "";
description = "The kind of output to generate";
};
hidePaths = mkOption {
@ -118,27 +93,23 @@ in (
"./secrets.tex"
"./passwords.tex"
];
description = ''
Tell the engine that no file at `<path/to/hide>` exists, if it tries
to read it.
'';
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
};
format = mkOption {
type = nullOr str;
default = null;
description = ''
The name of the \"format\" file used to initialize the TeX engine.
'';
type = str;
default = "";
description = "The name of the \"format\" file used to initialize the TeX engine";
};
color = mkOption {
type = nullOr (enum [
type = enum [
"always"
"auto"
"never"
]);
default = null;
""
];
default = "";
example = "always";
description = "Enable/disable colorful log output";
};
@ -147,83 +118,37 @@ in (
type = listOf str;
default = [];
description = ''
Add extra command line options to include in the tectonic build
command.
Extra options added here will not overwrite the options set in as nvf
options.
Add extra command line options to include in the tectonic build command.
Extra options added here will not overwrite the options set in as nvf options.
'';
};
};
# args = builderCfg: (
# # Base args
# [
# "-X"
# "compile"
# "%f"
# ]
# # Flags
# ++ (optionals builderCfg.keepIntermediates ["--keep-intermediates"])
# ++ (optionals builderCfg.keepLogs ["--keep-logs"])
# ++ (optionals builderCfg.onlyCached ["--only-cached"])
# ++ (optionals builderCfg.synctex ["--synctex"])
# ++ (optionals builderCfg.untrustedInput ["--untrusted"])
# # Options
# ++ (optionals (builderCfg.reruns > 0) ["--reruns" "${toString builderCfg.reruns}"])
# ++ (optionals (builderCfg.bundle != null) ["--bundle" "${toString builderCfg.bundle}"])
# ++ (optionals (builderCfg.webBundle != null) ["--web-bundle" "${toString builderCfg.webBundle}"])
# ++ (optionals (builderCfg.outfmt != null) ["--outfmt" "${toString builderCfg.outfmt}"])
# ++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
# ++ (optionals (builderCfg.format != null) ["--format" "${toString builderCfg.format}"])
# ++ (optionals (builderCfg.color != null) ["--color" "${toString builderCfg.color}"])
# # Still options but these are not defined by builder specific options but
# # instead synchronize options between the global build options and builder
# # specific options
# ++ (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]);
args = builderCfg: (
# Base args
[
"-X"
"compile"
"%f"
]
# Flags
++ (optionals builderCfg.keepIntermediates ["--keep-intermediates"])
++ (optionals builderCfg.keepLogs ["--keep-logs"])
++ (optionals builderCfg.onlyCached ["--only-cached"])
++ (optionals builderCfg.synctex ["--synctex"])
++ (optionals builderCfg.untrustedInput ["--untrusted"])
# Options
++ (optionals (builderCfg.reruns > 0) ["--reruns" "${toString builderCfg.reruns}"])
++ (optionals (builderCfg.bundle != "") ["--bundle" "${toString builderCfg.bundle}"])
++ (optionals (builderCfg.webBundle != "") ["--web-bundle" "${toString builderCfg.webBundle}"])
++ (optionals (builderCfg.outfmt != "") ["--outfmt" "${toString builderCfg.outfmt}"])
++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
++ (optionals (builderCfg.format != "") ["--format" "${toString builderCfg.format}"])
++ (optionals (builderCfg.color != "") ["--color" "${toString builderCfg.color}"])
# Still options but these are not defined by builder specific options but
# instead synchronize options between the global build options and builder
# specific options
++ (optionals (!(elem cfg.build.pdfDirectory ["." ""])) ["--outdir" "${cfg.build.pdfDirectory}"])
);
}
)

View file

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

View file

@ -4,17 +4,16 @@
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.config) mkBool;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum;
inherit (lib.types) bool str;
cfg = config.vim.languages.tex;
in {
imports = [
./build
./lsp
./pdfViewer
./treesitter.nix
./lsp
./build
./pdfViewer
];
options.vim.languages.tex = {
@ -22,46 +21,38 @@ in {
extraOpts = {
texFlavor = {
enable = mkBool false ''
Whether to set the `vim.g.tex_flavor` (`g:tex_flavor`) option in
your Lua config.
enable = mkOption {
type = bool;
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
determine the file type from the three options: `plaintex` (for
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, 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.
When opening a .tex file vim will try to automatically try to determine the file type from
the three options: plaintex (for 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
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 using the
`vim.languages.tex.lsp.extraOpts.texFlavor.flavor = <flavor>` in
your nvf config.
This option will enable setting the tex flavor in your lua 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 config entirely
(unless you manually set it elsewhere of course).
'';
Setting this option to `false` will omit the `vim.g.tex_flavor = <flavor>` line from your lua
config entirely (unless you manually set it elsewhere of course).
'';
};
flavor = mkOption {
type = enum [
"plaintex"
"contex"
"tex"
];
type = str;
default = "plaintex";
example = "tex";
description = ''
The flavor to set as a fallback for when vim cannot automatically
determine the tex flavor when opening a `.tex` document.
The flavor to set as a fallback for when vim cannot automatically 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 creating templates when
no context has yet been added to a new file.
This can be particularly useful for when using `vim.utility.new-file-template` options for
creating templates when no context has yet been added to a new file.
'';
};
};

View file

@ -4,35 +4,24 @@
lib,
...
}: let
inherit (builtins) isString map;
inherit (lib) optionalAttrs;
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 (lib.options) mkOption mkPackageOption;
inherit
(lib.types)
attrs
either
enum
ints
listOf
nullOr
package
path
str
submodule
;
inherit (builtins) isString map;
cfg = config.vim.languages.tex;
texlabCfg = cfg.lsp.texlab;
builderCfg = cfg.build.builder;
in {
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 = mkPackageOption pkgs "texlab" {};
package = mkOption {
type = package;
default = pkgs.texlab;
description = "texlab package";
};
chktex = {
enable = mkBool false "Whether to enable linting via chktex";
@ -46,9 +35,7 @@ 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.";
@ -56,8 +43,7 @@ in {
type = listOf str;
default = [];
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.
'';
};
@ -72,15 +58,11 @@ in {
];
default = "fuzzy-ignore-case";
description = ''
Modifies the algorithm used to filter the completion items returned to
the client.
Possibles values are:
- `fuzzy`: Fuzzy string matching (case sensitive).
- `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).
Modifies the algorithm used to filter the completion items returned to the client. Possibles values are:
- fuzzy: Fuzzy string matching (case sensitive)
- 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)
'';
};
@ -95,16 +77,13 @@ in {
type = listOf str;
default = [];
description = ''
A list of regular expressions used to filter the list of reported
diagnostics.
If specified, only diagnostics that match at least one of the
specified patterns are sent to the client.
A list of regular expressions used to filter the list of reported 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. Afterwards, the results are
filtered with the ignored patterns.
Hint: If both allowedPatterns and ignoredPatterns are set, then allowed patterns are applied first.
Afterwards, the results are filtered with the ignored patterns.
'';
};
@ -112,48 +91,35 @@ in {
type = listOf str;
default = [];
description = ''
A list of regular expressions used to filter the list of reported
diagnostics.
If specified, only diagnostics that match none of the specified
patterns are sent to the client.
A list of regular expressions used to filter the list of reported 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 = {
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 {
type = listOf str;
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 {
type = listOf str;
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 {
type = listOf str;
default = [];
description = ''
Allows extending the list of environments which the server considers
as verbatim environments (for example `minted` or `lstlisting`).
This can be used to suppress diagnostics from environments that do
not contain LaTeX code.
Allows extending the list of environments which the server considers as verbatim environments (for example `minted` or `lstlisting`).
This can be used to suppress diagnostics from environments that do not contain LaTeX code.
'';
};
@ -161,11 +127,9 @@ in {
type = listOf str;
default = [];
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`).
'';
};
@ -175,8 +139,7 @@ in {
description = ''
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`).
'';
};
@ -186,8 +149,7 @@ in {
description = ''
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`).
'';
};
@ -197,8 +159,7 @@ in {
description = ''
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`).
'';
};
@ -206,16 +167,13 @@ in {
type = listOf (listOf str);
default = [];
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}}
\theorem{foo}
```
Then setting `texlab.experimental.labelDefinitionPrefixes` to
`[["theorem", "theorem:"]]` and adding `theorem` to
`texlab.experimental.labelDefinitionCommands` will make the server
recognize the `theorem:foo` label.
Then setting `texlab.experimental.labelDefinitionPrefixes` to `[["theorem", "theorem:"]]` and adding "theorem"
to `texlab.experimental.labelDefinitionCommands` will make the server recognize the `theorem:foo` label.
'';
};
@ -237,8 +195,7 @@ in {
baz = 314;
};
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 will be placed in:
@ -261,12 +218,10 @@ in {
enable = mkBool false ''
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).
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 {
@ -284,8 +239,7 @@ in {
type = str;
default = cfg.pdfViewer.executable;
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.
'';
@ -295,37 +249,28 @@ in {
type = listOf str;
default = cfg.pdfViewer.args;
description = ''
Defines additional arguments that are passed to the configured
previewer to perform the forward search.
The placeholders `%f`, `%p`, `%l` will be replaced by the server.
Defines additional arguments that are passed to the configured 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.
Placeholders:
- `%f`: The path of the current TeX file.
- `%p`: The path of the current PDF file.
- `%l`: The current line number.
- %f: The path of the current TeX file.
- %p: The path of the current PDF file.
- %l: The current line number.
'';
};
};
formatter = {
formatterLineLength = mkOption {
type = ints.unsigned;
type = ints.positive;
default = 80;
description = ''
Defines the maximum amount of characters per line when formatting
BibTeX files.
Setting this value to 0 will disable this option.
'';
description = "Defines the maximum amount of characters per line (0 = disable) when formatting BibTeX files.";
};
bibtexFormatter = mkOption {
type = enum [
"texlab"
"latexindent"
];
type = enum ["texlab" "latexindent"];
default = "texlab";
description = ''
Defines the formatter to use for BibTeX formatting.
@ -334,10 +279,7 @@ in {
};
latexFormatter = mkOption {
type = enum [
"texlab"
"latexindent"
];
type = enum ["texlab" "latexindent"];
default = "latexindent";
description = ''
Defines the formatter to use for LaTeX formatting.
@ -348,23 +290,14 @@ in {
};
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 {
type = nullOr ints.positive;
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.";
};
};
@ -374,33 +307,25 @@ in {
default = null;
description = ''
Defines the path of a file containing the latexindent configuration.
This corresponds to the `--local=file.yaml` flag of latexindent.
By default the configuration inside the project root directory is
used.
This corresponds to the --local=file.yaml flag of latexindent.
By default the configuration inside the project root directory is used.
'';
};
modifyLineBreaks = mkBool false ''
Modifies linebreaks before, during, and at the end of code blocks when
formatting with latexindent.
This corresponds to the `--modifylinebreaks` flag of latexindent.
Modifies linebreaks before, during, and at the end of code blocks when formatting with latexindent.
This corresponds to the --modifylinebreaks flag of latexindent.
'';
replacement = mkOption {
type = nullOr (enum [
"-r"
"-rv"
"-rr"
]);
type = nullOr (enum ["-r" "-rv" "-rr"]);
default = null;
description = ''
Defines an additional replacement flag that is added when calling
latexindent.
This can be one of the following:
- `-r`
- `-rv`
- `-rr`
- `null`
Defines an additional replacement flag that is added when calling latexindent. This can be one of the following:
- "-r"
- "-rv"
- "-rr"
- null
By default no replacement flag is passed.
'';
};
@ -413,18 +338,15 @@ in {
type = listOf str;
default = [];
description = ''
A list of regular expressions used to filter the list of reported
document symbols.
If specified, only symbols that match at least one of the specified
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.
A list of regular expressions used to filter the list of reported document symbols.
If specified, only symbols that match at least one of the specified 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`.
Hint: If both `allowedPatterns` and `ignoredPatterns` are set, then
allowed patterns are applied first. Afterwards, the results are
filtered with the ignored patterns.
Hint: If both allowedPatterns and ignoredPatterns are set, then allowed patterns are applied first.
Afterwards, the results are filtered with the ignored patterns.
'';
};
@ -432,10 +354,8 @@ in {
type = listOf str;
default = [];
description = ''
A list of regular expressions used to filter the list of reported
document symbols.
If specified, only symbols that match none of the specified patterns
are sent to the client.
A list of regular expressions used to filter the list of reported document symbols.
If specified, only symbols that match none of the specified patterns are sent to the client.
See also `texlab.symbols.allowedPatterns`.
'';
@ -451,14 +371,10 @@ in {
displayName = mkOption {
type = nullOr str;
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 ''
If set to `true`, the server will try to match a label to
environment and append its number.
If set, the server will try to match a label to environment and append its number.
'';
};
});
@ -471,10 +387,9 @@ in {
}
];
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:
- name:
@ -487,12 +402,11 @@ in {
- default: <name>
- label:
- 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
Note: This functionality may not be working, please follow
https://github.com/latex-lsp/texlab/pull/1311 for status updates.
Note: This functionality may not be working, please follow https://github.com/latex-lsp/texlab/pull/1311
for status updates.
'';
};
};
@ -530,54 +444,70 @@ in {
}
#
# -- Build --
// (optionalAttrs cfg.build.enable {
build = {
inherit
(cfg.build)
onSave
useFileList
auxDirectory
logDirectory
pdfDirectory
filename
forwardSearchAfter
;
inherit (builderCfg) args;
executable = "${builderCfg.package}/bin/${builderCfg.executable}";
};
})
// (
if cfg.build.enable
then {
build = {
inherit
(cfg.build)
onSave
useFileList
auxDirectory
logDirectory
pdfDirectory
filename
forwardSearchAfter
;
inherit (builderCfg) args;
executable = "${builderCfg.package}/bin/${builderCfg.executable}";
};
}
else {}
)
#
# -- Chktex --
// (optionalAttrs texlabCfg.chktex.enable {
chktex = {
inherit (texlabCfg.chktex) onOpenAndSave onEdit additionalArgs;
};
})
// (
if texlabCfg.chktex.enable
then {
chktex = {
inherit (texlabCfg.chktex) onOpenAndSave onEdit additionalArgs;
};
}
else {}
)
#
# -- Forward Search --
// (optionalAttrs texlabCfg.forwardSearch.enable {
forwardSearch = {
inherit (texlabCfg.forwardSearch) args;
executable = "${texlabCfg.forwardSearch.package}/bin/${texlabCfg.forwardSearch.executable}";
};
})
// (
if texlabCfg.forwardSearch.enable
then {
forwardSearch = {
inherit (texlabCfg.forwardSearch) args;
executable = "${texlabCfg.forwardSearch.package}/bin/${texlabCfg.forwardSearch.executable}";
};
}
else {}
)
#
# -- Symbols --
// (optionalAttrs texlabCfg.symbols.enable {
symbols = {
inherit (texlabCfg.symbols) allowedPatterns ignoredPatterns;
// (
if texlabCfg.symbols.enable
then {
symbols = {
inherit (texlabCfg.symbols) allowedPatterns ignoredPatterns;
customEnvironments =
map (x: {
inherit (x) name label;
displayName =
if isString x.displayName
then x.displayName
else x.name;
})
texlabCfg.symbols.customEnvironments;
};
})
customEnvironments =
map (x: {
inherit (x) name label;
displayName =
if isString x.displayName
then x.displayName
else x.name;
})
texlabCfg.symbols.customEnvironments;
};
}
else {}
)
#
# -- Extra Settings --
// texlabCfg.extraLuaSettings

View file

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

View file

@ -5,10 +5,9 @@
}: let
defaultPdfViewerName = "okular";
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption;
inherit (lib.types) str package listOf;
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
cfg = config.vim.languages.tex;
viewerCfg = cfg.pdfViewer;
@ -45,11 +44,14 @@
# Get the index that will be used for the next iteration
nextIndex = index + 1;
# Increment the count that is recording the number of enabled pdf viewers
# if this viewer is enabled, otherwise leave it as is.
# Increment the count that is recording the number of enabled pdf viewers if
# this viewer is enabled, otherwise leave it as is.
newEnabledPdfViewersCount =
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;
# If this pdf viewer is enabled, set is as the enabled viewer.
@ -82,8 +84,8 @@ in {
imports = [
./custom.nix
./okular.nix
./qpdfview.nix
./sioyek.nix
./qpdfview.nix
./zathura.nix
];
@ -94,12 +96,10 @@ in {
description = ''
The name of the pdf viewer to use.
This value will be automatically set when any of the viewers are
enabled.
This value will be automatically set when any of the viewers are enabled.
Setting this option option manually is not recommended but can be used
for some very technical nix-ing. If you wish to use a custom viewer,
please use the `custom` entry provided under `viewers`.
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
'';
};
@ -109,12 +109,10 @@ in {
description = ''
The package of the pdf viewer to use.
This value will be automatically set when any of the viewers are
enabled.
This value will be automatically set when any of the viewers are enabled.
Setting this option option manually is not recommended but can be used
for some very technical nix-ing. If you wish to use a custom viewer,
please use the `custom` entry provided under `viewers`.
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
'';
};
@ -124,12 +122,10 @@ in {
description = ''
The executable for the pdf viewer to use.
This value will be automatically set when any of the viewers are
enabled.
This value will be automatically set when any of the viewers are enabled.
Setting this option option manually is not recommended but can be used
for some very technical nix-ing. If you wish to use a custom viewer,
please use the `custom` entry provided under `viewers`.
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
'';
};
@ -139,25 +135,11 @@ in {
description = ''
The command line arguments to use when calling the pdf viewer command.
This value will be automatically set when any of the viewers are
enabled.
This value will be automatically set when any of the viewers are enabled.
Setting this option option manually is not recommended but can be used
for some very technical nix-ing. If you wish to use a custom viewer,
please use the `custom` entry provided under `viewers`.
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
If you wish to use a custom viewer, 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
template = import ./viewerTemplate.nix;
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.types) str listOf;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) package str listOf;
in (
template {
inherit name moduleInheritancePackage;
@ -18,7 +18,11 @@ in (
options = {
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 {
type = str;
@ -28,10 +32,7 @@ in (
args = mkOption {
type = listOf str;
default = [
"--unique"
"file:%p#src:%l%f"
];
default = ["--unique" "file:%p#src:%l%f"];
description = "Arguments to pass to the viewer.";
};
};

View file

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

View file

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

View file

@ -56,8 +56,7 @@ in {
opts)
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) {
vim.languages.tex.pdfViewer = {
inherit name;

View file

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

View file

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