@@ -59,8 +59,16 @@ let moveMarkers = (~newBuffer, ~markerUpdate, model) => {
59
59
60
60
// MSG
61
61
62
+ [@ deriving show]
63
+ type command =
64
+ | MoveSelectionUpward
65
+ | MoveSelectionDownward
66
+ | CopySelectionUpward
67
+ | CopySelectionDownward ;
68
+
62
69
[@ deriving show]
63
70
type msg =
71
+ | Command (command )
64
72
| ModeChanged ({
65
73
allowAnimation: bool ,
66
74
mode: [@ opaque ] Vim . Mode . t ,
@@ -158,6 +166,10 @@ module Effects = {
158
166
159
167
let update = (msg, model: model ) => {
160
168
switch (msg) {
169
+ | Command (command ) =>
170
+ prerr_endline("COMMAND: " ++ show_command(command));
171
+ failwith ("Done" );
172
+
161
173
| ModeChanged ({allowAnimation, mode, effects, subMode}) => (
162
174
{... model, subMode} |> handleEffects(effects),
163
175
ModeDidChange ({allowAnimation, mode, effects}),
@@ -263,6 +275,46 @@ let sub = (~buffer, ~topVisibleLine, ~bottomVisibleLine, model) => {
263
275
|> Option . value(~default= Isolinear . Sub . none);
264
276
};
265
277
278
+ module Commands = {
279
+ open Feature_Commands . Schema ;
280
+
281
+ let moveLinesDown =
282
+ define(
283
+ ~category= "Editor" ,
284
+ ~title= "Move lines down" ,
285
+ "editor.action.moveLinesDownAction" ,
286
+ Command (MoveSelectionDownward ),
287
+ );
288
+
289
+ let moveLinesDown =
290
+ define(
291
+ ~title= "Move Line Down" ,
292
+ "editor.action.moveLinesDownAction" ,
293
+ Command (MoveSelectionDownward ),
294
+ );
295
+
296
+ let moveLinesUp =
297
+ define(
298
+ ~title= "Move Line Up" ,
299
+ "editor.action.moveLinesUpAction" ,
300
+ Command (MoveSelectionUpward ),
301
+ );
302
+
303
+ let copyLinesDown =
304
+ define(
305
+ ~category= "Copy Line Down" ,
306
+ "editor.action.copyLinesDownAction" ,
307
+ Command (CopySelectionDownward ),
308
+ );
309
+
310
+ let copyLinesUp =
311
+ define(
312
+ ~category= "Copy Line Up" ,
313
+ "editor.action.copyLinesUpAction" ,
314
+ Command (CopySelectionUpward ),
315
+ );
316
+ };
317
+
266
318
module Keybindings = {
267
319
open Feature_Input . Schema ;
268
320
let controlSquareBracketRemap =
@@ -272,10 +324,86 @@ module Keybindings = {
272
324
~toKeys= "<ESC>" ,
273
325
~condition= WhenExpr . Value (True ),
274
326
);
327
+
328
+ let editCondition =
329
+ WhenExpr . parse(
330
+ "normalMode || visualMode || insertMode && editorTextFocus" ,
331
+ );
332
+
333
+ let moveLineDownwardJ =
334
+ bind(
335
+ ~key= "<A-j>" ,
336
+ ~command= Commands . moveLinesDown. id,
337
+ ~condition= editCondition,
338
+ );
339
+
340
+ let moveLineDownwardArrow =
341
+ bind(
342
+ ~key= "<A-Down>" ,
343
+ ~command= Commands . moveLinesDown. id,
344
+ ~condition= editCondition,
345
+ );
346
+
347
+ let moveLineUpwardK =
348
+ bind(
349
+ ~key= "<A-k>" ,
350
+ ~command= Commands . moveLinesUp. id,
351
+ ~condition= editCondition,
352
+ );
353
+
354
+ let moveLineUpwardArrow =
355
+ bind(
356
+ ~key= "<A-Up>" ,
357
+ ~command= Commands . moveLinesUp. id,
358
+ ~condition= editCondition,
359
+ );
360
+
361
+ let copyLineDownwardJ =
362
+ bind(
363
+ ~key= "<A-S-j>" ,
364
+ ~command= Commands . copyLinesDown. id,
365
+ ~condition= editCondition,
366
+ );
367
+
368
+ let copyLineDownwardArrow =
369
+ bind(
370
+ ~key= "<A-S-Down>" ,
371
+ ~command= Commands . copyLinesDown. id,
372
+ ~condition= editCondition,
373
+ );
374
+
375
+ let copyLineUpwardK =
376
+ bind(
377
+ ~key= "<A-S-k>" ,
378
+ ~command= Commands . copyLinesUp. id,
379
+ ~condition= editCondition,
380
+ );
381
+
382
+ let copyLineUpwardArrow =
383
+ bind(
384
+ ~key= "<A-S-Up>" ,
385
+ ~command= Commands . copyLinesUp. id,
386
+ ~condition= editCondition,
387
+ );
275
388
};
276
389
277
390
module Contributions = {
278
- let keybindings = Keybindings . [ controlSquareBracketRemap] ;
391
+ let commands =
392
+ Commands . [ moveLinesDown, moveLinesUp, copyLinesDown, copyLinesUp] ;
393
+ let keybindings =
394
+ Keybindings . [
395
+ // Remaps
396
+ controlSquareBracketRemap,
397
+ // Bindings
398
+ moveLineDownwardJ,
399
+ moveLineDownwardArrow,
400
+ moveLineUpwardK,
401
+ moveLineUpwardArrow,
402
+ copyLineDownwardJ,
403
+ copyLineDownwardArrow,
404
+ copyLineUpwardArrow,
405
+ copyLineUpwardK,
406
+ ] ;
279
407
280
408
let configuration = Configuration . [ experimentalViml. spec] ;
281
409
};
0 commit comments