plugins/mkdnflow: properly handle old mappings
Migrate user's with old mappings to new format and warn about change.
This commit is contained in:
parent
6acc964664
commit
e49b8deda7
2 changed files with 174 additions and 118 deletions
|
|
@ -8,6 +8,42 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
|
||||
maintainers = [ lib.maintainers.khaneliman ];
|
||||
|
||||
settingsOptions = {
|
||||
mappings = lib.nixvim.mkNullOrOption' {
|
||||
type = with lib.types; attrsOf anything;
|
||||
description = ''
|
||||
Key mappings for mkdnflow commands.
|
||||
|
||||
Use the generated positional format for mapping entries:
|
||||
- `false` to disable a command mapping.
|
||||
- `[modes key]`, where `modes` is a string or list of mode strings.
|
||||
'';
|
||||
apply = lib.mapNullable (
|
||||
mappings:
|
||||
let
|
||||
isLegacyMapping = mapping: lib.isAttrs mapping && mapping ? modes && mapping ? key;
|
||||
|
||||
legacyMappings = lib.filterAttrs (_: isLegacyMapping) mappings;
|
||||
|
||||
normalizedMappings =
|
||||
mappings
|
||||
// lib.mapAttrs (_: mapping: [
|
||||
mapping.modes
|
||||
mapping.key
|
||||
]) legacyMappings;
|
||||
in
|
||||
# TODO: Added 2026-02-11, remove after 27.05
|
||||
lib.warnIf (legacyMappings != { }) ''
|
||||
Nixvim (plugins.mkdnflow): Setting `plugins.mkdnflow.settings.mappings.<name> = { modes = ...; key = ...; }` is deprecated.
|
||||
Use `plugins.mkdnflow.settings.mappings.<name> = [ <modes> <key> ];` instead.
|
||||
Example:
|
||||
`MkdnEnter = [ [ "n" "i" ] "<CR>" ];`
|
||||
Legacy mappings in this definition: ${lib.concatStringsSep ", " (lib.attrNames legacyMappings)}
|
||||
'' normalizedMappings
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
modules = {
|
||||
bib = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue