summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorAndrey01892024-04-18 09:51:55 +0500
committerAndrey01892024-04-18 09:51:55 +0500
commit07209b572031a01d7a76099c027b9779770840d1 (patch)
treef0a14de53d62677d62f4734ef95164d7e023b62b /nixos
parent4163673d44bf956329cfa59196845f5d264df2b9 (diff)
downloadnixos-config-07209b572031a01d7a76099c027b9779770840d1.tar.gz
nixos-config-07209b572031a01d7a76099c027b9779770840d1.tar.bz2
nixos-config-07209b572031a01d7a76099c027b9779770840d1.zip
Optimizing keymaps
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/nixvim/keymaps.nix71
-rw-r--r--nixos/modules/nixvim/plugins/barbar.nix2
2 files changed, 65 insertions, 8 deletions
diff --git a/nixos/modules/nixvim/keymaps.nix b/nixos/modules/nixvim/keymaps.nix
index e792ea0..080a20d 100644
--- a/nixos/modules/nixvim/keymaps.nix
+++ b/nixos/modules/nixvim/keymaps.nix
@@ -1,15 +1,72 @@
-{
+{ config, lib, ... }: {
programs.nixvim = {
globals = {
mapleader = "\\";
maplocalleader = "\\";
};
- keymaps = [
- {
- key = "<leader>n";
- action = "<cmd>Neotree<CR>";
- }
- ];
+ keymaps = let
+ normal =
+ lib.mapAttrsToList
+ (key: action: {
+ mode = "n";
+ inherit action key;
+ })
+ {
+ # Open Neotree
+ "<leader>n" = ":Neotree<CR>";
+
+ # Esc to clear search results
+ "<esc>" = ":noh<CR>";
+
+ # fix Y behaviour
+ Y = "y$";
+
+ # back and fourth between the two most recent files
+ "<C-c>" = ":b#<CR>";
+
+ # close by Ctrl+x
+ "<C-x>" = ":close<CR>";
+
+ # save by \+s or Ctrl+s
+ "<leader>s" = ":w<CR>";
+ "<C-s>" = ":w<CR>";
+
+ # navigate windows
+ "<leader>h" = "<C-w>h";
+ "<leader>j" = "<C-w>j";
+ "<leader>k" = "<C-w>k";
+ "<leader>l" = "<C-w>l";
+
+ # Press 'H', 'L' to jump to start/end of a line (first/last character)
+ # L = "$";
+ # H = "^";
+
+ # resize with arrows
+ "<C-Up>" = ":resize -2<CR>";
+ "<C-Down>" = ":resize +2<CR>";
+ "<C-Left>" = ":vertical resize +2<CR>";
+ "<C-Right>" = ":vertical resize -2<CR>";
+
+ # move current line up/down
+ # M = Alt key
+ "<M-k>" = ":move-2<CR>";
+ "<M-j>" = ":move+<CR>";
+ };
+ visual =
+ lib.mapAttrsToList
+ (key: action: {
+ mode = "v";
+ inherit action key;
+ })
+ {
+ # move selected line / block of text in visual mode
+ "K" = ":m '<-2<CR>gv=gv";
+ "J" = ":m '>+1<CR>gv=gv";
+ };
+ in
+ config.nixvim.helpers.keymaps.mkKeymaps
+ {options.silent = true;}
+ (normal ++ visual);
};
}
diff --git a/nixos/modules/nixvim/plugins/barbar.nix b/nixos/modules/nixvim/plugins/barbar.nix
index 516ec13..218fc90 100644
--- a/nixos/modules/nixvim/plugins/barbar.nix
+++ b/nixos/modules/nixvim/plugins/barbar.nix
@@ -6,7 +6,7 @@
next = "<TAB>";
previous = "<S-TAB>";
- close = "<C-q>";
+ # close = "<C-q>";
};
};
}