Refactored pdfViewer and fixed infrec error

This commit is contained in:
isaacST08 2025-05-03 18:51:58 -06:00
commit 664b27cb2c
12 changed files with 194 additions and 430 deletions

View file

@ -0,0 +1,22 @@
{
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