nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

Expose keymap options for all keymaps defined by nixvim

Open traxys opened this issue 2 years ago • 3 comments

Nixvim defines keymaps for some plugins, we should expose all the possible options for those plugins (like desc, silent, ....) instead of only allowing to specify a key.

Available keymap options (2024-06-01)

traxys avatar Sep 26 '23 20:09 traxys

Related: https://github.com/nix-community/nixvim/blob/b3fb1c4c8189bc873911da3f31d18082a0721fa9/lib/keymap-helpers.nix

trueNAHO avatar Dec 20 '23 16:12 trueNAHO

I think the best approach is to add a mkMapOptionSubmodule variant that omitts either key or action.

Maybe we could do something like:

mkMapOptionSubmodule = defaults: mkMapOptionSubmodule' {
  hasKey = true;
  hasAction = true;
  inherit defaults;
};

mkMapOptionSubmodule' = {
  hasKey ? false,
  hasAction ? false,
  rawAction ? true,
  defaults ? {}
}: submodule {
  options = (
	  (optionalAttrs hasKey {
	    key = mkOption (
	      {
	        type = str;
	        description = "The key to map.";
	        example = "<C-m>";
	      }
	      // (optionalAttrs (defaults ? key) { default = defaults.key; })
	    );
      })
      // (optionalAttrs hasAction {
	    action = mkOption (
	      {
	        type =
              if rawAction
              then nixvimTypes.maybeRaw str
              else str;
	        description = "The action to execute.";
	      }
	      // (optionalAttrs (defaults ? action) { default = defaults.action; })
	    );
      })
      // {
	    mode = mkModeOption defaults.mode or "";
	    options = mapConfigOptions;
        # Deprecated `lua` option omitted
	  }
  );
}

MattSturgeon avatar Jun 01 '24 14:06 MattSturgeon

Or since mkMapOptionSubmodule is only used by the wtf LSP and internally in keymap-helpers, we could change its interface instead of introducing a variant.

MattSturgeon avatar Jun 01 '24 15:06 MattSturgeon