From 78b6ac9edf5dcf186f8bb9464496e6e7d77fcf3f Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Fri, 17 Jul 2026 08:35:01 +0200 Subject: [PATCH] feat: improve keybinds for snacks --- nvim/lua/keybinds.lua | 4 - nvim/lua/plugins/snacks/keys/keys.lua | 556 ++++++++++++++------------ nvim/lua/wins.lua | 4 +- 3 files changed, 292 insertions(+), 272 deletions(-) diff --git a/nvim/lua/keybinds.lua b/nvim/lua/keybinds.lua index fdcf7c4..c99ef8b 100755 --- a/nvim/lua/keybinds.lua +++ b/nvim/lua/keybinds.lua @@ -60,10 +60,6 @@ keymap.set("n", "e", ":vertical resize 40", opts("Reset sizi -- nohlsearch keymap.set("n", "h", ":nohlsearch", opts("remove search highlighting")) --- run file -keymap.set("n", "r", ":!%:p", opts("run current file")) -keymap.set("n", "r", ":!%:p", opts("run current file with arguments")) - -- chmod +x keymap.set("n", "x", ":!chmod +x %:p", opts("make current file executable")) diff --git a/nvim/lua/plugins/snacks/keys/keys.lua b/nvim/lua/plugins/snacks/keys/keys.lua index dc00751..daea09c 100644 --- a/nvim/lua/plugins/snacks/keys/keys.lua +++ b/nvim/lua/plugins/snacks/keys/keys.lua @@ -1,268 +1,292 @@ return { - -- Git - { - "gl", - function() - Snacks.lazygit() - end, - desc = "Open LazyGit", - mode = "n", - }, - { - "gb", - function() - Snacks.git.blame_line() - end, - desc = "Open Git Blame for this line", - mode = "n", - }, - -- Colours - { - "fcs", - function() - Snacks.picker.colorschemes() - end, - desc = "Show color schemes", - mode = "n", - }, - { - "fco", - function() - Snacks.picker.highlights({ pattern = "hl_group:^Snacks" }) - end, - desc = "Show Snacks highlights", - mode = "n", - }, - { - "fca", - function() - Snacks.picker.highlights() - end, - desc = "Show highlight groups", - mode = "n", - }, - { - "fci", - function() - Snacks.picker.icons() - end, - desc = "Show icons", - mode = "n", - }, - -- Terminal - { - "t", - function() - Snacks.terminal() - end, - desc = "Open terminal", - }, - -- Tree - { - "E", - function() - Snacks.explorer() - end, - desc = "Open File Tree", - mode = "n", - }, - -- Pickers - { - "ff", - function() - Snacks.picker.files() - end, - desc = "Find file", - mode = "n", - }, - { - "fg", - function() - Snacks.picker.grep() - end, - desc = "Find file content using grep", - mode = "n", - }, - { - "fb", - function() - Snacks.picker.buffers() - end, - desc = "Show all buffers", - mode = "n", - }, - { - "fch", - function() - Snacks.picker.command_history() - end, - desc = "Show command history", - mode = "n", - }, - { - "fd", - function() - Snacks.picker.diagnostics() - end, - desc = "Show diagnostics", - mode = "n", - }, - { - "fm", - function() - Snacks.picker.git_diff() - end, - desc = "Show uncommitted diffs", - mode = "n", - }, - { - "fh", - function() - Snacks.picker.help() - end, - desc = "Show nvim help pages", - mode = "n", - }, - { - "fj", - function() - Snacks.picker.jumps() - end, - desc = "Show available jumps", - mode = "n", - }, - { - "fk", - function() - Snacks.picker.keymaps() - end, - desc = "Show keymaps", - mode = "n", - }, - { - "flc", - function() - Snacks.picker.lsp_config() - end, - desc = "Show LSP configs", - mode = "n", - }, - { - "gd", - function() - Snacks.picker.lsp_definitions() - end, - desc = "Goto definitions", - mode = "n", - }, - { - "gi", - function() - Snacks.picker.lsp_implementations() - end, - desc = "Goto implementations", - mode = "n", - }, - { - "gR", - function() - Snacks.picker.lsp_references() - end, - desc = "Goto references", - mode = "n", - }, - { - "gD", - function() - Snacks.picker.lsp_declarations() - end, - desc = "Goto declaration", - mode = "n", - }, - { - "gy", - function() - Snacks.picker.lsp_type_definitions() - end, - desc = "Goto T[y]pe Definition", - }, - { - "gai", - function() - Snacks.picker.lsp_incoming_calls() - end, - desc = "C[a]lls Incoming", - }, - { - "gao", - function() - Snacks.picker.lsp_outgoing_calls() - end, - desc = "C[a]lls Outgoing", - }, - { - "gs", - function() - Snacks.picker.lsp_symbols() - end, - desc = "Show LSP symbols", - mode = "n", - }, - { - "fn", - function() - Snacks.picker.noice() - end, - desc = "Show notifications", - mode = "n", - }, - { - "fp", - function() - Snacks.picker.projects() - end, - desc = "Show recent projects", - mode = "n", - }, - { - "fr", - function() - Snacks.picker.recent() - end, - desc = "Show recent files", - mode = "n", - }, - { - "fs", - function() - Snacks.picker.spelling() - end, - desc = "Show spelling suggestions", - mode = "n", - }, - { - "z=", - function() - Snacks.picker.spelling() - end, - desc = "Show spelling suggestions", - mode = "n", - }, - { - "fo", - function() - Snacks.picker.treesitter() - end, - desc = "Show treesitter details", - mode = "n", - }, - -- Close buffer - { - "", - function() - Snacks.bufdelete() - end, - desc = "Close buffer", - mode = "n", - }, + -- Git + { + "gl", + function() + Snacks.lazygit() + end, + desc = "Open LazyGit", + mode = "n", + }, + { + "gb", + function() + Snacks.git.blame_line() + end, + desc = "Open Git Blame for this line", + mode = "n", + }, + -- Colours + { + "fcs", + function() + Snacks.picker.colorschemes() + end, + desc = "Show color schemes", + mode = "n", + }, + { + "fco", + function() + Snacks.picker.highlights({ pattern = "hl_group:^Snacks" }) + end, + desc = "Show Snacks highlights", + mode = "n", + }, + { + "fca", + function() + Snacks.picker.highlights() + end, + desc = "Show highlight groups", + mode = "n", + }, + { + "fci", + function() + Snacks.picker.icons() + end, + desc = "Show icons", + mode = "n", + }, + -- Terminal + { + "t", + function() + Snacks.terminal() + end, + desc = "Open terminal", + }, + -- Tree + { + "e", + function() + Snacks.explorer({ layout = { preset = "select", layout = { max_height = 200 } } }) + end, + desc = "Open File Tree", + mode = "n", + }, + -- Pickers + { + "ff", + function() + Snacks.picker.smart() + end, + desc = "Find files (smart)", + mode = "n", + }, + { + "fF", + function() + Snacks.picker.files() + end, + desc = "Find files (default)", + mode = "n", + }, + { + "fg", + function() + Snacks.picker.grep() + end, + desc = "Find file content using grep", + mode = "n", + }, + { + "fb", + function() + Snacks.picker.buffers() + end, + desc = "Show all buffers", + mode = "n", + }, + { + "fch", + function() + Snacks.picker.command_history() + end, + desc = "Show command history", + mode = "n", + }, + { + "fd", + function() + Snacks.picker.diagnostics() + end, + desc = "Show diagnostics", + mode = "n", + }, + { + "fm", + function() + Snacks.picker.git_diff() + end, + desc = "Show uncommitted diffs", + mode = "n", + }, + { + "fh", + function() + Snacks.picker.help() + end, + desc = "Show nvim help pages", + mode = "n", + }, + { + "fj", + function() + Snacks.picker.jumps() + end, + desc = "Show available jumps", + mode = "n", + }, + { + "fk", + function() + Snacks.picker.keymaps() + end, + desc = "Show keymaps", + mode = "n", + }, + { + "flc", + function() + Snacks.picker.lsp_config() + end, + desc = "Show LSP configs", + mode = "n", + }, + { + "gd", + function() + Snacks.picker.lsp_definitions() + end, + desc = "Goto definitions", + mode = "n", + }, + { + "gi", + function() + Snacks.picker.lsp_implementations() + end, + desc = "Goto implementations", + mode = "n", + }, + { + "gr", + function() + Snacks.picker.lsp_references() + end, + desc = "Goto references", + mode = "n", + }, + { + "gD", + function() + Snacks.picker.lsp_declarations() + end, + desc = "Goto declaration", + mode = "n", + }, + { + "gy", + function() + Snacks.picker.lsp_type_definitions() + end, + desc = "Goto T[y]pe Definition", + }, + { + "gai", + function() + Snacks.picker.lsp_incoming_calls() + end, + desc = "C[a]lls Incoming", + }, + { + "gao", + function() + Snacks.picker.lsp_outgoing_calls() + end, + desc = "C[a]lls Outgoing", + }, + { + "gs", + function() + Snacks.picker.lsp_symbols() + end, + desc = "Show LSP symbols", + mode = "n", + }, + { + "fn", + function() + Snacks.picker.noice() + end, + desc = "Show notifications", + mode = "n", + }, + { + "fp", + function() + Snacks.picker.projects() + end, + desc = "Show recent projects", + mode = "n", + }, + { + "fr", + function() + Snacks.picker.recent() + end, + desc = "Show recent files", + mode = "n", + }, + { + "fs", + function() + Snacks.picker.spelling() + end, + desc = "Show spelling suggestions", + mode = "n", + }, + { + "z=", + function() + Snacks.picker.spelling() + end, + desc = "Show spelling suggestions", + mode = "n", + }, + { + "fo", + function() + Snacks.picker.treesitter() + end, + desc = "Show treesitter details", + mode = "n", + }, + { + "[[", + function() + Snacks.words.jump(-vim.v.count1) + end, + desc = "Jump to previous reference", + mode = "n", + }, + { + "]]", + function() + Snacks.words.jump(vim.v.count1) + end, + desc = "Jump to next reference", + mode = "n", + }, + -- Close buffer + { + "", + function() + Snacks.bufdelete() + end, + desc = "Close buffer", + mode = "n", + }, } diff --git a/nvim/lua/wins.lua b/nvim/lua/wins.lua index 6e5d95b..bb6067e 100644 --- a/nvim/lua/wins.lua +++ b/nvim/lua/wins.lua @@ -2,7 +2,7 @@ local utils = require("utils") local opts = utils.opts local keymap = vim.keymap -keymap.set({ "n" }, "e", function() +keymap.set({ "n" }, "E", function() local width = math.ceil(math.min(150, vim.o.columns * 0.8)) local height = math.ceil(math.min(35, vim.o.lines * 0.8)) local row = math.ceil(vim.o.lines - height) * 0.5 - 1 @@ -25,4 +25,4 @@ end, opts("Open file browser")) keymap.set({ "n" }, "u", function() vim.api.nvim_command(":packadd nvim.undotree") vim.api.nvim_command(":Undotree") -end, opts("Open file browser")) +end, opts("Open undotree"))