mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 15:35: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
67
modules/plugins/languages/tex/pdfViewer/viewerTemplate.nix
Normal file
67
modules/plugins/languages/tex/pdfViewer/viewerTemplate.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# This function acts as a template for creating new pdf viewers.
|
||||
# It enforces providing all the parameters required for creating
|
||||
# a new pdf viewer for it to be able to work in the existing code.
|
||||
#
|
||||
# The first layer requirements are as follows:
|
||||
{
|
||||
# This is the name of the pdf viewer, it will only be used internally and
|
||||
# MUST match the <name>.nix file that the pdf viewer is implemented in.
|
||||
name,
|
||||
#
|
||||
# Module attribute set. This is the attribute set that the module that is
|
||||
# defining a pdf viewer is passed as its input.
|
||||
moduleInheritencePackage,
|
||||
#
|
||||
# These are the standard options for the pdf viewer just like creating any
|
||||
# other module. Some options are required and are described below but
|
||||
# it will also accept any other options that are provided to it.
|
||||
options,
|
||||
#
|
||||
# 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.${name}"
|
||||
argsFunction,
|
||||
...
|
||||
}: let
|
||||
# Inherit the necessary variables available to any module.
|
||||
inherit (moduleInheritencePackage) lib config;
|
||||
#
|
||||
# Inherit other useful functions.
|
||||
inherit (lib.modules) mkIf;
|
||||
#
|
||||
# Set the cfg variable
|
||||
cfg = config.vim.languages.tex;
|
||||
#
|
||||
# Set the cfg of the viewer itself
|
||||
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.${name} = ({
|
||||
# The enable option. This one is self explanatory.
|
||||
enable,
|
||||
#
|
||||
# This is the package option for the pdf viewer.
|
||||
package,
|
||||
#
|
||||
# This is the executable that will be used to call the pdf viewer.
|
||||
# It, along with package will result in:
|
||||
# "<package_path>/bin/<executable>"
|
||||
executable,
|
||||
#
|
||||
# Any other options provided are accepted.
|
||||
...
|
||||
} @ opts:
|
||||
opts)
|
||||
options;
|
||||
|
||||
# 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 = {
|
||||
inherit name;
|
||||
inherit (viewerCfg) package executable;
|
||||
args = argsFunction viewerCfg;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue