Skip to content

Commit dd6a114

Browse files
committed
plugins/misc: adapt to new maps options
1 parent 574fb73 commit dd6a114

File tree

18 files changed

+262
-193
lines changed

18 files changed

+262
-193
lines changed

plugins/bufferlines/barbar.nix

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ with lib; let
5757
}
5858
// bufferOptions;
5959

60-
keymaps = {
60+
keymapsActions = {
6161
previous = "Previous";
6262
next = "Next";
6363
movePrevious = "MovePrevious";
@@ -227,7 +227,7 @@ in {
227227
optionName: funcName:
228228
helpers.mkNullOrOption types.str "Keymap for function Buffer${funcName}"
229229
)
230-
keymaps
230+
keymapsActions
231231
);
232232
};
233233

@@ -326,28 +326,33 @@ in {
326326
}
327327
// cfg.extraOptions;
328328

329-
userKeymapsList =
330-
mapAttrsToList
329+
keymaps =
330+
flatten
331331
(
332-
optionName: funcName: let
333-
key = cfg.keymaps.${optionName};
334-
in
335-
mkIf (key != null) {
336-
${key} = {
332+
mapAttrsToList
333+
(
334+
optionName: funcName: let
335+
key = cfg.keymaps.${optionName};
336+
in
337+
optional
338+
(key != null)
339+
{
340+
mode = "n";
341+
inherit key;
337342
action = "<Cmd>Buffer${funcName}<CR>";
338-
inherit (cfg.keymaps) silent;
339-
};
340-
}
341-
)
342-
keymaps;
343+
options.silent = cfg.keymaps.silent;
344+
}
345+
)
346+
keymapsActions
347+
);
343348
in
344349
mkIf cfg.enable {
345350
extraPlugins = with pkgs.vimPlugins; [
346351
cfg.package
347352
nvim-web-devicons
348353
];
349354

350-
maps.normal = mkMerge userKeymapsList;
355+
inherit keymaps;
351356

352357
extraConfigLua = ''
353358
require('barbar').setup(${helpers.toLuaObject setupOptions})

plugins/languages/julia/julia-cell.nix

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,19 @@ in
9393
// cfg.extraConfig
9494
);
9595

96-
maps.normal = mkMerge (
96+
keymaps = flatten (
9797
mapAttrsToList
9898
(
9999
name: value: let
100100
key = cfg.keymaps.${name};
101101
in
102-
if key == null
103-
then {}
104-
else {
105-
${key} = {
106-
action = ":JuliaCell${value.cmd}<CR>";
107-
inherit (cfg.keymaps) silent;
108-
};
102+
optional
103+
(key != null)
104+
{
105+
mode = "n";
106+
inherit key;
107+
action = ":JuliaCell${value.cmd}<CR>";
108+
options.silent = cfg.keymaps.silent;
109109
}
110110
)
111111
mappings

plugins/languages/typst/typst-vim.nix

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,20 @@ in {
3434
# Add the typst compiler to nixvim packages
3535
extraPackages = with pkgs; [typst];
3636

37-
maps.normal = with cfg.keymaps;
38-
helpers.mkModeMaps {inherit silent;} {
39-
${watch} = ":TypstWatch<CR>";
40-
};
37+
keymaps = with cfg.keymaps;
38+
helpers.mkKeymaps
39+
{
40+
mode = "n";
41+
options.silent = silent;
42+
}
43+
(
44+
optional
45+
(watch != null)
46+
{
47+
# mode = "n";
48+
key = watch;
49+
action = ":TypstWatch<CR>";
50+
}
51+
);
4152
};
4253
}

plugins/lsp/default.nix

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,30 +110,35 @@ in {
110110
mkIf cfg.enable {
111111
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
112112

113-
maps.normal = let
113+
keymaps = let
114114
mkMaps = prefix:
115-
mapAttrs
116-
(key: action: let
117-
actionStr =
118-
if isString action
119-
then action
120-
else action.action;
121-
actionProps =
122-
if isString action
123-
then {}
124-
else filterAttrs (n: v: n != "action") action;
125-
in
126-
{
127-
inherit (cfg.keymaps) silent;
115+
mapAttrsToList
116+
(
117+
key: action: let
118+
actionStr =
119+
if isString action
120+
then action
121+
else action.action;
122+
actionProps =
123+
if isString action
124+
then {}
125+
else filterAttrs (n: v: n != "action") action;
126+
in {
127+
mode = "n";
128+
inherit key;
128129
action = prefix + actionStr;
129130
lua = true;
131+
132+
options =
133+
{
134+
inherit (cfg.keymaps) silent;
135+
}
136+
// actionProps;
130137
}
131-
// actionProps);
138+
);
132139
in
133-
mkMerge [
134-
(mkMaps "vim.diagnostic." cfg.keymaps.diagnostic)
135-
(mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf)
136-
];
140+
(mkMaps "vim.diagnostic." cfg.keymaps.diagnostic)
141+
++ (mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf);
137142

138143
# Enable all LSP servers
139144
extraConfigLua = ''

plugins/telescope/default.nix

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,31 @@ in {
8383
let $BAT_THEME = '${cfg.highlightTheme}'
8484
'';
8585

86-
maps.normal =
87-
mapAttrs
88-
(key: action: let
89-
actionStr =
90-
if isString action
91-
then action
92-
else action.action;
93-
actionProps =
94-
if isString action
95-
then {}
96-
else filterAttrs (n: v: n != "action") action;
97-
in
98-
{
99-
silent = cfg.keymapsSilent;
86+
keymaps =
87+
mapAttrsToList
88+
(
89+
key: action: let
90+
actionStr =
91+
if isString action
92+
then action
93+
else action.action;
94+
actionProps =
95+
if isString action
96+
then {}
97+
else filterAttrs (n: v: n != "action") action;
98+
in {
99+
mode = "n";
100+
inherit key;
100101
action = "require('telescope.builtin').${actionStr}";
101102
lua = true;
103+
104+
options =
105+
{
106+
silent = cfg.keymapsSilent;
107+
}
108+
// actionProps;
102109
}
103-
// actionProps)
110+
)
104111
cfg.keymaps;
105112

106113
extraConfigLua = let

plugins/utils/auto-save.nix

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,14 @@ in {
142142
require('auto-save').setup(${helpers.toLuaObject options})
143143
'';
144144

145-
maps.normal = with cfg.keymaps; let
146-
inherit (cfg.keymaps) silent;
147-
in
148-
mkMerge [
149-
(mkIf (toggle != null) {
150-
${toggle} = {
151-
action = ":ASToggle<CR>";
152-
inherit silent;
153-
};
154-
})
155-
];
145+
keymaps = with cfg.keymaps;
146+
optional
147+
(toggle != null)
148+
{
149+
mode = "n";
150+
key = toggle;
151+
action = ":ASToggle<CR>";
152+
options.silent = cfg.keymaps.silent;
153+
};
156154
};
157155
}

plugins/utils/coverage.nix

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,24 @@ in {
299299
require("coverage").setup(${helpers.toLuaObject setupOptions})
300300
'';
301301

302-
maps.normal = mkMerge (
303-
mapAttrsToList
302+
keymaps =
303+
flatten
304304
(
305-
optionName: properties: let
306-
key = cfg.keymaps.${optionName};
307-
in
308-
mkIf (key != null)
309-
{
310-
${key} = {
305+
mapAttrsToList
306+
(
307+
optionName: properties: let
308+
key = cfg.keymaps.${optionName};
309+
in
310+
optional
311+
(key != null)
312+
{
313+
mode = "n";
314+
inherit key;
311315
action = ":Coverage${properties.command}<CR>";
312-
silent = cfg.keymapsSilent;
313-
};
314-
}
315-
)
316-
keymapsDef
317-
);
316+
options.silent = cfg.keymapsSilent;
317+
}
318+
)
319+
keymapsDef
320+
);
318321
};
319322
}

plugins/utils/harpoon.nix

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,20 @@ in {
187187
require('harpoon').setup(${helpers.toLuaObject options})
188188
'';
189189

190-
maps.normal = let
191-
silent = cfg.keymapsSilent;
190+
keymaps = let
192191
km = cfg.keymaps;
193192

194-
simpleMappings = mkMerge (
193+
simpleMappings = flatten (
195194
mapAttrsToList
196195
(
197196
optionName: luaFunc: let
198197
key = km.${optionName};
199198
in
200-
mkIf (key != null) {
201-
${key} = {
202-
action = luaFunc;
203-
lua = true;
204-
inherit silent;
205-
};
199+
optional
200+
(key != null)
201+
{
202+
inherit key;
203+
action = luaFunc;
206204
}
207205
)
208206
{
@@ -217,38 +215,44 @@ in {
217215
mkNavMappings = name: genLuaFunc: let
218216
mappingsAttrs = km.${name};
219217
in
220-
mkIf
221-
(mappingsAttrs != null)
218+
flatten
222219
(
223-
mapAttrs'
224-
(id: key: {
225-
name = key;
226-
value = {
220+
optionals
221+
(mappingsAttrs != null)
222+
(
223+
mapAttrsToList
224+
(id: key: {
225+
inherit key;
227226
action = genLuaFunc id;
228-
lua = true;
229-
inherit silent;
230-
};
231-
})
232-
mappingsAttrs
227+
})
228+
mappingsAttrs
229+
)
233230
);
234-
in
235-
mkMerge [
231+
232+
allMappings =
236233
simpleMappings
237-
(
234+
++ (
238235
mkNavMappings
239236
"navFile"
240237
(id: "function() require('harpoon.ui').nav_file(${id}) end")
241238
)
242-
(
239+
++ (
243240
mkNavMappings
244241
"gotoTerminal"
245242
(id: "function() require('harpoon.term').gotoTerminal(${id}) end")
246243
)
247-
(
244+
++ (
248245
mkNavMappings
249246
"tmuxGotoTerminal"
250247
(id: "function() require('harpoon.tmux').gotoTerminal(${id}) end")
251-
)
252-
];
248+
);
249+
in
250+
helpers.mkKeymaps
251+
{
252+
mode = "n";
253+
lua = true;
254+
options.silent = cfg.keymapsSilent;
255+
}
256+
allMappings;
253257
};
254258
}

plugins/utils/intellitab.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ in {
1919
config = mkIf cfg.enable {
2020
extraPlugins = [cfg.package];
2121

22-
maps.insert."<Tab>" = "<CMD>lua require([[intellitab]]).indent()<CR>";
22+
keymaps = [
23+
{
24+
mode = "i";
25+
key = "<Tab>";
26+
action = "require('intellitab').indent";
27+
lua = true;
28+
}
29+
];
2330
plugins.treesitter = {
2431
indent = true;
2532
};

0 commit comments

Comments
 (0)