mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 15:35:30 +00:00
PDF Viewer framework bug fixes and integrated functionallity into texlab lsp implementation
This commit is contained in:
parent
9524d93bd2
commit
95a0125ce0
4 changed files with 42 additions and 38 deletions
|
|
@ -226,31 +226,34 @@ in {
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = package;
|
type = package;
|
||||||
default = pkgs.okular;
|
default = cfg.pdfViewer.package;
|
||||||
description = ''
|
description = ''
|
||||||
The package to use as your PDF viewer.
|
The package to use as your PDF viewer.
|
||||||
This viewer needs to support Synctex.
|
This viewer needs to support Synctex.
|
||||||
|
|
||||||
|
By default it is set to the package of the pdfViewer option.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
executable = mkOption {
|
executable = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = "okular";
|
default = cfg.pdfViewer.executable;
|
||||||
description = ''
|
description = ''
|
||||||
Defines the executable of the PDF previewer. The previewer needs to support SyncTeX.
|
Defines the executable of the PDF previewer. The previewer needs to support SyncTeX.
|
||||||
|
|
||||||
|
By default it is set to the executable of the pdfViewer option.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
args = mkOption {
|
args = mkOption {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = [
|
default = cfg.pdfViewer.args;
|
||||||
"--unique"
|
|
||||||
"file:%p#src:%l%f"
|
|
||||||
];
|
|
||||||
description = ''
|
description = ''
|
||||||
Defines additional arguments that are passed to the configured previewer to perform the forward search.
|
Defines additional arguments that are passed to the configured previewer to perform the forward search.
|
||||||
The placeholders %f, %p, %l will be replaced by the server.
|
The placeholders %f, %p, %l will be replaced by the server.
|
||||||
|
|
||||||
|
By default it is set to the args of the pdfViewer option.
|
||||||
|
|
||||||
Placeholders:
|
Placeholders:
|
||||||
- %f: The path of the current TeX file.
|
- %f: The path of the current TeX file.
|
||||||
- %p: The path of the current PDF file.
|
- %p: The path of the current PDF file.
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
defaultPdfViewerName = "okular";
|
defaultPdfViewerName = "okular";
|
||||||
|
|
||||||
inherit (lib) mkOverride;
|
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.modules) mkIf;
|
|
||||||
inherit (lib.types) str package listOf;
|
inherit (lib.types) str package listOf;
|
||||||
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
|
inherit (builtins) filter isAttrs hasAttr attrNames length elemAt;
|
||||||
inherit (lib.nvim.config) mkBool;
|
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
viewersCfg = cfg.pdfViewer.viewers;
|
viewersCfg = cfg.pdfViewer.viewers;
|
||||||
|
|
@ -52,7 +48,10 @@
|
||||||
# this viewer is enabled, otherwise leave it as is.
|
# this viewer is enabled, otherwise leave it as is.
|
||||||
newEnabledPdfViewersCount =
|
newEnabledPdfViewersCount =
|
||||||
if currentPdfViewer.enable
|
if currentPdfViewer.enable
|
||||||
then enabledPdfViewersCount + 1
|
then
|
||||||
|
if enabledPdfViewersCount > 0
|
||||||
|
then throw "nvf-tex-language does not support having more than 1 pdf viewer enabled!"
|
||||||
|
else enabledPdfViewersCount + 1
|
||||||
else enabledPdfViewersCount;
|
else enabledPdfViewersCount;
|
||||||
|
|
||||||
# If this pdf viewer is enabled, set is as the enabled viewer.
|
# If this pdf viewer is enabled, set is as the enabled viewer.
|
||||||
|
|
@ -81,30 +80,22 @@
|
||||||
in (getEnabledPdfViewersInfo {});
|
in (getEnabledPdfViewersInfo {});
|
||||||
|
|
||||||
enabledPdfViewerCfg = viewersCfg.${enabledPdfViewersInfo.enabledViewerName};
|
enabledPdfViewerCfg = viewersCfg.${enabledPdfViewersInfo.enabledViewerName};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./viewers
|
./viewers
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim.languages.tex.pdfViewer = {
|
options.vim.languages.tex.pdfViewer = {
|
||||||
enable =
|
|
||||||
mkBool (
|
|
||||||
if enabledPdfViewersInfo.count > 1
|
|
||||||
then throw "nvf-tex-language does not support having more than 1 pdf viewer enabled!"
|
|
||||||
else (enabledPdfViewersInfo.count == 1)
|
|
||||||
) ''
|
|
||||||
Whether to enable configuring the pdf viewer.
|
|
||||||
|
|
||||||
By enabling any of the pdfViewers, this option will be automatically set.
|
|
||||||
If you enable more than one pdf viewer then an error will be thrown.
|
|
||||||
'';
|
|
||||||
|
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = enabledPdfViewerCfg.name;
|
default = enabledPdfViewerCfg.name;
|
||||||
description = ''
|
description = ''
|
||||||
TODO
|
The name of the pdf viewer to use.
|
||||||
|
|
||||||
|
This value will be automatically set when any of the viewers are enabled.
|
||||||
|
|
||||||
|
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
|
||||||
|
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -112,7 +103,12 @@ in {
|
||||||
type = package;
|
type = package;
|
||||||
default = enabledPdfViewerCfg.package;
|
default = enabledPdfViewerCfg.package;
|
||||||
description = ''
|
description = ''
|
||||||
The package to set to use a custom viewer.
|
The package of the pdf viewer to use.
|
||||||
|
|
||||||
|
This value will be automatically set when any of the viewers are enabled.
|
||||||
|
|
||||||
|
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
|
||||||
|
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -120,7 +116,12 @@ in {
|
||||||
type = str;
|
type = str;
|
||||||
default = enabledPdfViewerCfg.executable;
|
default = enabledPdfViewerCfg.executable;
|
||||||
description = ''
|
description = ''
|
||||||
TODO
|
The executable for the pdf viewer to use.
|
||||||
|
|
||||||
|
This value will be automatically set when any of the viewers are enabled.
|
||||||
|
|
||||||
|
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
|
||||||
|
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -128,14 +129,13 @@ in {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = enabledPdfViewerCfg.args;
|
default = enabledPdfViewerCfg.args;
|
||||||
description = ''
|
description = ''
|
||||||
TODO
|
The command line arguments to use when calling the pdf viewer command.
|
||||||
|
|
||||||
|
This value will be automatically set when any of the viewers are enabled.
|
||||||
|
|
||||||
|
Setting this option option manually is not recommended but can be used for some very technical nix-ing.
|
||||||
|
If you wish to use a custom viewer, please use the `custom` entry provided under `viewers`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# If the pdf viewer has been enabled, but none of the individual viewers have been enabled,
|
|
||||||
# then enable the default viewer.
|
|
||||||
config = mkIf (cfg.enable && cfg.pdfViewer.enable && enabledPdfViewersInfo.count == 0) {
|
|
||||||
vim.languages.tex.pdfViewer.viewers.${defaultPdfViewerName}.enable = mkOverride 75 true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@ in (
|
||||||
|
|
||||||
args = mkOption {
|
args = mkOption {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = [ "--unique" "file:%p#src:%l%f" ];
|
default = ["--unique" "file:%p#src:%l%f"];
|
||||||
description = "Arguments to pass to the viewer.";
|
description = "Arguments to pass to the viewer.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
args = viewerCfg: ( viewerCfg.args );
|
argsFunction = viewerCfg: (viewerCfg.args);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
# 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.viewers.${name}"
|
||||||
args,
|
argsFunction,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
# Inherit the necessary variables available to any module.
|
# Inherit the necessary variables available to any module.
|
||||||
|
|
@ -59,10 +59,11 @@ in {
|
||||||
# Check that the language, overall pdf viewing, and this pdf viewer have been enabled before making any
|
# Check that the language, overall pdf viewing, 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;
|
||||||
args = args viewerCfg;
|
args = argsFunction viewerCfg;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue