plugins/typst-vim: init plugin + test

This commit is contained in:
Gaetan Lepage 2023-05-26 11:00:04 +02:00 committed by Gaétan Lepage
parent 2f4a546ba6
commit 3f08cff1d0
3 changed files with 60 additions and 0 deletions

View file

@ -43,6 +43,7 @@
./languages/treesitter/treesitter-playground.nix
./languages/treesitter/treesitter-rainbow.nix
./languages/treesitter/treesitter-refactor.nix
./languages/typst/typst-vim.nix
./languages/vimtex.nix
./languages/zig.nix

View file

@ -0,0 +1,42 @@
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.typst-vim;
helpers = import ../../helpers.nix {inherit lib;};
in {
options.plugins.typst-vim =
helpers.extraOptionsOptions
// {
enable = mkEnableOption "typst.vim";
package = helpers.mkPackageOption "typst-vim" pkgs.vimPlugins.typst-vim;
keymaps = {
silent = mkOption {
type = types.bool;
description = "Whether typst-vim keymaps should be silent.";
default = false;
};
watch =
helpers.mkNullOrOption types.str
"Keymap to preview the document and recompile on change.";
};
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
# Add the typst compiler to nixvim packages
extraPackages = with pkgs; [typst];
maps.normal = with cfg.keymaps;
helpers.mkModeMaps {inherit silent;} {
${watch} = ":TypstWatch<CR>";
};
};
}

View file

@ -0,0 +1,17 @@
{
empty = {
plugins.typst-vim.enable = true;
};
example = {
plugins.typst-vim = {
enable = true;
keymaps = {
silent = true;
watch = "<leader>w";
};
};
};
}