mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-12-20 08:10:09 +01:00
23 lines
672 B
Nix
23 lines
672 B
Nix
|
|
{
|
||
|
|
config,
|
||
|
|
lib,
|
||
|
|
...
|
||
|
|
}: let
|
||
|
|
# The attribute set of pdf viewers in this configuration.
|
||
|
|
pdfViewers = config.vim.languages.tex.pdfViewer;
|
||
|
|
|
||
|
|
# The list of pdf viewers in this configuration.
|
||
|
|
pdfViewersList = builtins.attrValues pdfViewers;
|
||
|
|
|
||
|
|
# The list of enabled pdf viewers.
|
||
|
|
enabledPdfViewersList = builtins.filter (x: x.enable) pdfViewersList;
|
||
|
|
|
||
|
|
# The number of enabled pdf viewers.
|
||
|
|
enabledPdfViewersCount = lib.lists.count (x: x.enable) pdfViewersList;
|
||
|
|
in
|
||
|
|
if (enabledPdfViewersCount == 0)
|
||
|
|
# Use the fallback if no pdf viewer was enabled.
|
||
|
|
then pdfViewers.fallback
|
||
|
|
# Otherwise get the first enabled viewer.
|
||
|
|
else builtins.head enabledPdfViewersList
|