mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 07:25:30 +00:00
Reorganized file and options structure for more intuitive use
This commit is contained in:
parent
821cefec27
commit
e08d0b5a4e
8 changed files with 14 additions and 22 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
|
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
viewersCfg = cfg.pdfViewer.viewers;
|
viewerCfg = cfg.pdfViewer;
|
||||||
|
|
||||||
enabledPdfViewersInfo = let
|
enabledPdfViewersInfo = let
|
||||||
# This function will sort through the pdf viewer options and count how many
|
# This function will sort through the pdf viewer options and count how many
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
pdfViewerNamesList ? (
|
pdfViewerNamesList ? (
|
||||||
filter (
|
filter (
|
||||||
x: let
|
x: let
|
||||||
y = viewersCfg.${x};
|
y = viewerCfg.${x};
|
||||||
in (
|
in (
|
||||||
isAttrs y
|
isAttrs y
|
||||||
&& hasAttr "enable" y
|
&& hasAttr "enable" y
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
&& hasAttr "executable" y
|
&& hasAttr "executable" y
|
||||||
&& hasAttr "args" y
|
&& hasAttr "args" y
|
||||||
)
|
)
|
||||||
) (attrNames viewersCfg)
|
) (attrNames viewerCfg)
|
||||||
),
|
),
|
||||||
currentEnabledPdfViewerName ? defaultPdfViewerName,
|
currentEnabledPdfViewerName ? defaultPdfViewerName,
|
||||||
}: let
|
}: let
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
currentPdfViewerName = elemAt pdfViewerNamesList index;
|
currentPdfViewerName = elemAt pdfViewerNamesList index;
|
||||||
|
|
||||||
# Get the current pdf viewer object
|
# Get the current pdf viewer object
|
||||||
currentPdfViewer = viewersCfg.${currentPdfViewerName};
|
currentPdfViewer = viewerCfg.${currentPdfViewerName};
|
||||||
|
|
||||||
# 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;
|
||||||
|
|
@ -79,10 +79,14 @@
|
||||||
};
|
};
|
||||||
in (getEnabledPdfViewersInfo {});
|
in (getEnabledPdfViewersInfo {});
|
||||||
|
|
||||||
enabledPdfViewerCfg = viewersCfg.${enabledPdfViewersInfo.enabledViewerName};
|
enabledPdfViewerCfg = viewerCfg.${enabledPdfViewersInfo.enabledViewerName};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./viewers
|
./custom.nix
|
||||||
|
./okular.nix
|
||||||
|
./sioyek.nix
|
||||||
|
./qpdfview.nix
|
||||||
|
./zathura.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim.languages.tex.pdfViewer = {
|
options.vim.languages.tex.pdfViewer = {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
# These are the command line arguments that will accompany the executable
|
# These are the command line arguments that will accompany the executable
|
||||||
# when the view command is called.
|
# when the view command is called.
|
||||||
# This is a function that will take in the cfg of its own pdf viewer.
|
# 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,
|
argsFunction,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
|
@ -34,11 +34,11 @@
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
#
|
#
|
||||||
# Set the cfg of the viewer itself
|
# Set the cfg of the viewer itself
|
||||||
viewerCfg = cfg.pdfViewer.viewers.${name};
|
viewerCfg = cfg.pdfViewer.${name};
|
||||||
in {
|
in {
|
||||||
# These are the options for the pdf viewer. It will accept any options
|
# These are the options for the pdf viewer. It will accept any options
|
||||||
# provided to it but some options are mandatory:
|
# 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.
|
# The enable option. This one is self explanatory.
|
||||||
enable,
|
enable,
|
||||||
#
|
#
|
||||||
|
|
@ -56,10 +56,8 @@ in {
|
||||||
opts)
|
opts)
|
||||||
options;
|
options;
|
||||||
|
|
||||||
# Check that the language, overall pdf viewing, and this pdf viewer have been enabled before making any
|
# Check that the language and this pdf viewer have been enabled before making any config.
|
||||||
# config.
|
|
||||||
config = mkIf (cfg.enable && viewerCfg.enable) {
|
config = mkIf (cfg.enable && viewerCfg.enable) {
|
||||||
# vim.languages.tex.pdfViewer.viewers.${name} = {
|
|
||||||
vim.languages.tex.pdfViewer = {
|
vim.languages.tex.pdfViewer = {
|
||||||
inherit name;
|
inherit name;
|
||||||
inherit (viewerCfg) package executable;
|
inherit (viewerCfg) package executable;
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./custom.nix
|
|
||||||
./okular.nix
|
|
||||||
./sioyek.nix
|
|
||||||
./qpdfview.nix
|
|
||||||
./zathura.nix
|
|
||||||
];
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue