nix-community.nixvim/plugins/languages/vimtex.nix
2024-02-22 01:34:19 +01:00

97 lines
2.3 KiB
Nix

{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
name = "vimtex";
defaultPackage = pkgs.vimPlugins.vimtex;
globalPrefix = "vimtex_";
maintainers = [maintainers.GaetanLepage];
extraPackages = [pkgs.pstree];
# TODO introduced 2024-02-20: remove 2024-04-20
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"viewMethod"
];
imports = let
basePluginPath = ["plugins" "vimtex"];
in [
(
mkRemovedOptionModule
(basePluginPath ++ ["installTexLive"])
"If you don't want `texlive` to be installed, set `plugins.vimtex.texlivePackage` to `null`."
)
(
mkRenamedOptionModule
(basePluginPath ++ ["texLivePackage"])
(basePluginPath ++ ["texlivePackage"])
)
];
settingsOptions = {
view_method = mkOption {
type = types.str;
default = "general";
example = "zathura";
description = ''
Set the viewer method.
By default, a generic viewer is used through the general view method (e.g. `xdg-open` on Linux).
'';
};
};
settingsExample = {
view_method = "zathura";
compiler_method = "latexrun";
toc_config = {
split_pos = "vert topleft";
split_width = 40;
};
};
extraOptions = {
texlivePackage = mkOption {
type = with types; nullOr package;
default = pkgs.texlive.combined.scheme-medium;
example = null;
description = ''
The package to install for `textlive.
Set to `null` for not installing `texlive` at all.
'';
};
};
extraConfig = cfg: {
plugins.vimtex.settings = {
enabled = true;
callback_progpath = "nvim";
};
extraPackages = let
# xdotool does not exist on darwin
xdotool = optional pkgs.stdenv.isLinux pkgs.xdotool;
viewerPackages =
{
general = xdotool;
zathura = xdotool ++ [pkgs.zathura];
zathura_simple = [pkgs.zathura];
mupdf = xdotool ++ [pkgs.mupdf];
}
.${cfg.settings.view_method}
or [];
in
(
optional
(cfg.texlivePackage != null)
cfg.texlivePackage
)
++ viewerPackages;
};
}