-- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here -- -- -- Copy relative path vim.keymap.set("n", "cy", function() vim.fn.setreg("+", vim.fn.expand("%")) print("Copied relative path: " .. vim.fn.expand("%")) end, { desc = "Copy relative path" }) -- Copy absolute path vim.keymap.set("n", "cY", function() vim.fn.setreg("+", vim.fn.expand("%:p")) print("Copied absolute path: " .. vim.fn.expand("%:p")) end, { desc = "Copy absolute path" }) -- Select mode (Shift+arrows) replaces the selection with what you type, so `y` -- types a "y". Conventional copy/cut instead ( switches to Visual first). -- The `y`/`d` is fed remappable so buffer maps still apply (md-render's render -- view copies markdown source); `"+` is fed noremap so which-key's `"` trigger -- stays out. Both go to the front of typeahead, in this order. local function clipboard_op(prefix, op) return function() vim.api.nvim_feedkeys(op, "mi", false) vim.api.nvim_feedkeys(vim.keycode(prefix) .. '"+', "ni", false) end end vim.keymap.set("s", "", clipboard_op("", "y"), { desc = "Copy selection to clipboard" }) vim.keymap.set("s", "", clipboard_op("", "d"), { desc = "Cut selection to clipboard" }) vim.keymap.set("x", "", clipboard_op("", "y"), { desc = "Copy selection to clipboard" }) -- VS Code's terminal toggle (Ctrl+`, the ~ key), mirroring LazyVim's . -- Only reaches nvim when the terminal sends CSI u / kitty keys; the legacy -- encoding of Ctrl+` is NUL, which is (flash) and is left alone. local function toggle_terminal() Snacks.terminal.focus(nil, { cwd = LazyVim.root() }) end vim.keymap.set({ "n", "t" }, "", toggle_terminal, { desc = "Terminal (Root Dir)" }) vim.keymap.set({ "n", "t" }, "", toggle_terminal, { desc = "which_key_ignore" })