From 6c6161828d78119c7ddf1b906ed7fda5e48ba16b Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Wed, 10 May 2023 17:01:59 +0300 Subject: [PATCH] feat: keymap updates --- .config/.tmux.conf | 6 +++--- .config/alacritty/alacritty.yml | 2 ++ .config/nvim/lua/casraf/remap.lua | 28 ++++++++++++++++++++-------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.config/.tmux.conf b/.config/.tmux.conf index df3fffae..2df47ad7 100644 --- a/.config/.tmux.conf +++ b/.config/.tmux.conf @@ -20,7 +20,7 @@ bind -n C-M-Down select-pane -D bind -n C-k send-keys -R \; send-keys C-l # Ctrl+Shift+W to close session -bind -n C-S-w confirm-before kill-session +bind -n C-M-w confirm-before kill-session # Enable mouse control set -g mouse on @@ -65,8 +65,8 @@ set -g pane-active-border-style 'bg=colour0 fg=colour9' set -g status-position bottom set -g status-justify left set -g status-style 'bg=colour18 fg=colour137 dim' -set -g status-left 'casraf' -set -g status-right '#[fg=colour233,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S ' +set -g status-left 'casraf ' +set -g status-right '#[fg=colour255,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S ' set -g status-right-length 50 set -g status-left-length 20 diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml index 4cf2b11c..bac91648 100644 --- a/.config/alacritty/alacritty.yml +++ b/.config/alacritty/alacritty.yml @@ -925,6 +925,8 @@ key_bindings: - { chars: "\x02_", key: D, mods: Command|Shift } # Split the current pane into two, top and bottom. - { chars: "\x02|", key: D, mods: Command } + # move to pane above - neovim + # - { chars: "\e\ewk\n", key: Up, mods: Command|Alt } # Type :w to save neovim - { chars: "\e:w\n", key: S, mods: Command } # Type :wa to save all neovim files in nvim window diff --git a/.config/nvim/lua/casraf/remap.lua b/.config/nvim/lua/casraf/remap.lua index 05e23d74..92dd5a88 100644 --- a/.config/nvim/lua/casraf/remap.lua +++ b/.config/nvim/lua/casraf/remap.lua @@ -5,7 +5,7 @@ vim.keymap.set("n", "ps", function() vim.cmd.Ex() end, { desc = "Save and file explorer" }) -vim.keymap.set("n", "q", "c", { desc = "Close pane" }) +vim.keymap.set("n", "Q", "c", { desc = "Close pane" }) vim.keymap.set("v", "J", ":m '>+1gv=gv", { desc = "Move line down" }) vim.keymap.set("v", "K", ":m '<-2gv=gv", { desc = "Move line up" }) @@ -45,7 +45,10 @@ vim.keymap.set("x", "p", [["_dP]], { desc = "Paste over selection, keep vim.keymap.set({ "n", "v" }, "y", [["+y]], { desc = "Yank selection to system clipboard" }) vim.keymap.set("n", "Y", [["+Y]], { desc = "Yank line to system clipboard" }) -- surround with parens --- vim.keymap.set("v", "(", "(\"", { desc = "Surround selection with parens" }) +vim.keymap.set("v", "(", [[:s/\%V\(.*\)\%V/\(\1\)/g]], { desc = "Surround selection with parens" }) +vim.keymap.set("v", "[[", [[:s/\%V\(.*\)\%V/\[\1\]/g]], { desc = "Surround selection with brackets" }) +vim.keymap.set("v", "{", [[:s/\%V\(.*\)\%V/{\1}/g]], { desc = "Surround selection with braces" }) +vim.keymap.set("v", "<", [[:s/\%V\(.*\)\%V/<\1>/g]], { desc = "Surround selection with angle brackets" }) -- comment line vim.keymap.set("n", "/", ":CommentToggle", { desc = "Comment line" }) @@ -58,13 +61,20 @@ vim.keymap.set("i", "", "", { desc = "Exit insert mode" }) -- who needs Q vim.keymap.set("n", "Q", "", { desc = "No Q" }) -vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer", { desc = "New tmux session" }) - -- file formatting -- TODO: move to lsp.lua? -vim.keymap.set("n", "f", vim.lsp.buf.format, { desc = "Format file" }) -vim.keymap.set("n", "df", "silent !dart format --line-length 120 %:p", - { desc = "Format dart file", silent = true }) +vim.keymap.set("n", "f", function() + if vim.bo.filetype == "dart" then + vim.cmd("silent !dart format --line-length 120 %:p") + else + vim.lsp.buf.format() + end +end, { desc = "Format file" }) + +vim.keymap.set("n", "nh", "belowright new", { desc = "New buffer below" }) +vim.keymap.set("n", "nH", "aboveleft new", { desc = "New buffer above" }) +vim.keymap.set("n", "nV", "vnew", { desc = "New buffer left" }) +vim.keymap.set("n", "nv", "belowright vnew", { desc = "New buffer right" }) vim.keymap.set("n", "", "cnextzz", { desc = "Next quickfix" }) vim.keymap.set("n", "", "cprevzz", { desc = "Previous quickfix" }) @@ -76,8 +86,10 @@ vim.keymap.set("n", "s", [[:%s/\<\>//gI< vim.keymap.set("n", "x", "!chmod +x %", { silent = true, desc = "Make file executable" }) vim.keymap.set("n", "X", "!chmod -x %", { silent = true, desc = "Make file not executable" }) -vim.keymap.set("n", "vpp", "e ~/.config/nvim/.dotfiles/nvim/lua/casraf/packer.lua", +vim.keymap.set("n", "vpp", "e ~/.dotfiles/.config/nvim/lua/casraf/packer.lua", { desc = "Edit packer config" }); +vim.keymap.set("n", "vpr", "e ~/.dotfiles/.config/nvim/lua/casraf/remap.lua", + { desc = "Edit remaps" }); vim.keymap.set("n", "mir", "CellularAutomaton make_it_rain", { desc = "Make it rain" }); vim.keymap.set("n", "gol", "CellularAutomaton game_of_life", { desc = "Game of life" });