mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/typst: add options
This commit is contained in:
parent
440c449c0a
commit
c2ccb2dfab
2 changed files with 60 additions and 15 deletions
|
@ -8,13 +8,29 @@
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.plugins.typst-vim;
|
cfg = config.plugins.typst-vim;
|
||||||
in {
|
in {
|
||||||
options.plugins.typst-vim =
|
options.plugins.typst-vim = {
|
||||||
helpers.extraOptionsOptions
|
|
||||||
// {
|
|
||||||
enable = mkEnableOption "typst.vim";
|
enable = mkEnableOption "typst.vim";
|
||||||
|
|
||||||
package = helpers.mkPackageOption "typst-vim" pkgs.vimPlugins.typst-vim;
|
package = helpers.mkPackageOption "typst-vim" pkgs.vimPlugins.typst-vim;
|
||||||
|
|
||||||
|
cmd = helpers.defaultNullOpts.mkStr "typst" ''
|
||||||
|
Specifies the location of the Typst executable.
|
||||||
|
'';
|
||||||
|
|
||||||
|
pdfViewer = helpers.mkNullOrOption types.str ''
|
||||||
|
Specifies pdf viewer that `typst watch --open` will use.
|
||||||
|
'';
|
||||||
|
|
||||||
|
concealMath = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Enable concealment for math symbols in math mode (i.e. replaces symbols with their actual
|
||||||
|
unicode character).
|
||||||
|
Warning: this can affect performance
|
||||||
|
'';
|
||||||
|
|
||||||
|
autoCloseToc = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Specifies whether TOC will be automatically closed after using it.
|
||||||
|
'';
|
||||||
|
|
||||||
keymaps = {
|
keymaps = {
|
||||||
silent = mkOption {
|
silent = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
@ -26,6 +42,18 @@ in {
|
||||||
helpers.mkNullOrOption types.str
|
helpers.mkNullOrOption types.str
|
||||||
"Keymap to preview the document and recompile on change.";
|
"Keymap to preview the document and recompile on change.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
The configuration options for typst-vim without the 'typst_' prefix.
|
||||||
|
Example: To set 'typst_foobar' to 1, write
|
||||||
|
extraConfig = {
|
||||||
|
foobar = true;
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -34,6 +62,20 @@ in {
|
||||||
# Add the typst compiler to nixvim packages
|
# Add the typst compiler to nixvim packages
|
||||||
extraPackages = with pkgs; [typst];
|
extraPackages = with pkgs; [typst];
|
||||||
|
|
||||||
|
globals =
|
||||||
|
mapAttrs'
|
||||||
|
(name: nameValuePair ("typst_" + name))
|
||||||
|
(
|
||||||
|
with cfg;
|
||||||
|
{
|
||||||
|
inherit cmd;
|
||||||
|
pdf_viewer = pdfViewer;
|
||||||
|
conceal_math = concealMath;
|
||||||
|
auto_close_toc = autoCloseToc;
|
||||||
|
}
|
||||||
|
// extraConfig
|
||||||
|
);
|
||||||
|
|
||||||
keymaps = with cfg.keymaps;
|
keymaps = with cfg.keymaps;
|
||||||
helpers.keymaps.mkKeymaps
|
helpers.keymaps.mkKeymaps
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,9 +7,12 @@
|
||||||
plugins.typst-vim = {
|
plugins.typst-vim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
cmd = "typst";
|
||||||
|
pdfViewer = "zathura";
|
||||||
|
concealMath = false;
|
||||||
|
autoCloseToc = false;
|
||||||
keymaps = {
|
keymaps = {
|
||||||
silent = true;
|
silent = true;
|
||||||
|
|
||||||
watch = "<leader>w";
|
watch = "<leader>w";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue