From c3f591927ca9a844fd01bfa15c82825e69eb6d3e Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 4 Mar 2024 15:24:13 +0530 Subject: [PATCH] add keymaps --- config/keymaps.nix | 380 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 380 insertions(+) diff --git a/config/keymaps.nix b/config/keymaps.nix index 9cb2520..4beb4cb 100644 --- a/config/keymaps.nix +++ b/config/keymaps.nix @@ -1,3 +1,4 @@ + { globals.mapleader = " "; @@ -13,5 +14,384 @@ key = "s"; action = "+search"; } + { + mode = "n"; + key = "q"; + action = "+quit/session"; + } + { + mode = ["n" "v"]; + key = "g"; + action = "+git"; + } + { + mode = "n"; + key = "u"; + action = "+ui"; + } + { + mode = "n"; + key = "w"; + action = "+windows"; + } + { + mode = "n"; + key = ""; + action = "+tab"; + } + { + mode = ["n" "v"]; + key = "d"; + action = "+debug"; + } + { + mode = ["n" "v"]; + key = "c"; + action = "+code"; + } + { + mode = ["n" "v"]; + key = "t"; + action = "+test"; + } + + # Tabs + { + mode = "n"; + key = "l"; + action = "tablast"; + options = { + silent = true; + desc = "Last tab"; + }; + } + { + mode = "n"; + key = "f"; + action = "tabfirst"; + options = { + silent = true; + desc = "First Tab"; + }; + } + { + mode = "n"; + key = ""; + action = "tabnew"; + options = { + silent = true; + desc = "New Tab"; + }; + } + { + mode = "n"; + key = "]"; + action = "tabnext"; + options = { + silent = true; + desc = "Next Tab"; + }; + } + { + mode = "n"; + key = "d"; + action = "tabclose"; + options = { + silent = true; + desc = "Close Tab"; + }; + } + { + mode = "n"; + key = "["; + action = "tabprevious"; + options = { + silent = true; + desc = "Previous Tab"; + }; + } + + # Windows + { + mode = "n"; + key = "ww"; + action = "p"; + options = { + silent = true; + desc = "Other window"; + }; + } + { + mode = "n"; + key = "wd"; + action = "c"; + options = { + silent = true; + desc = "Delete window"; + }; + } + { + mode = "n"; + key = "w-"; + action = "s"; + options = { + silent = true; + desc = "Split window below"; + }; + } + { + mode = "n"; + key = "w|"; + action = "v"; + options = { + silent = true; + desc = "Split window right"; + }; + } + { + mode = "n"; + key = ""; + action = "w"; + options = { + silent = true; + desc = "Save file"; + }; + } + + # Session + { + mode = "n"; + key = "qq"; + action = "quitall"; + options = { + silent = true; + desc = "Quit all"; + }; + } + { + mode = "n"; + key = "qs"; + action = ":lua require('persistence').load()"; + options = { + silent = true; + desc = "Restore session"; + }; + } + { + mode = "n"; + key = "ql"; + action = "lua require('persistence').load({ last = true })"; + options = { + silent = true; + desc = "Restore last session"; + }; + } + { + mode = "n"; + key = "qd"; + action = "lua require('persistence').stop()"; + options = { + silent = true; + desc = "Don't save current session"; + }; + } + { + mode = "n"; + key = "ul"; + action = ":lua ToggleLineNumber()"; + options = { + silent = true; + desc = "Toggle line number"; + }; + } + { + mode = "n"; + key = "uL"; + action = ":lua ToggleRelativeLineNumber()"; + options = { + silent = true; + desc = "Toggle relative line number"; + }; + } + { + mode = "n"; + key = "uw"; + action = ":lua ToggleWrap()"; + options = { + silent = true; + desc = "Toggle line wrap"; + }; + } + { + mode = "n"; + key = "J"; + action = ":m '>+1gv=gv"; + options = { + silent = true; + desc = "Move up when line is highlighted"; + }; + } + { + mode = "n"; + key = "K"; + action = ":m '<-2gv=gv"; + options = { + silent = true; + desc = "Move down when line is highlighted"; + }; + } + { + mode = "n"; + key = "J"; + action = "mzJ`z"; + options = { + search = true; + desc = "Allow cursor to stay in the same place after appending to current line"; + }; + } + { + mode = "n"; + key = "<"; + action = "+y or just y to have it just in vim + { + mode = ["n" "v"]; + key = "y"; + action = "\"+y"; + options = { + desc = "Copy to sysem clipboard"; + }; + } + { + mode = ["n" "v"]; + key = "Y"; + action = "\"+Y"; + options = { + desc = "Copy to system clipboard"; + }; + } + + # Delete to void register + { + mode = ["n" "v"]; + key = "D"; + action = "\"_d"; + options = { + desc = "Delete to void register"; + }; + } + { + mode = "n"; + key = ""; + action = "!tmux new tmux-sessionizer"; + options = { + desc = "Switch between projects"; + }; + } ]; + + extraConfigLua = '' + local notify = require("notify") + + local function show_notification(message, level) + notify(message, level, { title = "conform.nvim" }) + end + + function ToggleLineNumber() + if vim.wo.number then + vim.wo.number = false + show_notification("Line number disabled", "info") + else + vim.wo.number = true + show_notification("Line number enabled", "info") + end + end + + function ToggleRelativeLineNumber() + if vim.wo.relativenumber then + vim.wo.relativenumber = false + show_notification("Relative line number disabled", "info") + else + vim.wo.relativenumber = true + show_notification("Relative line number enabled", "info") + end + end + + function ToggleWrap() + if vim.wo.wrap then + vim.wo.wrap = false + show_notification("Wrap disabled", "info") + else + vim.wo.wrap = true + show_notification("Wrap enabled", "info") + end + end + + if vim.lsp.inlay_hint then + vim.keymap.set('n', 'uh', function() + vim.lsp.inlay_hint(0, nil) + end, { desc = 'Toggle inlay hints' }) + end + ''; }