mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-02-04 02:45:53 +00:00
modules: move mappings to neovim/init
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I9b04107496df27dcda1a24ce000da3f46a6a6964
This commit is contained in:
parent
91269c56c5
commit
f8f1017411
6 changed files with 149 additions and 131 deletions
|
|
@ -10,7 +10,6 @@
|
|||
# such as spellchecking, mappings, and the init script (init.vim).
|
||||
neovim = map (p: ./neovim + "/${p}") [
|
||||
"init"
|
||||
"mappings"
|
||||
];
|
||||
|
||||
# Individual plugin modules, separated by the type of plugin.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
./filetype.nix
|
||||
./highlight.nix
|
||||
./lsp.nix
|
||||
./mappings.nix
|
||||
./spellcheck.nix
|
||||
./util.nix
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,19 +1,31 @@
|
|||
{lib, ...}: let
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkMerge;
|
||||
inherit (lib.options) mkOption literalMD;
|
||||
inherit (lib.types) either str listOf attrsOf nullOr submodule;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.lists) flatten;
|
||||
inherit (lib.trivial) pipe;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
mapConfigOptions = {
|
||||
desc = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
||||
description = ''
|
||||
Description for the keybind, to be shown in which-key, if you have enabled
|
||||
in the module system.
|
||||
'';
|
||||
};
|
||||
|
||||
action = mkOption {
|
||||
type = str;
|
||||
description = "The command to execute.";
|
||||
};
|
||||
|
||||
lua = mkBool false ''
|
||||
If true, `action` is considered to be lua code.
|
||||
Thus, it will not be wrapped in `""`.
|
||||
|
|
@ -55,6 +67,22 @@
|
|||
});
|
||||
default = {};
|
||||
};
|
||||
|
||||
legacyMapModes = {
|
||||
normal = ["n"];
|
||||
insert = ["i"];
|
||||
select = ["s"];
|
||||
visual = ["v"];
|
||||
terminal = ["t"];
|
||||
normalVisualOp = ["n" "v" "o"];
|
||||
visualOnly = ["n" "x"];
|
||||
operator = ["o"];
|
||||
insertCommand = ["i" "c"];
|
||||
lang = ["l"];
|
||||
command = ["c"];
|
||||
};
|
||||
|
||||
cfg = config.vim;
|
||||
in {
|
||||
options.vim = {
|
||||
keymaps = mkOption {
|
||||
|
|
@ -94,4 +122,27 @@ in {
|
|||
command = legacyMapOption "command-line";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
vim.keymaps = mkMerge [
|
||||
(
|
||||
pipe cfg.maps
|
||||
[
|
||||
(mapAttrsToList (
|
||||
oldMode: keybinds:
|
||||
mapAttrsToList (
|
||||
key: bind:
|
||||
bind
|
||||
// {
|
||||
inherit key;
|
||||
mode = legacyMapModes.${oldMode};
|
||||
}
|
||||
)
|
||||
keybinds
|
||||
))
|
||||
flatten
|
||||
]
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -3,11 +3,6 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkMerge;
|
||||
inherit (lib.trivial) pipe;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.lists) flatten;
|
||||
|
||||
legacyMapModes = {
|
||||
normal = ["n"];
|
||||
insert = ["i"];
|
||||
|
|
@ -24,26 +19,4 @@
|
|||
|
||||
cfg = config.vim;
|
||||
in {
|
||||
config = {
|
||||
vim.keymaps = mkMerge [
|
||||
(
|
||||
pipe cfg.maps
|
||||
[
|
||||
(mapAttrsToList (
|
||||
oldMode: keybinds:
|
||||
mapAttrsToList (
|
||||
key: bind:
|
||||
bind
|
||||
// {
|
||||
inherit key;
|
||||
mode = legacyMapModes.${oldMode};
|
||||
}
|
||||
)
|
||||
keybinds
|
||||
))
|
||||
flatten
|
||||
]
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./options.nix
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue