aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRobin Stumm <dermetfan@users.noreply.github.com>2020-07-03 22:43:18 +0200
committerGitHub <noreply@github.com>2020-07-03 22:43:18 +0200
commit7dc322c1ebe049dde356386ff46809c13bcfbff9 (patch)
treea7c340d7ae83b6500ad80fb992a5cb58b894eb82 /modules
parent87361907435aa40175c5e46dd98a05ad6bd8c7eb (diff)
kakoune: support user modes in keyMappings
kakoune: support user modes in keyMappings User modes are declared automatically. PR #1286
Diffstat (limited to 'modules')
-rw-r--r--modules/programs/kakoune.nix29
1 files changed, 18 insertions, 11 deletions
diff --git a/modules/programs/kakoune.nix b/modules/programs/kakoune.nix
index aca5a1ad340..d2fd8eb10a1 100644
--- a/modules/programs/kakoune.nix
+++ b/modules/programs/kakoune.nix
@@ -97,16 +97,7 @@ let
keyMapping = types.submodule {
options = {
mode = mkOption {
- type = types.enum [
- "insert"
- "normal"
- "prompt"
- "menu"
- "user"
- "goto"
- "view"
- "object"
- ];
+ type = types.str;
example = "user";
description = ''
The mode in which the mapping takes effect.
@@ -543,6 +534,21 @@ let
}"
];
+ userModeString = mode:
+ optionalString (!builtins.elem mode [
+ "insert"
+ "normal"
+ "prompt"
+ "menu"
+ "user"
+ "goto"
+ "view"
+ "object"
+ ]) "try %{declare-user-mode ${mode}}";
+
+ userModeStrings = map userModeString
+ (lists.unique (map (km: km.mode) cfg.config.keyMappings));
+
keyMappingString = km:
concatStringsSep " " [
"map global"
@@ -592,7 +598,8 @@ let
++ [ "# UI options" ]
++ optional (ui != null) "set-option global ui_options ${uiOptions}"
- ++ [ "# Key mappings" ] ++ map keyMappingString keyMappings
+ ++ [ "# User modes" ] ++ userModeStrings ++ [ "# Key mappings" ]
+ ++ map keyMappingString keyMappings
++ [ "# Hooks" ] ++ map hookString hooks);
in pkgs.writeText "kakrc"