feat(micro): add option to specify keybindings

Added option to specify custom micro keybindings, all options available can be seen at https://github.com/zyedidia/micro/blob/master/runtime/help/keybindings.md
This commit is contained in:
Yash-Garg 2024-04-17 20:13:23 +05:30
parent fa8c16e245
commit 64b3ffa49c
No known key found for this signature in database
2 changed files with 36 additions and 0 deletions

View File

@ -31,6 +31,26 @@ in {
for supported values.
'';
};
keybinds = mkOption {
type = jsonFormat.type;
default = {
"Alt-/" = "lua:comment.comment";
"CtrlUnderscore" = "lua:comment.comment";
};
example = literalExpression ''
{
"Ctrl-y" = "Undo";
"Ctrl-z" = "Redo";
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/micro/bindings.json`. See
<https://github.com/zyedidia/micro/blob/master/runtime/help/keybindings.md>
for supported values.
'';
};
};
};
@ -39,5 +59,8 @@ in {
xdg.configFile."micro/settings.json".source =
jsonFormat.generate "micro-settings" cfg.settings;
xdg.configFile."micro/bindings.json".source =
jsonFormat.generate "micro-keybinds" cfg.keybinds;
};
}

View File

@ -8,6 +8,11 @@
autosu = false;
cursorline = false;
};
keybinds = {
"Ctrl-y" = "Undo";
"Ctrl-z" = "Redo";
};
};
test.stubs.micro = { };
@ -20,5 +25,13 @@
"cursorline": false
}
''}
assertFileContent home-files/.config/micro/bindings.json \
${builtins.toFile "micro-expected-keybinds.json" ''
{
"Ctrl-y": "Undo",
"Ctrl-z": "Redo"
}
''}
'';
}