aboutsummaryrefslogtreecommitdiffstats
path: root/home-manager/soispha/config/neovim/nixvim/mappings
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-08-03 21:34:16 +0200
committerSoispha <soispha@vhack.eu>2023-08-19 17:34:47 +0200
commitbe1cc38bdb83e6716b08d24cc1201fffc6649311 (patch)
treec3691569e0e8858b672b501096b6cb5edd39daf6 /home-manager/soispha/config/neovim/nixvim/mappings
parentFeat(treewide): Import nixVim (diff)
downloadnixos-config-be1cc38bdb83e6716b08d24cc1201fffc6649311.zip
Feat(hm/conf/nvim): Add basic nix config [REBASE TARGET]
Diffstat (limited to 'home-manager/soispha/config/neovim/nixvim/mappings')
-rw-r--r--home-manager/soispha/config/neovim/nixvim/mappings/default.nix161
1 files changed, 161 insertions, 0 deletions
diff --git a/home-manager/soispha/config/neovim/nixvim/mappings/default.nix b/home-manager/soispha/config/neovim/nixvim/mappings/default.nix
new file mode 100644
index 00000000..237319a0
--- /dev/null
+++ b/home-manager/soispha/config/neovim/nixvim/mappings/default.nix
@@ -0,0 +1,161 @@
+{lib, ...}: {
+ programs.nixvim = {
+ globals = {
+ mapleader = " ";
+ maplocalleader = " ";
+ };
+ maps = let
+ normal_and_insert = {
+ "<Esc>" = {
+ action = "'<cmd>noh<CR><Esc>'";
+ desc = "Disable the search highlighting and send Escape";
+ };
+ };
+ in {
+ insert =
+ lib.recursiveUpate {
+ "hh" = {
+ action = ''
+ function()
+ local cmp = require('cmp');
+ local luasnip = require('luasnip');
+
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif luasnip.expand_or_locally_jumpable() then
+ luasnip.expand_or_jump()
+ end
+ end
+ '';
+ desc = "completion trigger/ forward in completen menu";
+ };
+ "<S-Tab>" = {
+ action = ''
+ function()
+ local cmp = require('cmp');
+ cmp.confirm()
+ end
+ '';
+ desc = "confirm the selected item";
+ };
+ }
+ normal_and_insert;
+ normalVisualOp = {
+ # yank/ cut to the system clipboard
+ "<leader>y" = "'\"+y'";
+ "<leader>Y" = "'\"+Y'";
+
+ # Unmap some old keys
+ #"s" = "'<Nop>'";
+ #"t" = "'<Nop>'";
+ "<Up>" = "'<Nop>'";
+ "<Down>" = "'<Nop>'";
+ "<Left>" = "'<Nop>'";
+ "<Right>" = "'<Nop>'";
+
+ # remap dvorak
+ "l" = "n";
+ "L" = "N";
+ "k" = "t";
+ "K" = "T";
+ "j" = "k";
+ "J" = "K";
+
+ # Change Vim-keys
+ "h" = "<left>";
+ "t" = "g<down>";
+ "n" = "g<up>";
+ "s" = "<right>";
+
+ # Move display lines
+ "0" = "g0";
+ "$" = "g$";
+ };
+ normal =
+ lib.recursiveUpdate {
+ "<Tab>" = {
+ action = "':'";
+ desc = "jump to command line";
+ };
+
+
+ # Splits
+ "<C-t>" = {
+ action = "'<C-w>p'";
+ desc = "go to previous split";
+ };
+ "<C-n>" = {
+ action = "'<C-w>w'";
+ desc = "go to next split";
+ };
+ "<leader>-" = {
+ action = "'<C-W>s'";
+ desc = "New horizontal split";
+ };
+ "<leader>|" = {
+ action = "'<C-W>v'";
+ desc = "New vertical split";
+ };
+
+ # Exit insert mode after creating a new line above or below the current line.";
+ "o" = "'o<Esc>'";
+ "O" = "'O<Esc>'";
+
+ # Center the cursor vertically when moving to the next word during a search.
+ "n" = "'nzzzv'";
+ #"N" = "'Nzzzv'";
+
+ "<leader>p" = {
+ action = "'\"_dP'";
+ desc = "keep the cut thing in the base register";
+ };
+
+ "<leader>d" = {
+ action = "'\"_d'";
+ desc = "delete without saving to register";
+ };
+ "dd" = {
+ action = ''
+ function()
+ if vim.api.nvim_get_current_line():match("^%s*$") then
+ return '"_dd'
+ else
+ return "dd"
+ end
+ end
+ '';
+ desc = "Pipe all blank line deletions to the blackhole register";
+ expr = true;
+ silent = true;
+ };
+
+ "<leader>s" = {
+ action = "':%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>'";
+ desc = "replace for the word under the cursor";
+ };
+
+ "<C-s>" = {
+ action = "'<cmd>mksession! <CR>'";
+ desc = "to overwrite/create a session";
+ };
+
+ "<leader>X" = {
+ action = "'[[!!$SHELL <cr>]]'";
+ desc = "Read the current line and execute that line in your $SHELL. The resulting output will replace the curent line that was being executed.";
+ };
+ }
+ normal_and_insert;
+ terminal = {
+ "<Esc><Esc>" = {
+ action = "'<C-\\><C-n>'";
+ desc = "Exit terminal mode with <Esc><Esc>";
+ };
+ };
+ visual = {
+ # move selected lines in visual mode
+ "T" = "':m '>+1<CR>gv=gv'";
+ "N" = "':m '<-2<CR>gv=gv'";
+ };
+ };
+ };
+}