mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 15:35:30 +00:00
Created assertion for the correct number of pdf viewers instead of throwing an error.
This commit is contained in:
parent
739415da0f
commit
5b616f7907
1 changed files with 38 additions and 20 deletions
|
|
@ -5,9 +5,10 @@
|
||||||
}: let
|
}: let
|
||||||
defaultPdfViewerName = "okular";
|
defaultPdfViewerName = "okular";
|
||||||
|
|
||||||
|
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.types) str package listOf;
|
inherit (lib.types) str package listOf;
|
||||||
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
|
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
viewerCfg = cfg.pdfViewer;
|
viewerCfg = cfg.pdfViewer;
|
||||||
|
|
@ -44,14 +45,11 @@
|
||||||
# Get the index that will be used for the next iteration
|
# Get the index that will be used for the next iteration
|
||||||
nextIndex = index + 1;
|
nextIndex = index + 1;
|
||||||
|
|
||||||
# Increment the count that is recording the number of enabled pdf viewers if
|
# Increment the count that is recording the number of enabled pdf viewers
|
||||||
# this viewer is enabled, otherwise leave it as is.
|
# if this viewer is enabled, otherwise leave it as is.
|
||||||
newEnabledPdfViewersCount =
|
newEnabledPdfViewersCount =
|
||||||
if currentPdfViewer.enable
|
if currentPdfViewer.enable
|
||||||
then
|
then enabledPdfViewersCount + 1
|
||||||
if enabledPdfViewersCount > 0
|
|
||||||
then throw "nvf-tex-language does not support having more than 1 pdf viewer enabled!"
|
|
||||||
else enabledPdfViewersCount + 1
|
|
||||||
else enabledPdfViewersCount;
|
else enabledPdfViewersCount;
|
||||||
|
|
||||||
# If this pdf viewer is enabled, set is as the enabled viewer.
|
# If this pdf viewer is enabled, set is as the enabled viewer.
|
||||||
|
|
@ -84,8 +82,8 @@ in {
|
||||||
imports = [
|
imports = [
|
||||||
./custom.nix
|
./custom.nix
|
||||||
./okular.nix
|
./okular.nix
|
||||||
./sioyek.nix
|
|
||||||
./qpdfview.nix
|
./qpdfview.nix
|
||||||
|
./sioyek.nix
|
||||||
./zathura.nix
|
./zathura.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -96,10 +94,12 @@ in {
|
||||||
description = ''
|
description = ''
|
||||||
The name of the pdf viewer to use.
|
The name of the pdf viewer to use.
|
||||||
|
|
||||||
This value will be automatically set when any of the viewers are 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.
|
Setting this option option manually is not recommended but can be used
|
||||||
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
for some very technical nix-ing. If you wish to use a custom viewer,
|
||||||
|
please use the `custom` entry provided under `viewers`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -109,10 +109,12 @@ in {
|
||||||
description = ''
|
description = ''
|
||||||
The package of the pdf viewer to use.
|
The package of the pdf viewer to use.
|
||||||
|
|
||||||
This value will be automatically set when any of the viewers are 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.
|
Setting this option option manually is not recommended but can be used
|
||||||
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
for some very technical nix-ing. If you wish to use a custom viewer,
|
||||||
|
please use the `custom` entry provided under `viewers`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -122,10 +124,12 @@ in {
|
||||||
description = ''
|
description = ''
|
||||||
The executable for the pdf viewer to use.
|
The executable for the pdf viewer to use.
|
||||||
|
|
||||||
This value will be automatically set when any of the viewers are 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.
|
Setting this option option manually is not recommended but can be used
|
||||||
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
for some very technical nix-ing. If you wish to use a custom viewer,
|
||||||
|
please use the `custom` entry provided under `viewers`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -135,11 +139,25 @@ in {
|
||||||
description = ''
|
description = ''
|
||||||
The command line arguments to use when calling the pdf viewer command.
|
The command line arguments to use when calling the pdf viewer command.
|
||||||
|
|
||||||
This value will be automatically set when any of the viewers are 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.
|
Setting this option option manually is not recommended but can be used
|
||||||
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
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.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue