Reorganized file and options structure for more intuitive use

This commit is contained in:
isaacST08 2025-01-30 19:15:22 -07:00
commit e08d0b5a4e
8 changed files with 14 additions and 22 deletions

View file

@ -10,7 +10,7 @@
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
cfg = config.vim.languages.tex;
viewersCfg = cfg.pdfViewer.viewers;
viewerCfg = cfg.pdfViewer;
enabledPdfViewersInfo = let
# This function will sort through the pdf viewer options and count how many
@ -23,7 +23,7 @@
pdfViewerNamesList ? (
filter (
x: let
y = viewersCfg.${x};
y = viewerCfg.${x};
in (
isAttrs y
&& hasAttr "enable" y
@ -31,7 +31,7 @@
&& hasAttr "executable" y
&& hasAttr "args" y
)
) (attrNames viewersCfg)
) (attrNames viewerCfg)
),
currentEnabledPdfViewerName ? defaultPdfViewerName,
}: let
@ -39,7 +39,7 @@
currentPdfViewerName = elemAt pdfViewerNamesList index;
# Get the current pdf viewer object
currentPdfViewer = viewersCfg.${currentPdfViewerName};
currentPdfViewer = viewerCfg.${currentPdfViewerName};
# Get the index that will be used for the next iteration
nextIndex = index + 1;
@ -79,10 +79,14 @@
};
in (getEnabledPdfViewersInfo {});
enabledPdfViewerCfg = viewersCfg.${enabledPdfViewersInfo.enabledViewerName};
enabledPdfViewerCfg = viewerCfg.${enabledPdfViewersInfo.enabledViewerName};
in {
imports = [
./viewers
./custom.nix
./okular.nix
./sioyek.nix
./qpdfview.nix
./zathura.nix
];
options.vim.languages.tex.pdfViewer = {

View file

@ -20,7 +20,7 @@
# These are the command line arguments that will accompany the executable
# when the view command is called.
# This is a function that will take in the cfg of its own pdf viewer.
# i.e. it will be called as "args cfg.pdfViewer.viewers.${name}"
# i.e. it will be called as "args cfg.pdfViewer.${name}"
argsFunction,
...
}: let
@ -34,11 +34,11 @@
cfg = config.vim.languages.tex;
#
# Set the cfg of the viewer itself
viewerCfg = cfg.pdfViewer.viewers.${name};
viewerCfg = cfg.pdfViewer.${name};
in {
# These are the options for the pdf viewer. It will accept any options
# provided to it but some options are mandatory:
options.vim.languages.tex.pdfViewer.viewers.${name} = ({
options.vim.languages.tex.pdfViewer.${name} = ({
# The enable option. This one is self explanatory.
enable,
#
@ -56,10 +56,8 @@ in {
opts)
options;
# Check that the language, overall pdf viewing, and this pdf viewer have been enabled before making any
# config.
# Check that the language and this pdf viewer have been enabled before making any config.
config = mkIf (cfg.enable && viewerCfg.enable) {
# vim.languages.tex.pdfViewer.viewers.${name} = {
vim.languages.tex.pdfViewer = {
inherit name;
inherit (viewerCfg) package executable;

View file

@ -1,10 +0,0 @@
{ ... }:
{
imports = [
./custom.nix
./okular.nix
./sioyek.nix
./qpdfview.nix
./zathura.nix
];
}