utility/yanky-nvim: fix plugin setupOpts; assert when shada is disabled

This commit is contained in:
raf 2025-02-24 16:56:15 +03:00
commit 831a5db8fa
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 17 additions and 5 deletions

View file

@ -11,6 +11,7 @@
cfg = config.vim.utility.yanky-nvim; cfg = config.vim.utility.yanky-nvim;
usingSqlite = cfg.setupOpts.ring.storage == "sqlite"; usingSqlite = cfg.setupOpts.ring.storage == "sqlite";
usingShada = cfg.setupOpts.ring.storage == "shada";
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
@ -28,5 +29,15 @@ in {
require("yanky").setup(${toLuaObject cfg.setupOpts}); require("yanky").setup(${toLuaObject cfg.setupOpts});
''; '';
}; };
assertions = [
{
assertion = usingShada && ((config.vim.options.shada or "") == "");
message = ''
Yanky.nvim is configured to use 'shada' for the storage backend, but shada is disabled
in 'vim.options'. Please re-enable shada, or switch to a different backend.
'';
}
];
}; };
} }

View file

@ -1,13 +1,14 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum; inherit (lib.types) enum;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.utility.yanky-nvim = { options.vim.utility.yanky-nvim = {
enable = mkEnableOption '' enable = mkEnableOption ''
improved Yank and Put functionalities for Neovim [yanky-nvim] improved Yank and Put functionalities for Neovim [yanky-nvim]
''; '';
setupOpts = { setupOpts = mkPluginSetupOption "yanky-nvim" {
ring.storage = mkOption { ring.storage = mkOption {
type = enum ["shada" "sqlite" "memory"]; type = enum ["shada" "sqlite" "memory"];
default = "shada"; default = "shada";
@ -15,11 +16,11 @@ in {
description = '' description = ''
storage mode for ring values. storage mode for ring values.
- shada: this will save pesistantly using Neovim ShaDa feature. - **shada**: this will save pesistantly using Neovim ShaDa feature.
This means that history will be persisted between each session of Neovim. This means that history will be persisted between each session of Neovim.
- memory: each Neovim instance will have his own history and it will be - **memory**: each Neovim instance will have his own history and it will be
lost between sessions. lost between sessions.
- sqlite: more reliable than `shada`, requires `sqlite.lua` as a dependency. - **sqlite**: more reliable than `shada`, requires `sqlite.lua` as a dependency.
nvf will add this dependency to `PATH` automatically. nvf will add this dependency to `PATH` automatically.
''; '';
}; };