From 48392501e1bf73cca5a66045bee05846f11c8639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Fri, 19 Dec 2025 22:21:10 +0100 Subject: [PATCH] nvim: split snacks keys to allow reload with :so --- nvim/.config/nvim/lua/config/remap.lua | 24 +- nvim/.config/nvim/lua/config/remap/snacks.lua | 204 +++++++++++++++++ nvim/.config/nvim/lua/plugins/snacks.lua | 205 ------------------ 3 files changed, 219 insertions(+), 214 deletions(-) create mode 100644 nvim/.config/nvim/lua/config/remap/snacks.lua diff --git a/nvim/.config/nvim/lua/config/remap.lua b/nvim/.config/nvim/lua/config/remap.lua index e626479..a354018 100644 --- a/nvim/.config/nvim/lua/config/remap.lua +++ b/nvim/.config/nvim/lua/config/remap.lua @@ -1,10 +1,16 @@ -vim.keymap.set("n", "", "h") -vim.keymap.set("n", "", "k") -vim.keymap.set("n", "", "j") -vim.keymap.set("n", "", "l") +local set = vim.keymap.set -vim.keymap.set("n", "", "nohlsearch") -vim.keymap.set("n", "k", "cp") -vim.keymap.set("n", "j", "cn") -vim.keymap.set("n", "x", "copen") -vim.keymap.set("n", "X", "cclose") +set("n", "", "h") +set("n", "", "k") +set("n", "", "j") +set("n", "", "l") + +set("n", "", "nohlsearch") +set("n", "k", "cp") +set("n", "j", "cn") +set("n", "x", "copen") +set("n", "X", "cclose") + +set("n", "a", "AutoSession search") + +require("config.remap.snacks") diff --git a/nvim/.config/nvim/lua/config/remap/snacks.lua b/nvim/.config/nvim/lua/config/remap/snacks.lua new file mode 100644 index 0000000..c5deb18 --- /dev/null +++ b/nvim/.config/nvim/lua/config/remap/snacks.lua @@ -0,0 +1,204 @@ +local set = vim.keymap.set + +set("n", "", function() + Snacks.picker.smart() +end, { desc = "Smart Find Files" }) + +set("n", "b", function() + Snacks.picker.buffers() +end, { desc = "Buffers" }) + +set("n", "e", function() + Snacks.explorer() +end, { desc = "File Explorer" }) + +set("n", "r", function() + Snacks.picker.recent() +end, { desc = "Recent files" }) + +set("n", "R", function() + Snacks.picker.resume() +end, { desc = "Resume" }) + +set("n", "p", function() + Snacks.picker.projects() +end, { desc = "Projects" }) + +set("n", "l", function() + Snacks.picker.lines() +end, { desc = "Buffer lines" }) + +set("n", "L", function() + Snacks.picker.grep_buffers() +end, { desc = "Grep Open Buffers" }) + +set("n", "F", function() + Snacks.picker.files() +end, { desc = "Find Files" }) + +set("n", "S", function() + Snacks.picker.grep() +end, { desc = "Grep" }) + +set("n", "B", function() + Snacks.picker.git_branches() +end, { desc = "Git Branches" }) + +set({ "n", "v" }, "xB", function() + Snacks.gitbrowse() +end, { desc = "Git Browse" }) + +set("n", "i", function() + Snacks.picker.git_log_line() +end, { desc = "Git Log Line" }) + +set("n", "I", function() + Snacks.picker.git_log() +end, { desc = "Git Log" }) + +set("n", "t", function() + Snacks.picker.git_status() +end, { desc = "Git Status" }) + +set("n", "H", function() + Snacks.picker.git_diff() +end, { desc = "Git Diff (Hunks)" }) + +set("n", "xS", function() + Snacks.picker.git_stash() +end, { desc = "Git Stash" }) + +set("n", "f", function() + Snacks.picker.git_files() +end, { desc = "Find Git Files" }) + +set("n", "s", function() + Snacks.picker.git_grep() +end, { desc = "Git Grep" }) + +set({ "n", "v" }, "o", function() + Snacks.picker.grep_word() +end, { desc = "Grep Visual Selection or Word" }) + +set("n", "g", function() + Snacks.lazygit() +end, { desc = "Lazygit" }) + +set("n", "G", function() + Snacks.lazygit.log_file() +end, { desc = "Git Log File" }) + +set("n", "m", function() + Snacks.picker.marks() +end, { desc = "Marks" }) + +set("n", "M", function() + Snacks.picker.man() +end, { desc = "Man pages" }) + +set("n", "U", function() + Snacks.picker.undo() +end, { desc = "Undo History" }) + +set("n", "q", function() + Snacks.picker.qflist() +end, { desc = "Quickfix list" }) + +set("n", "Q", function() + Snacks.picker.loclist() +end, { desc = "Location List" }) + +set("n", "xs", function() + Snacks.picker.colorschemes() +end, { desc = "Colorschemes" }) + +set("n", "n", function() + Snacks.notifier.show_history() +end, { desc = "Notification History" }) + +set("n", "N", function() + Snacks.picker.notifications() +end, { desc = "Notifications" }) + +set("n", "xC", function() + Snacks.picker.commands() +end, { desc = "Commands" }) + +set("n", "h", function() + Snacks.picker.keymaps() +end, { desc = "Keymaps" }) + +set("n", "xh", function() + Snacks.picker.highlights() +end, { desc = "Hightlights" }) + +set("n", "xc", function() + Snacks.picker.command_history() +end, { desc = "Command History" }) + +set("n", '"', function() + Snacks.picker.registers() +end, { desc = "Registers" }) + +set("n", "$", function() + Snacks.rename.rename_file() +end, { desc = "Rename File" }) + +set("n", "z", function() + Snacks.zen.zoom() +end, { desc = "Toggle Zoom" }) + +set("n", ".", function() + Snacks.scratch() +end, { desc = "Toggle Scratch Buffer" }) + +set("n", "x.", function() + Snacks.scratch.select() +end, { desc = "Select Scratch Buffer" }) + +-- LSP + +set("n", "gd", function() + Snacks.picker.lsp_definitions() +end, { desc = "Goto Definition" }) + +set("n", "gD", function() + Snacks.picker.lsp_declarations() +end, { desc = "Goto Declaration" }) + +set("n", "grr", function() + Snacks.picker.lsp_references() +end, { desc = "References" }) + +set("n", "gI", function() + Snacks.picker.lsp_implementations() +end, { desc = "Goto Implementation" }) + +set("n", "gy", function() + Snacks.picker.lsp_type_definitions() +end, { desc = "Goto T[y]pe Definition" }) + +set("n", "w", function() + Snacks.picker.lsp_symbols() +end, { desc = "LSP Symbols" }) + +set("n", "d", function() + Snacks.picker.diagnostics_buffer() +end, { desc = "Buffer Diagnostics" }) + +set("n", "D", function() + Snacks.picker.diagnostics() +end, { desc = "Diagnostics" }) + +set("n", "W", function() + Snacks.picker.lsp_workspace_symbols() +end, { desc = "LSP Workspace Symbols" }) +-- Terminal + +set({ "n", "t" }, "", function() + Snacks.terminal() +end, { desc = "Toggle Terminal" }) + +set({ "n", "t" }, "", function() + Snacks.terminal() +end, { desc = "which_key_ignore" }) diff --git a/nvim/.config/nvim/lua/plugins/snacks.lua b/nvim/.config/nvim/lua/plugins/snacks.lua index 2bb6bfc..c4f3196 100644 --- a/nvim/.config/nvim/lua/plugins/snacks.lua +++ b/nvim/.config/nvim/lua/plugins/snacks.lua @@ -1,210 +1,5 @@ return { init = function() - local set = vim.keymap.set - - set("n", "", function() - Snacks.picker.smart() - end, { desc = "Smart Find Files" }) - - set("n", "b", function() - Snacks.picker.buffers() - end, { desc = "Buffers" }) - - set("n", "e", function() - Snacks.explorer() - end, { desc = "File Explorer" }) - - set("n", "r", function() - Snacks.picker.recent() - end, { desc = "Recent files" }) - - set("n", "R", function() - Snacks.picker.resume() - end, { desc = "Resume" }) - - set("n", "p", function() - Snacks.picker.projects() - end, { desc = "Projects" }) - - set("n", "l", function() - Snacks.picker.lines() - end, { desc = "Buffer lines" }) - - set("n", "L", function() - Snacks.picker.grep_buffers() - end, { desc = "Grep Open Buffers" }) - - set("n", "F", function() - Snacks.picker.files() - end, { desc = "Find Files" }) - - set("n", "S", function() - Snacks.picker.grep() - end, { desc = "Grep" }) - - set("n", "B", function() - Snacks.picker.git_branches() - end, { desc = "Git Branches" }) - - set({ "n", "v" }, "xB", function() - Snacks.gitbrowse() - end, { desc = "Git Browse" }) - - set("n", "i", function() - Snacks.picker.git_log_line() - end, { desc = "Git Log Line" }) - - set("n", "I", function() - Snacks.picker.git_log() - end, { desc = "Git Log" }) - - set("n", "t", function() - Snacks.picker.git_status() - end, { desc = "Git Status" }) - - set("n", "H", function() - Snacks.picker.git_diff() - end, { desc = "Git Diff (Hunks)" }) - - set("n", "xS", function() - Snacks.picker.git_stash() - end, { desc = "Git Stash" }) - - set("n", "f", function() - Snacks.picker.git_files() - end, { desc = "Find Git Files" }) - - set("n", "s", function() - Snacks.picker.git_grep() - end, { desc = "Git Grep" }) - - set({ "n", "v" }, "o", function() - Snacks.picker.grep_word() - end, { desc = "Grep Visual Selection or Word" }) - - set("n", "g", function() - Snacks.lazygit() - end, { desc = "Lazygit" }) - - set("n", "G", function() - Snacks.lazygit.log_file() - end, { desc = "Git Log File" }) - - set("n", "m", function() - Snacks.picker.marks() - end, { desc = "Marks" }) - - set("n", "M", function() - Snacks.picker.man() - end, { desc = "Man pages" }) - - set("n", "U", function() - Snacks.picker.undo() - end, { desc = "Undo History" }) - - set("n", "q", function() - Snacks.picker.qflist() - end, { desc = "Quickfix list" }) - - set("n", "Q", function() - Snacks.picker.loclist() - end, { desc = "Location List" }) - - set("n", "xs", function() - Snacks.picker.colorschemes() - end, { desc = "Colorschemes" }) - - set("n", "n", function() - Snacks.notifier.show_history() - end, { desc = "Notification History" }) - - set("n", "N", function() - Snacks.picker.notifications() - end, { desc = "Notifications" }) - - set("n", "xC", function() - Snacks.picker.commands() - end, { desc = "Commands" }) - - set("n", "h", function() - Snacks.picker.keymaps() - end, { desc = "Keymaps" }) - - set("n", "xh", function() - Snacks.picker.highlights() - end, { desc = "Hightlights" }) - - set("n", "xc", function() - Snacks.picker.command_history() - end, { desc = "Command History" }) - - set("n", '"', function() - Snacks.picker.registers() - end, { desc = "Registers" }) - - set("n", "$", function() - Snacks.rename.rename_file() - end, { desc = "Rename File" }) - - set("n", "z", function() - Snacks.zen.zoom() - end, { desc = "Toggle Zoom" }) - - set("n", ".", function() - Snacks.scratch() - end, { desc = "Toggle Scratch Buffer" }) - - set("n", "x.", function() - Snacks.scratch.select() - end, { desc = "Select Scratch Buffer" }) - - -- LSP - - set("n", "gd", function() - Snacks.picker.lsp_definitions() - end, { desc = "Goto Definition" }) - - set("n", "gD", function() - Snacks.picker.lsp_declarations() - end, { desc = "Goto Declaration" }) - - set("n", "grr", function() - Snacks.picker.lsp_references() - end, { desc = "References" }) - - set("n", "gI", function() - Snacks.picker.lsp_implementations() - end, { desc = "Goto Implementation" }) - - set("n", "gy", function() - Snacks.picker.lsp_type_definitions() - end, { desc = "Goto T[y]pe Definition" }) - - set("n", "w", function() - Snacks.picker.lsp_symbols() - end, { desc = "LSP Symbols" }) - - set("n", "d", function() - Snacks.picker.diagnostics_buffer() - end, { desc = "Buffer Diagnostics" }) - - set("n", "D", function() - Snacks.picker.diagnostics() - end, { desc = "Diagnostics" }) - - set("n", "W", function() - Snacks.picker.lsp_workspace_symbols() - end, { desc = "LSP Workspace Symbols" }) - -- Terminal - - set({ "n", "t" }, "", function() - Snacks.terminal() - end, { desc = "Toggle Terminal" }) - - set({ "n", "t" }, "", function() - Snacks.terminal() - end, { desc = "which_key_ignore" }) - vim.api.nvim_create_autocmd("VimEnter", { callback = function() -- Setup some globals for debugging (lazy-loaded)