{ lib, nix2lua }: let modeEnum = lib.types.enum [ "" "n" "!" "i" "c" "v" "x" "s" "o" "t" "l" ]; mode = with lib.types; either modeEnum (uniq (listOf modeEnum)); # TODO: maybe add more options and add descriptions from # :help vim.keymap.set # :help nvim_set_keymap keymap = lib.types.submodule ({ config, ... }: { options = with lib; { lhs = mkOption { type = types.str; description = '' Left-hand side |{lhs}| of the mapping. ''; }; rhs = mkOption { type = with types; oneOf [ str attrs ]; description = '' Right-hand side |{rhs}| of the mapping, can be a Lua function. ''; }; mode = mkOption { type = mode; default = ""; description = '' Mode | Norm | Ins | Cmd | Vis | Sel | Opr | Term | Lang | Command +------+-----+-----+-----+-----+-----+------+------+ "" | yes | - | - | yes | yes | yes | - | - | "n" | yes | - | - | - | - | - | - | - | "!" | - | yes | yes | - | - | - | - | - | "i" | - | yes | - | - | - | - | - | - | "c" | - | - | yes | - | - | - | - | - | "v" | - | - | - | yes | yes | - | - | - | "x" | - | - | - | yes | - | - | - | - | "s" | - | - | - | - | yes | - | - | - | "o" | - | - | - | - | - | yes | - | - | "t" | - | - | - | - | - | - | yes | - | "l" | - | yes | yes | - | - | - | - | yes | `:help map-overview` ''; }; buffer = mkOption { type = with types; nullOr attrs; default = null; description = '' The mapping will be effective in the current buffer only. `:help :map-buffer` ''; }; nowait = mkOption { type = types.bool; default = false; description = '' When defining a buffer-local mapping for "," there may be a global mapping that starts with ",". Then you need to type another character for Vim to know whether to use the "," mapping or the longer one. To avoid this add the argument. Then the mapping will be used when it matches, Vim does not wait for more characters to be typed. `:help :map-nowait` ''; }; silent = mkOption { type = types.bool; default = false; description = '' To define a mapping which will not be echoed on the command line. `:help :map-silent` ''; }; script = mkOption { type = types.bool; default = false; description = '' If the first argument to one of these commands is "