plugins/zk: init + tests (#340)

This commit is contained in:
traxys 2023-04-17 23:13:12 +02:00 committed by GitHub
parent f8c412ba7f
commit 838f616f0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 0 deletions

View file

@ -100,5 +100,6 @@
./utils/emmet.nix ./utils/emmet.nix
./utils/magma-nvim.nix ./utils/magma-nvim.nix
./utils/which-key.nix ./utils/which-key.nix
./utils/zk.nix
]; ];
} }

55
plugins/utils/zk.nix Normal file
View file

@ -0,0 +1,55 @@
{
pkgs,
config,
lib,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
in {
options.plugins.zk = {
enable = mkEnableOption "zk.nvim, a plugin to integrate with zk";
package = helpers.mkPackageOption "zk.nvim" pkgs.vimPlugins.zk-nvim;
picker = helpers.defaultNullOpts.mkEnumFirstDefault ["select" "fzf" "telescope"] ''
it's recommended to use "telescope" or "fzf"
'';
lsp = {
config =
helpers.extraOptionsOptions
// {
cmd = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["zk" "lsp"]'' "";
name = helpers.defaultNullOpts.mkStr "zk" "";
};
autoAttach = {
enabled = helpers.defaultNullOpts.mkBool true "automatically attach buffers in a zk notebook";
filetypes =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["markdown"]''
"matching the given filetypes";
};
};
};
config = let
cfg = config.plugins.zk;
setupOptions = {
inherit (cfg) picker;
lsp = {
inherit (cfg.lsp) config;
auto_attach = {
inherit (cfg.lsp.autoAttach) enabled filetypes;
};
};
};
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPackages = [pkgs.zk];
extraConfigLua = ''
require("zk").setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -0,0 +1,23 @@
{
empty = {
plugins.zk.enable = true;
};
defaults = {
plugins.zk = {
enable = true;
picker = "select";
lsp = {
config = {
cmd = ["zk" "lsp"];
name = "zk";
};
autoAttach = {
enabled = true;
filetypes = ["markdown"];
};
};
};
};
}