aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/programs/kakoune.nix
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/modules/programs/kakoune.nix')
-rw-r--r--home-manager/modules/programs/kakoune.nix70
1 files changed, 57 insertions, 13 deletions
diff --git a/home-manager/modules/programs/kakoune.nix b/home-manager/modules/programs/kakoune.nix
index faf2542dc70..6db311a1376 100644
--- a/home-manager/modules/programs/kakoune.nix
+++ b/home-manager/modules/programs/kakoune.nix
@@ -49,6 +49,7 @@ let
"InsertCompletionShow"
"InsertCompletionHide"
"InsertCompletionSelect"
+ "ModuleLoaded"
];
example = "SetOption";
description = ''
@@ -96,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.
@@ -497,6 +489,10 @@ let
};
};
+ kakouneWithPlugins = pkgs.wrapKakoune pkgs.kakoune-unwrapped {
+ configure = { plugins = cfg.plugins; };
+ };
+
configFile = let
wrapOptions = with cfg.config.wrapLines;
concatStrings [
@@ -513,6 +509,25 @@ let
"${optionalString (separator != null) " -separator ${separator}"}"
];
+ showWhitespaceOptions = with cfg.config.showWhitespace;
+ let
+ quoteSep = sep:
+ if sep == "'" then
+ ''"'"''
+ else if lib.strings.stringLength sep == 1 then
+ "'${sep}'"
+ else
+ sep; # backwards compat, in case sep == "' '", etc.
+
+ in concatStrings [
+ (optionalString (tab != null) " -tab ${quoteSep tab}")
+ (optionalString (tabStop != null) " -tabpad ${quoteSep tabStop}")
+ (optionalString (space != null) " -spc ${quoteSep space}")
+ (optionalString (nonBreakingSpace != null)
+ " -nbsp ${quoteSep nonBreakingSpace}")
+ (optionalString (lineFeed != null) " -lf ${quoteSep lineFeed}")
+ ];
+
uiOptions = with cfg.config.ui;
concatStringsSep " " [
"ncurses_set_title=${if setTitle then "true" else "false"}"
@@ -533,6 +548,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"
@@ -566,12 +596,14 @@ let
++ optional (autoComplete != null)
"set-option global autocomplete ${concatStringsSep "|" autoComplete}"
++ optional (autoReload != null)
- "set-option global/ autoreload ${autoReload}"
+ "set-option global autoreload ${autoReload}"
++ optional (wrapLines != null && wrapLines.enable)
"add-highlighter global/ wrap${wrapOptions}"
++ optional (numberLines != null && numberLines.enable)
"add-highlighter global/ number-lines${numberLinesOptions}"
++ optional showMatching "add-highlighter global/ show-matching"
+ ++ optional (showWhitespace != null && showWhitespace.enable)
+ "add-highlighter global/ show-whitespaces${showWhitespaceOptions}"
++ optional (scrollOff != null)
"set-option global scrolloff ${toString scrollOff.lines},${
toString scrollOff.columns
@@ -580,7 +612,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"
@@ -605,11 +638,22 @@ in {
<filename>~/.config/kak/kakrc</filename>.
'';
};
+
+ plugins = mkOption {
+ type = with types; listOf package;
+ default = [ ];
+ example = literalExample "[ pkgs.kakounePlugins.kak-fzf ]";
+ description = ''
+ List of kakoune plugins to install. To get a list of
+ supported plugins run:
+ <command>nix-env -f '&lt;nixpkgs&gt;' -qaP -A kakounePlugins</command>.
+ '';
+ };
};
};
config = mkIf cfg.enable {
- home.packages = [ pkgs.kakoune ];
+ home.packages = [ kakouneWithPlugins ];
xdg.configFile."kak/kakrc".source = configFile;
};
}