mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 07:25:30 +00:00
Migrated texlab into its own module
This commit is contained in:
parent
c3291ab71c
commit
9b401be571
2 changed files with 989 additions and 474 deletions
|
|
@ -39,375 +39,378 @@
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
|
|
||||||
# --- Enable Options ---
|
# --- Enable Options ---
|
||||||
mkEnableDefaultOption = default: description: (mkOption {
|
# mkEnableDefaultOption = default: description: (mkOption {
|
||||||
type = bool;
|
# type = bool;
|
||||||
default = default;
|
# default = default;
|
||||||
example = !default;
|
# example = !default;
|
||||||
description = description;
|
# description = description;
|
||||||
});
|
# });
|
||||||
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
|
# mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
|
||||||
|
|
||||||
# --- Arg Collation Functions --
|
# # --- Arg Collation Functions --
|
||||||
collateArgs.lsp.texlab.build = {
|
# collateArgs.lsp.texlab.build = {
|
||||||
tectonic = buildConfig: let
|
# tectonic = buildConfig: let
|
||||||
selfConfig = buildConfig.tectonic;
|
# selfConfig = buildConfig.tectonic;
|
||||||
in (
|
# in (
|
||||||
# Base args
|
# # Base args
|
||||||
[
|
# [
|
||||||
"-X"
|
# "-X"
|
||||||
"compile"
|
# "compile"
|
||||||
"%f"
|
# "%f"
|
||||||
]
|
# ]
|
||||||
# Flags
|
# # Flags
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.keepIntermediates
|
# if selfConfig.keepIntermediates
|
||||||
then ["--keep-intermediates"]
|
# then ["--keep-intermediates"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.keepLogs
|
# if selfConfig.keepLogs
|
||||||
then ["--keep-logs"]
|
# then ["--keep-logs"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.onlyCached
|
# if selfConfig.onlyCached
|
||||||
then ["--only-cached"]
|
# then ["--only-cached"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.synctex
|
# if selfConfig.synctex
|
||||||
then ["--synctex"]
|
# then ["--synctex"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.untrustedInput
|
# if selfConfig.untrustedInput
|
||||||
then ["--untrusted"]
|
# then ["--untrusted"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
# Options
|
# # Options
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.reruns > 0
|
# if selfConfig.reruns > 0
|
||||||
then ["--reruns" "${toString selfConfig.reruns}"]
|
# then ["--reruns" "${toString selfConfig.reruns}"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.bundle != ""
|
# if selfConfig.bundle != ""
|
||||||
then ["--bundle" "${toString selfConfig.bundle}"]
|
# then ["--bundle" "${toString selfConfig.bundle}"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.webBundle != ""
|
# if selfConfig.webBundle != ""
|
||||||
then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
# then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.outfmt != ""
|
# if selfConfig.outfmt != ""
|
||||||
then ["--outfmt" "${toString selfConfig.outfmt}"]
|
# then ["--outfmt" "${toString selfConfig.outfmt}"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
# ++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.format != ""
|
# if selfConfig.format != ""
|
||||||
then ["--format" "${toString selfConfig.format}"]
|
# then ["--format" "${toString selfConfig.format}"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
++ (
|
# ++ (
|
||||||
if selfConfig.color != ""
|
# if selfConfig.color != ""
|
||||||
then ["--color" "${toString selfConfig.color}"]
|
# then ["--color" "${toString selfConfig.color}"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
# 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
|
||||||
++ (
|
# ++ (
|
||||||
if !(elem buildConfig.pdfDirectory ["." ""])
|
# if !(elem buildConfig.pdfDirectory ["." ""])
|
||||||
then ["--outdir" "${buildConfig.pdfDirectory}"]
|
# then ["--outdir" "${buildConfig.pdfDirectory}"]
|
||||||
else []
|
# else []
|
||||||
)
|
# )
|
||||||
);
|
# );
|
||||||
custom = buildConfig: buildConfig.custom.args;
|
# custom = buildConfig: buildConfig.custom.args;
|
||||||
};
|
# };
|
||||||
in {
|
in {
|
||||||
options.vim.languages.tex.lsp = {
|
imports = [
|
||||||
texlab = {
|
./texlab.nix
|
||||||
enable = mkEnableLspOption "Whether to enable Tex LSP support (texlab)";
|
];
|
||||||
|
# options.vim.languages.tex.lsp = {
|
||||||
package = mkOption {
|
# texlab = {
|
||||||
type = package;
|
# enable = mkEnableLspOption "Whether to enable Tex LSP support (texlab)";
|
||||||
default = pkgs.texlab;
|
#
|
||||||
description = "texlab package";
|
# package = mkOption {
|
||||||
};
|
# type = package;
|
||||||
|
# default = pkgs.texlab;
|
||||||
build = {
|
# description = "texlab package";
|
||||||
tectonic = {
|
# };
|
||||||
enable = mkEnableDefaultOption true "Whether to enable Tex Compilation Via Tectonic";
|
#
|
||||||
|
# build = {
|
||||||
package = mkOption {
|
# tectonic = {
|
||||||
type = package;
|
# enable = mkEnableDefaultOption true "Whether to enable Tex Compilation Via Tectonic";
|
||||||
default = pkgs.tectonic;
|
#
|
||||||
description = "tectonic package";
|
# package = mkOption {
|
||||||
};
|
# type = package;
|
||||||
|
# default = pkgs.tectonic;
|
||||||
executable = mkOption {
|
# description = "tectonic package";
|
||||||
type = str;
|
# };
|
||||||
default = "tectonic";
|
#
|
||||||
description = "The executable name from the build package that will be used to build/compile the tex.";
|
# executable = mkOption {
|
||||||
};
|
# type = str;
|
||||||
|
# default = "tectonic";
|
||||||
# -- Flags --
|
# description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||||
keepIntermediates = mkEnableDefaultOption false ''
|
# };
|
||||||
Keep the intermediate files generated during processing.
|
#
|
||||||
|
# # -- Flags --
|
||||||
If texlab is reporting build errors when there shouldn't be, disable this option.
|
# keepIntermediates = mkEnableDefaultOption false ''
|
||||||
'';
|
# Keep the intermediate files generated during processing.
|
||||||
keepLogs = mkEnableDefaultOption true ''
|
#
|
||||||
Keep the log files generated during processing.
|
# If texlab is reporting build errors when there shouldn't be, disable this option.
|
||||||
|
# '';
|
||||||
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
# keepLogs = mkEnableDefaultOption true ''
|
||||||
'';
|
# Keep the log files generated during processing.
|
||||||
onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
#
|
||||||
synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
# Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
||||||
untrustedInput = mkEnableDefaultOption false "Input is untrusted -- disable all known-insecure features";
|
# '';
|
||||||
|
# onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
||||||
# -- Options --
|
# synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
||||||
reruns = mkOption {
|
# untrustedInput = mkEnableDefaultOption false "Input is untrusted -- disable all known-insecure features";
|
||||||
type = ints.unsigned;
|
#
|
||||||
default = 0;
|
# # -- Options --
|
||||||
example = 2;
|
# reruns = mkOption {
|
||||||
description = "Rerun the TeX engine exactly this many times after the first";
|
# type = ints.unsigned;
|
||||||
};
|
# default = 0;
|
||||||
|
# example = 2;
|
||||||
bundle = mkOption {
|
# description = "Rerun the TeX engine exactly this many times after the first";
|
||||||
type = str;
|
# };
|
||||||
default = "";
|
#
|
||||||
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
# bundle = mkOption {
|
||||||
};
|
# type = str;
|
||||||
|
# default = "";
|
||||||
webBundle = mkOption {
|
# description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
||||||
type = str;
|
# };
|
||||||
default = "";
|
#
|
||||||
description = "Use this URL to find resource files instead of the default";
|
# webBundle = mkOption {
|
||||||
};
|
# type = str;
|
||||||
|
# default = "";
|
||||||
outfmt = mkOption {
|
# description = "Use this URL to find resource files instead of the default";
|
||||||
type = enum [
|
# };
|
||||||
"pdf"
|
#
|
||||||
"html"
|
# outfmt = mkOption {
|
||||||
"xdv"
|
# type = enum [
|
||||||
"aux"
|
# "pdf"
|
||||||
"fmt"
|
# "html"
|
||||||
""
|
# "xdv"
|
||||||
];
|
# "aux"
|
||||||
default = "";
|
# "fmt"
|
||||||
description = "The kind of output to generate";
|
# ""
|
||||||
};
|
# ];
|
||||||
|
# default = "";
|
||||||
hidePaths = mkOption {
|
# description = "The kind of output to generate";
|
||||||
type = listOf str;
|
# };
|
||||||
default = [];
|
#
|
||||||
example = [
|
# hidePaths = mkOption {
|
||||||
"./secrets.tex"
|
# type = listOf str;
|
||||||
"./passwords.tex"
|
# default = [];
|
||||||
];
|
# example = [
|
||||||
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
# "./secrets.tex"
|
||||||
};
|
# "./passwords.tex"
|
||||||
|
# ];
|
||||||
format = mkOption {
|
# description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
||||||
type = str;
|
# };
|
||||||
default = "";
|
#
|
||||||
description = "The name of the \"format\" file used to initialize the TeX engine";
|
# format = mkOption {
|
||||||
};
|
# type = str;
|
||||||
|
# default = "";
|
||||||
color = mkOption {
|
# description = "The name of the \"format\" file used to initialize the TeX engine";
|
||||||
type = enum [
|
# };
|
||||||
"always"
|
#
|
||||||
"auto"
|
# color = mkOption {
|
||||||
"never"
|
# type = enum [
|
||||||
""
|
# "always"
|
||||||
];
|
# "auto"
|
||||||
default = "";
|
# "never"
|
||||||
example = "always";
|
# ""
|
||||||
description = "Enable/disable colorful log output";
|
# ];
|
||||||
};
|
# default = "";
|
||||||
|
# example = "always";
|
||||||
extraOptions = {
|
# description = "Enable/disable colorful log output";
|
||||||
type = listOf str;
|
# };
|
||||||
default = [];
|
#
|
||||||
description = ''
|
# extraOptions = {
|
||||||
Add extra command line options to include in the tectonic build command.
|
# type = listOf str;
|
||||||
Extra options added here will not overwrite the options set in as nvf options.
|
# default = [];
|
||||||
'';
|
# description = ''
|
||||||
};
|
# Add extra command line options to include in the tectonic build command.
|
||||||
};
|
# Extra options added here will not overwrite the options set in as nvf options.
|
||||||
|
# '';
|
||||||
custom = {
|
# };
|
||||||
enable = mkEnableDefaultOption false "Whether to enable using a custom build package";
|
# };
|
||||||
package = mkOption {
|
#
|
||||||
type = package;
|
# custom = {
|
||||||
default = pkgs.tectonic;
|
# enable = mkEnableDefaultOption false "Whether to enable using a custom build package";
|
||||||
description = "build/compiler package";
|
# package = mkOption {
|
||||||
};
|
# type = package;
|
||||||
executable = mkOption {
|
# default = pkgs.tectonic;
|
||||||
type = str;
|
# description = "build/compiler package";
|
||||||
default = "tectonic";
|
# };
|
||||||
description = "The executable name from the build package that will be used to build/compile the tex.";
|
# executable = mkOption {
|
||||||
};
|
# type = str;
|
||||||
args = mkOption {
|
# default = "tectonic";
|
||||||
type = listOf str;
|
# description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||||
default = [
|
# };
|
||||||
"-X"
|
# args = mkOption {
|
||||||
"compile"
|
# type = listOf str;
|
||||||
"%f"
|
# default = [
|
||||||
"--synctex"
|
# "-X"
|
||||||
"--keep-logs"
|
# "compile"
|
||||||
"--keep-intermediates"
|
# "%f"
|
||||||
];
|
# "--synctex"
|
||||||
description = ''
|
# "--keep-logs"
|
||||||
Defines additional arguments that are passed to the configured LaTeX build tool.
|
# "--keep-intermediates"
|
||||||
Note that flags and their arguments need to be separate elements in this array.
|
# ];
|
||||||
To pass the arguments -foo bar to a build tool, args needs to be ["-foo" "bar"].
|
# description = ''
|
||||||
The placeholder `%f` will be replaced by the server.
|
# Defines additional arguments that are passed to the configured LaTeX build tool.
|
||||||
|
# Note that flags and their arguments need to be separate elements in this array.
|
||||||
Placeholders:
|
# To pass the arguments -foo bar to a build tool, args needs to be ["-foo" "bar"].
|
||||||
- `%f`: The path of the TeX file to compile.
|
# The placeholder `%f` will be replaced by the server.
|
||||||
'';
|
#
|
||||||
};
|
# Placeholders:
|
||||||
};
|
# - `%f`: The path of the TeX file to compile.
|
||||||
|
# '';
|
||||||
forwardSearchAfter = mkOption {
|
# };
|
||||||
type = bool;
|
# };
|
||||||
default = false;
|
#
|
||||||
description = "Set this property to true if you want to execute a forward search after a build.";
|
# forwardSearchAfter = mkOption {
|
||||||
};
|
# type = bool;
|
||||||
onSave = mkOption {
|
# default = false;
|
||||||
type = bool;
|
# description = "Set this property to true if you want to execute a forward search after a build.";
|
||||||
default = false;
|
# };
|
||||||
description = "Set this property to true if you want to compile the project after saving a file.";
|
# onSave = mkOption {
|
||||||
};
|
# type = bool;
|
||||||
useFileList = mkOption {
|
# default = false;
|
||||||
type = bool;
|
# description = "Set this property to true if you want to compile the project after saving a file.";
|
||||||
default = false;
|
# };
|
||||||
description = ''
|
# useFileList = mkOption {
|
||||||
When set to true, the server will use the .fls files produced by the TeX engine as an additional input for the project detection.
|
# type = bool;
|
||||||
|
# default = false;
|
||||||
Note that enabling this property might have an impact on performance.
|
# description = ''
|
||||||
'';
|
# When set to true, the server will use the .fls files produced by the TeX engine as an additional input for the project detection.
|
||||||
};
|
#
|
||||||
auxDirectory = mkOption {
|
# Note that enabling this property might have an impact on performance.
|
||||||
type = str;
|
# '';
|
||||||
default = ".";
|
# };
|
||||||
description = ''
|
# auxDirectory = mkOption {
|
||||||
When not using latexmk, provides a way to define the directory containing the .aux files.
|
# type = str;
|
||||||
Note that you need to set the aux directory in latex.build.args too.
|
# default = ".";
|
||||||
|
# description = ''
|
||||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
# 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.
|
||||||
};
|
#
|
||||||
logDirectory = mkOption {
|
# When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||||
type = str;
|
# '';
|
||||||
default = ".";
|
# };
|
||||||
description = ''
|
# logDirectory = mkOption {
|
||||||
When not using latexmk, provides a way to define the directory containing the build log files.
|
# type = str;
|
||||||
Note that you need to change the output directory in your build arguments too.
|
# default = ".";
|
||||||
|
# description = ''
|
||||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
# 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.
|
||||||
};
|
#
|
||||||
pdfDirectory = mkOption {
|
# When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||||
type = str;
|
# '';
|
||||||
default = ".";
|
# };
|
||||||
description = ''
|
# pdfDirectory = mkOption {
|
||||||
When not using latexmk, provides a way to define the directory containing the output files.
|
# type = str;
|
||||||
Note that you need to set the output directory in latex.build.args too.
|
# default = ".";
|
||||||
|
# description = ''
|
||||||
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
# 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.
|
||||||
};
|
#
|
||||||
filename = mkOption {
|
# When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||||
type = str;
|
# '';
|
||||||
default = "";
|
# };
|
||||||
description = ''
|
# filename = mkOption {
|
||||||
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.
|
# type = str;
|
||||||
'';
|
# default = "";
|
||||||
};
|
# description = ''
|
||||||
};
|
# Allows overriding the default file name of the build artifact. This setting is used to find the correct PDF file to open during forward search.
|
||||||
|
# '';
|
||||||
forwardSearch = {
|
# };
|
||||||
enable = mkOption {
|
# };
|
||||||
type = bool;
|
#
|
||||||
default = false;
|
# forwardSearch = {
|
||||||
example = true;
|
# enable = mkOption {
|
||||||
description = ''
|
# type = bool;
|
||||||
Whether to enable forward search.
|
# default = false;
|
||||||
|
# example = true;
|
||||||
Enable this option if you want to have the compiled document appear in your chosen PDF viewer.
|
# description = ''
|
||||||
|
# Whether to enable forward search.
|
||||||
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 allong with custom configs.
|
# 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).
|
||||||
package = mkOption {
|
# Note this is not all the options, but can act as a guide to help you allong with custom configs.
|
||||||
type = package;
|
# '';
|
||||||
default = pkgs.okular;
|
# };
|
||||||
description = ''
|
# package = mkOption {
|
||||||
The package to use as your PDF viewer.
|
# type = package;
|
||||||
This viewer needs to support Synctex.
|
# default = pkgs.okular;
|
||||||
'';
|
# description = ''
|
||||||
};
|
# The package to use as your PDF viewer.
|
||||||
executable = mkOption {
|
# This viewer needs to support Synctex.
|
||||||
type = str;
|
# '';
|
||||||
default = "okular";
|
# };
|
||||||
description = ''
|
# executable = mkOption {
|
||||||
Defines the executable of the PDF previewer. The previewer needs to support SyncTeX.
|
# type = str;
|
||||||
'';
|
# default = "okular";
|
||||||
};
|
# description = ''
|
||||||
args = mkOption {
|
# Defines the executable of the PDF previewer. The previewer needs to support SyncTeX.
|
||||||
type = listOf str;
|
# '';
|
||||||
default = [
|
# };
|
||||||
"--unique"
|
# args = mkOption {
|
||||||
"file:%p#src:%l%f"
|
# type = listOf str;
|
||||||
];
|
# default = [
|
||||||
description = ''
|
# "--unique"
|
||||||
Defines additional arguments that are passed to the configured previewer to perform the forward search.
|
# "file:%p#src:%l%f"
|
||||||
The placeholders %f, %p, %l will be replaced by the server.
|
# ];
|
||||||
|
# description = ''
|
||||||
Placeholders:
|
# Defines additional arguments that are passed to the configured previewer to perform the forward search.
|
||||||
- %f: The path of the current TeX file.
|
# The placeholders %f, %p, %l will be replaced by the server.
|
||||||
- %p: The path of the current PDF file.
|
#
|
||||||
- %l: The current line number.
|
# Placeholders:
|
||||||
'';
|
# - %f: The path of the current TeX file.
|
||||||
};
|
# - %p: The path of the current PDF file.
|
||||||
};
|
# - %l: The current line number.
|
||||||
|
# '';
|
||||||
extraLuaSettings = mkOption {
|
# };
|
||||||
type = str;
|
# };
|
||||||
default = "";
|
#
|
||||||
example = ''
|
# extraLuaSettings = mkOption {
|
||||||
formatterLineLength = 80,
|
# type = str;
|
||||||
'';
|
# default = "";
|
||||||
description = ''
|
# example = ''
|
||||||
For any options that do not have options provided through nvf this can be used to add them.
|
# formatterLineLength = 80,
|
||||||
Options already declared in nvf config will NOT be overridden.
|
# '';
|
||||||
|
# description = ''
|
||||||
Options will be placed in:
|
# 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.
|
||||||
lspconfig.texlab.setup {
|
#
|
||||||
settings = {
|
# Options will be placed in:
|
||||||
texlab = {
|
# ```
|
||||||
...
|
# lspconfig.texlab.setup {
|
||||||
<nvf defined options>
|
# settings = {
|
||||||
...
|
# texlab = {
|
||||||
<extraLuaSettings>
|
# ...
|
||||||
}
|
# <nvf defined options>
|
||||||
}
|
# ...
|
||||||
}
|
# <extraLuaSettings>
|
||||||
```
|
# }
|
||||||
'';
|
# }
|
||||||
};
|
# }
|
||||||
};
|
# ```
|
||||||
|
# '';
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
|
||||||
# Add other LSPs here
|
# Add other LSPs here
|
||||||
};
|
# };
|
||||||
|
|
||||||
# config = mkIf cfg.enable (mkMerge [
|
# config = mkIf cfg.enable (mkMerge [
|
||||||
# (mkIf (any (x: x.enable) (attrValues cfg.lsp)) (
|
# (mkIf (any (x: x.enable) (attrValues cfg.lsp)) (
|
||||||
|
|
@ -415,114 +418,114 @@ in {
|
||||||
{
|
{
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig.enable = true;
|
||||||
} # Enable lspconfig when any of the lsps are enabled
|
} # Enable lspconfig when any of the lsps are enabled
|
||||||
// (mkMerge [
|
# // (mkMerge [
|
||||||
# ----- Texlab -----
|
# # ----- Texlab -----
|
||||||
(
|
# (
|
||||||
let
|
# let
|
||||||
tl = cfg.lsp.texlab;
|
# tl = cfg.lsp.texlab;
|
||||||
build = tl.build;
|
# build = tl.build;
|
||||||
|
#
|
||||||
listToLua = list: nullOnEmpty:
|
# listToLua = list: nullOnEmpty:
|
||||||
if length list == 0
|
# if length list == 0
|
||||||
then
|
# then
|
||||||
if nullOnEmpty
|
# if nullOnEmpty
|
||||||
then "null"
|
# then "null"
|
||||||
else "{ }"
|
# else "{ }"
|
||||||
else "{ ${concatStringsSep ", " (map (x: ''"${toString x}"'') list)} }";
|
# else "{ ${concatStringsSep ", " (map (x: ''"${toString x}"'') list)} }";
|
||||||
|
#
|
||||||
stringToLua = string: nullOnEmpty:
|
# stringToLua = string: nullOnEmpty:
|
||||||
if string == ""
|
# if string == ""
|
||||||
then
|
# then
|
||||||
if nullOnEmpty
|
# if nullOnEmpty
|
||||||
then "null"
|
# then "null"
|
||||||
else ""
|
# else ""
|
||||||
else ''"${string}"'';
|
# else ''"${string}"'';
|
||||||
|
#
|
||||||
boolToLua = boolean:
|
# boolToLua = boolean:
|
||||||
if boolean
|
# if boolean
|
||||||
then "true"
|
# then "true"
|
||||||
else "false";
|
# else "false";
|
||||||
|
#
|
||||||
# -- Build --
|
# # -- Build --
|
||||||
buildConfig = let
|
# buildConfig = let
|
||||||
# This function will sort through the builder options of ...texlab.build and count how many
|
# # This function will sort through the builder options of ...texlab.build and count how many
|
||||||
# builders have been enabled and get the attrs of the last enabled builder.
|
# # builders have been enabled and get the attrs of the last enabled builder.
|
||||||
getBuilder = {
|
# getBuilder = {
|
||||||
enabledBuildersCount ? 0,
|
# enabledBuildersCount ? 0,
|
||||||
enabledBuilderName ? "",
|
# enabledBuilderName ? "",
|
||||||
index ? 0,
|
# index ? 0,
|
||||||
builderNamesList ? (
|
# builderNamesList ? (
|
||||||
filter (
|
# filter (
|
||||||
x: let
|
# x: let
|
||||||
y = tl.build.${x};
|
# y = tl.build.${x};
|
||||||
in (isAttrs y && hasAttr "enable" y)
|
# in (isAttrs y && hasAttr "enable" y)
|
||||||
) (attrNames tl.build)
|
# ) (attrNames tl.build)
|
||||||
),
|
# ),
|
||||||
}: let
|
# }: let
|
||||||
currentBuilderName = elemAt builderNamesList index;
|
# currentBuilderName = elemAt builderNamesList index;
|
||||||
currentBuilder = tl.build.${currentBuilderName};
|
# currentBuilder = tl.build.${currentBuilderName};
|
||||||
nextIndex = index + 1;
|
# nextIndex = index + 1;
|
||||||
currentState = {
|
# currentState = {
|
||||||
enabledBuildersCount =
|
# enabledBuildersCount =
|
||||||
if currentBuilder.enable
|
# if currentBuilder.enable
|
||||||
then enabledBuildersCount + 1
|
# then enabledBuildersCount + 1
|
||||||
else enabledBuildersCount;
|
# else enabledBuildersCount;
|
||||||
enabledBuilderName =
|
# enabledBuilderName =
|
||||||
if currentBuilder.enable
|
# if currentBuilder.enable
|
||||||
then currentBuilderName
|
# then currentBuilderName
|
||||||
else enabledBuilderName;
|
# else enabledBuilderName;
|
||||||
};
|
# };
|
||||||
in
|
# in
|
||||||
if length builderNamesList > nextIndex
|
# if length builderNamesList > nextIndex
|
||||||
then
|
# then
|
||||||
getBuilder ({
|
# getBuilder ({
|
||||||
inherit builderNamesList;
|
# inherit builderNamesList;
|
||||||
index = nextIndex;
|
# index = nextIndex;
|
||||||
}
|
# }
|
||||||
// currentState)
|
# // currentState)
|
||||||
else currentState;
|
# else currentState;
|
||||||
|
#
|
||||||
getBuilderResults = getBuilder {};
|
# getBuilderResults = getBuilder {};
|
||||||
builder = tl.build.${getBuilderResults.enabledBuilderName};
|
# builder = tl.build.${getBuilderResults.enabledBuilderName};
|
||||||
builderArgs = collateArgs.lsp.texlab.build.${getBuilderResults.enabledBuilderName} tl.build;
|
# builderArgs = collateArgs.lsp.texlab.build.${getBuilderResults.enabledBuilderName} tl.build;
|
||||||
in
|
# in
|
||||||
if getBuilderResults.enabledBuildersCount == 0
|
# if getBuilderResults.enabledBuildersCount == 0
|
||||||
then ""
|
# then ""
|
||||||
else if getBuilderResults.enabledBuildersCount > 1
|
# else if getBuilderResults.enabledBuildersCount > 1
|
||||||
then throw "Texlab does not support having more than 1 builders enabled!"
|
# then throw "Texlab does not support having more than 1 builders enabled!"
|
||||||
else ''
|
# else ''
|
||||||
build = {
|
# build = {
|
||||||
executable = "${builder.package}/bin/${builder.executable}",
|
# executable = "${builder.package}/bin/${builder.executable}",
|
||||||
args = ${listToLua builderArgs false},
|
# args = ${listToLua builderArgs false},
|
||||||
forwardSearchAfter = ${boolToLua build.forwardSearchAfter},
|
# forwardSearchAfter = ${boolToLua build.forwardSearchAfter},
|
||||||
onSave = ${boolToLua build.onSave},
|
# onSave = ${boolToLua build.onSave},
|
||||||
useFileList = ${boolToLua build.useFileList},
|
# useFileList = ${boolToLua build.useFileList},
|
||||||
auxDirectory = ${stringToLua build.auxDirectory true},
|
# auxDirectory = ${stringToLua build.auxDirectory true},
|
||||||
logDirectory = ${stringToLua build.logDirectory true},
|
# logDirectory = ${stringToLua build.logDirectory true},
|
||||||
pdfDirectory = ${stringToLua build.pdfDirectory true},
|
# pdfDirectory = ${stringToLua build.pdfDirectory true},
|
||||||
filename = ${stringToLua build.filename true},
|
# filename = ${stringToLua build.filename true},
|
||||||
},
|
# },
|
||||||
'';
|
# '';
|
||||||
in (mkIf tl.enable {
|
# in (mkIf tl.enable {
|
||||||
vim.lsp.lspconfig.sources.texlab = ''
|
# vim.lsp.lspconfig.sources.texlab = ''
|
||||||
lspconfig.texlab.setup {
|
# lspconfig.texlab.setup {
|
||||||
cmd = { "${tl.package}/bin/texlab" },
|
# cmd = { "${tl.package}/bin/texlab" },
|
||||||
settings = {
|
# settings = {
|
||||||
texlab = {
|
# texlab = {
|
||||||
${buildConfig}
|
# ${buildConfig}
|
||||||
forwardSearch = {
|
# forwardSearch = {
|
||||||
executable = "${tl.forwardSearch.package}/bin/${tl.forwardSearch.executable}",
|
# executable = "${tl.forwardSearch.package}/bin/${tl.forwardSearch.executable}",
|
||||||
args = ${listToLua tl.forwardSearch.args true}
|
# args = ${listToLua tl.forwardSearch.args true}
|
||||||
},
|
# },
|
||||||
${tl.extraLuaSettings}
|
# ${tl.extraLuaSettings}
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
'';
|
# '';
|
||||||
})
|
# })
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
# Add other LSPs here
|
# # Add other LSPs here
|
||||||
])
|
# ])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
512
modules/plugins/languages/tex/lsp/texlab.nix
Normal file
512
modules/plugins/languages/tex/lsp/texlab.nix
Normal file
|
|
@ -0,0 +1,512 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit
|
||||||
|
(lib.types)
|
||||||
|
bool
|
||||||
|
either
|
||||||
|
enum
|
||||||
|
ints
|
||||||
|
listOf
|
||||||
|
oneOf
|
||||||
|
package
|
||||||
|
str
|
||||||
|
;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
inherit
|
||||||
|
(builtins)
|
||||||
|
any
|
||||||
|
attrNames
|
||||||
|
attrValues
|
||||||
|
concatLists
|
||||||
|
concatStringsSep
|
||||||
|
elem
|
||||||
|
elemAt
|
||||||
|
filter
|
||||||
|
hasAttr
|
||||||
|
isAttrs
|
||||||
|
length
|
||||||
|
map
|
||||||
|
throw
|
||||||
|
toString
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.vim.languages.tex;
|
||||||
|
|
||||||
|
# --- Enable Options ---
|
||||||
|
mkEnableDefaultOption = default: description: (mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = default;
|
||||||
|
example = !default;
|
||||||
|
description = description;
|
||||||
|
});
|
||||||
|
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
|
||||||
|
|
||||||
|
# --- Arg Collation Functions --
|
||||||
|
collateArgs.lsp.texlab.build = {
|
||||||
|
tectonic = buildConfig: let
|
||||||
|
selfConfig = buildConfig.tectonic;
|
||||||
|
in (
|
||||||
|
# Base args
|
||||||
|
[
|
||||||
|
"-X"
|
||||||
|
"compile"
|
||||||
|
"%f"
|
||||||
|
]
|
||||||
|
# Flags
|
||||||
|
++ (
|
||||||
|
if selfConfig.keepIntermediates
|
||||||
|
then ["--keep-intermediates"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.keepLogs
|
||||||
|
then ["--keep-logs"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.onlyCached
|
||||||
|
then ["--only-cached"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.synctex
|
||||||
|
then ["--synctex"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.untrustedInput
|
||||||
|
then ["--untrusted"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
# Options
|
||||||
|
++ (
|
||||||
|
if selfConfig.reruns > 0
|
||||||
|
then ["--reruns" "${toString selfConfig.reruns}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.bundle != ""
|
||||||
|
then ["--bundle" "${toString selfConfig.bundle}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.webBundle != ""
|
||||||
|
then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.outfmt != ""
|
||||||
|
then ["--outfmt" "${toString selfConfig.outfmt}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
||||||
|
++ (
|
||||||
|
if selfConfig.format != ""
|
||||||
|
then ["--format" "${toString selfConfig.format}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.color != ""
|
||||||
|
then ["--color" "${toString selfConfig.color}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
# Still options but these are not defined by builder specific options but
|
||||||
|
# instead synchronize options between the global build options and builder
|
||||||
|
# specific options
|
||||||
|
++ (
|
||||||
|
if !(elem buildConfig.pdfDirectory ["." ""])
|
||||||
|
then ["--outdir" "${buildConfig.pdfDirectory}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
);
|
||||||
|
custom = buildConfig: buildConfig.custom.args;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.vim.languages.tex.lsp.texlab = {
|
||||||
|
enable = mkEnableLspOption "Whether to enable Tex LSP support (texlab)";
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = package;
|
||||||
|
default = pkgs.texlab;
|
||||||
|
description = "texlab package";
|
||||||
|
};
|
||||||
|
|
||||||
|
build = {
|
||||||
|
tectonic = {
|
||||||
|
enable = mkEnableDefaultOption true "Whether to enable Tex Compilation Via Tectonic";
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = package;
|
||||||
|
default = pkgs.tectonic;
|
||||||
|
description = "tectonic package";
|
||||||
|
};
|
||||||
|
|
||||||
|
executable = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "tectonic";
|
||||||
|
description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||||
|
};
|
||||||
|
|
||||||
|
# -- Flags --
|
||||||
|
keepIntermediates = mkEnableDefaultOption false ''
|
||||||
|
Keep the intermediate files generated during processing.
|
||||||
|
|
||||||
|
If texlab is reporting build errors when there shouldn't be, disable this option.
|
||||||
|
'';
|
||||||
|
keepLogs = mkEnableDefaultOption true ''
|
||||||
|
Keep the log files generated during processing.
|
||||||
|
|
||||||
|
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
||||||
|
'';
|
||||||
|
onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
||||||
|
synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
||||||
|
untrustedInput = mkEnableDefaultOption false "Input is untrusted -- disable all known-insecure features";
|
||||||
|
|
||||||
|
# -- Options --
|
||||||
|
reruns = mkOption {
|
||||||
|
type = ints.unsigned;
|
||||||
|
default = 0;
|
||||||
|
example = 2;
|
||||||
|
description = "Rerun the TeX engine exactly this many times after the first";
|
||||||
|
};
|
||||||
|
|
||||||
|
bundle = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "";
|
||||||
|
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
||||||
|
};
|
||||||
|
|
||||||
|
webBundle = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "";
|
||||||
|
description = "Use this URL to find resource files instead of the default";
|
||||||
|
};
|
||||||
|
|
||||||
|
outfmt = mkOption {
|
||||||
|
type = enum [
|
||||||
|
"pdf"
|
||||||
|
"html"
|
||||||
|
"xdv"
|
||||||
|
"aux"
|
||||||
|
"fmt"
|
||||||
|
""
|
||||||
|
];
|
||||||
|
default = "";
|
||||||
|
description = "The kind of output to generate";
|
||||||
|
};
|
||||||
|
|
||||||
|
hidePaths = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
example = [
|
||||||
|
"./secrets.tex"
|
||||||
|
"./passwords.tex"
|
||||||
|
];
|
||||||
|
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
||||||
|
};
|
||||||
|
|
||||||
|
format = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "";
|
||||||
|
description = "The name of the \"format\" file used to initialize the TeX engine";
|
||||||
|
};
|
||||||
|
|
||||||
|
color = mkOption {
|
||||||
|
type = enum [
|
||||||
|
"always"
|
||||||
|
"auto"
|
||||||
|
"never"
|
||||||
|
""
|
||||||
|
];
|
||||||
|
default = "";
|
||||||
|
example = "always";
|
||||||
|
description = "Enable/disable colorful log output";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
Add extra command line options to include in the tectonic build command.
|
||||||
|
Extra options added here will not overwrite the options set in as nvf options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
custom = {
|
||||||
|
enable = mkEnableDefaultOption false "Whether to enable using a custom build package";
|
||||||
|
package = mkOption {
|
||||||
|
type = package;
|
||||||
|
default = pkgs.tectonic;
|
||||||
|
description = "build/compiler package";
|
||||||
|
};
|
||||||
|
executable = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "tectonic";
|
||||||
|
description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||||
|
};
|
||||||
|
args = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [
|
||||||
|
"-X"
|
||||||
|
"compile"
|
||||||
|
"%f"
|
||||||
|
"--synctex"
|
||||||
|
"--keep-logs"
|
||||||
|
"--keep-intermediates"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
Defines additional arguments that are passed to the configured LaTeX build tool.
|
||||||
|
Note that flags and their arguments need to be separate elements in this array.
|
||||||
|
To pass the arguments -foo bar to a build tool, args needs to be ["-foo" "bar"].
|
||||||
|
The placeholder `%f` will be replaced by the server.
|
||||||
|
|
||||||
|
Placeholders:
|
||||||
|
- `%f`: The path of the TeX file to compile.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
forwardSearchAfter = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Set this property to true if you want to execute a forward search after a build.";
|
||||||
|
};
|
||||||
|
onSave = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Set this property to true if you want to compile the project after saving a file.";
|
||||||
|
};
|
||||||
|
useFileList = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
When set to true, the server will use the .fls files produced by the TeX engine as an additional input for the project detection.
|
||||||
|
|
||||||
|
Note that enabling this property might have an impact on performance.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
auxDirectory = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = ".";
|
||||||
|
description = ''
|
||||||
|
When not using latexmk, provides a way to define the directory containing the .aux files.
|
||||||
|
Note that you need to set the aux directory in latex.build.args too.
|
||||||
|
|
||||||
|
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
logDirectory = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = ".";
|
||||||
|
description = ''
|
||||||
|
When not using latexmk, provides a way to define the directory containing the build log files.
|
||||||
|
Note that you need to change the output directory in your build arguments too.
|
||||||
|
|
||||||
|
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
pdfDirectory = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = ".";
|
||||||
|
description = ''
|
||||||
|
When not using latexmk, provides a way to define the directory containing the output files.
|
||||||
|
Note that you need to set the output directory in latex.build.args too.
|
||||||
|
|
||||||
|
When using a latexmkrc file, texlab will automatically infer the correct setting.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
filename = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Allows overriding the default file name of the build artifact. This setting is used to find the correct PDF file to open during forward search.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
forwardSearch = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
description = ''
|
||||||
|
Whether to enable forward search.
|
||||||
|
|
||||||
|
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 allong with custom configs.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
package = mkOption {
|
||||||
|
type = package;
|
||||||
|
default = pkgs.okular;
|
||||||
|
description = ''
|
||||||
|
The package to use as your PDF viewer.
|
||||||
|
This viewer needs to support Synctex.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
executable = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "okular";
|
||||||
|
description = ''
|
||||||
|
Defines the executable of the PDF previewer. The previewer needs to support SyncTeX.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
args = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [
|
||||||
|
"--unique"
|
||||||
|
"file:%p#src:%l%f"
|
||||||
|
];
|
||||||
|
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.
|
||||||
|
|
||||||
|
Placeholders:
|
||||||
|
- %f: The path of the current TeX file.
|
||||||
|
- %p: The path of the current PDF file.
|
||||||
|
- %l: The current line number.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraLuaSettings = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "";
|
||||||
|
example = ''
|
||||||
|
formatterLineLength = 80,
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
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:
|
||||||
|
```
|
||||||
|
lspconfig.texlab.setup {
|
||||||
|
settings = {
|
||||||
|
texlab = {
|
||||||
|
...
|
||||||
|
<nvf defined options>
|
||||||
|
...
|
||||||
|
<extraLuaSettings>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf (cfg.enable && (cfg.lsp.texlab.enable)) (
|
||||||
|
let
|
||||||
|
tl = cfg.lsp.texlab;
|
||||||
|
build = tl.build;
|
||||||
|
|
||||||
|
listToLua = list: nullOnEmpty:
|
||||||
|
if length list == 0
|
||||||
|
then
|
||||||
|
if nullOnEmpty
|
||||||
|
then "null"
|
||||||
|
else "{ }"
|
||||||
|
else "{ ${concatStringsSep ", " (map (x: ''"${toString x}"'') list)} }";
|
||||||
|
|
||||||
|
stringToLua = string: nullOnEmpty:
|
||||||
|
if string == ""
|
||||||
|
then
|
||||||
|
if nullOnEmpty
|
||||||
|
then "null"
|
||||||
|
else ""
|
||||||
|
else ''"${string}"'';
|
||||||
|
|
||||||
|
boolToLua = boolean:
|
||||||
|
if boolean
|
||||||
|
then "true"
|
||||||
|
else "false";
|
||||||
|
|
||||||
|
# -- Build --
|
||||||
|
buildConfig = let
|
||||||
|
# This function will sort through the builder options of ...texlab.build and count how many
|
||||||
|
# builders have been enabled and get the attrs of the last enabled builder.
|
||||||
|
getBuilder = {
|
||||||
|
enabledBuildersCount ? 0,
|
||||||
|
enabledBuilderName ? "",
|
||||||
|
index ? 0,
|
||||||
|
builderNamesList ? (
|
||||||
|
filter (
|
||||||
|
x: let
|
||||||
|
y = tl.build.${x};
|
||||||
|
in (isAttrs y && hasAttr "enable" y)
|
||||||
|
) (attrNames tl.build)
|
||||||
|
),
|
||||||
|
}: let
|
||||||
|
currentBuilderName = elemAt builderNamesList index;
|
||||||
|
currentBuilder = tl.build.${currentBuilderName};
|
||||||
|
nextIndex = index + 1;
|
||||||
|
currentState = {
|
||||||
|
enabledBuildersCount =
|
||||||
|
if currentBuilder.enable
|
||||||
|
then enabledBuildersCount + 1
|
||||||
|
else enabledBuildersCount;
|
||||||
|
enabledBuilderName =
|
||||||
|
if currentBuilder.enable
|
||||||
|
then currentBuilderName
|
||||||
|
else enabledBuilderName;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
if length builderNamesList > nextIndex
|
||||||
|
then
|
||||||
|
getBuilder ({
|
||||||
|
inherit builderNamesList;
|
||||||
|
index = nextIndex;
|
||||||
|
}
|
||||||
|
// currentState)
|
||||||
|
else currentState;
|
||||||
|
|
||||||
|
getBuilderResults = getBuilder {};
|
||||||
|
builder = tl.build.${getBuilderResults.enabledBuilderName};
|
||||||
|
builderArgs = collateArgs.lsp.texlab.build.${getBuilderResults.enabledBuilderName} tl.build;
|
||||||
|
in
|
||||||
|
if getBuilderResults.enabledBuildersCount == 0
|
||||||
|
then ""
|
||||||
|
else if getBuilderResults.enabledBuildersCount > 1
|
||||||
|
then throw "Texlab does not support having more than 1 builders enabled!"
|
||||||
|
else ''
|
||||||
|
build = {
|
||||||
|
executable = "${builder.package}/bin/${builder.executable}",
|
||||||
|
args = ${listToLua builderArgs false},
|
||||||
|
forwardSearchAfter = ${boolToLua build.forwardSearchAfter},
|
||||||
|
onSave = ${boolToLua build.onSave},
|
||||||
|
useFileList = ${boolToLua build.useFileList},
|
||||||
|
auxDirectory = ${stringToLua build.auxDirectory true},
|
||||||
|
logDirectory = ${stringToLua build.logDirectory true},
|
||||||
|
pdfDirectory = ${stringToLua build.pdfDirectory true},
|
||||||
|
filename = ${stringToLua build.filename true},
|
||||||
|
},
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
vim.lsp.lspconfig.sources.texlab = ''
|
||||||
|
lspconfig.texlab.setup {
|
||||||
|
cmd = { "${tl.package}/bin/texlab" },
|
||||||
|
settings = {
|
||||||
|
texlab = {
|
||||||
|
${buildConfig}
|
||||||
|
forwardSearch = {
|
||||||
|
executable = "${tl.forwardSearch.package}/bin/${tl.forwardSearch.executable}",
|
||||||
|
args = ${listToLua tl.forwardSearch.args true}
|
||||||
|
},
|
||||||
|
${tl.extraLuaSettings}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue