From ac43fae7273cba38d1045d191efb5160d011c223 Mon Sep 17 00:00:00 2001 From: derped Date: Thu, 28 Nov 2024 16:21:04 +0100 Subject: [PATCH] Define keyBind interface in submodule. --- modules/nvim-lazy/default.nix | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/modules/nvim-lazy/default.nix b/modules/nvim-lazy/default.nix index 24169cf..4b2735c 100644 --- a/modules/nvim-lazy/default.nix +++ b/modules/nvim-lazy/default.nix @@ -2,7 +2,34 @@ let mkOption = lib.mkOption; types = lib.types; - plugin = types.submodule ( + keyBind = ( + { ... }: + { + options = { + bind = mkOption { + type = types.str; + default = ""; + description = ''The keys to bind.''; + }; + cmd = mkOption { + type = with types; nullOr str; + default = null; + description = ''The command to execute. If this is a lua function set cmdIsFunction to true.''; + }; + cmdIsFunction = mkOption { + type = types.bool; + default = false; + description = ''Needs to be set to true if cmd is a lua function.''; + }; + opts = mkOption { + type = with types; nullOr attrs; + default = null; + description = ''Additional named parameters passed to the keybind function.''; + }; + }; + } + ); + plugin = ( { ... }: { options = { @@ -150,7 +177,7 @@ let }; keys = mkOption { # TODO: update; - type = with types; nullOr (listOf attrs); + type = with types; nullOr (listOf (submodule keyBind)); default = null; description = ''Lazy-load on key mapping.''; }; @@ -195,7 +222,7 @@ in with types; listOf (oneOf [ str - plugin + (submodule plugin) ]); default = [ ]; description = ''List of plugins to be installed with neovim.'';