fix: keymap conflicts + generated Vim keymap cheatsheet #10
No files matched your search
+40
-17
@@ -15,10 +15,17 @@ vim.opt.clipboard = "unnamedplus"
|
|||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
|
|
||||||
-- Redirect 'delete' and 'change' operations to the 'd' register
|
-- Redirect 'delete' and 'change' operations to the 'd' register
|
||||||
-- This keeps your system clipboard (unnamedplus) clean
|
-- This keeps your system clipboard (unnamedplus) clean.
|
||||||
|
-- A register typed first ("a, "_ …) is still honoured; with unnamedplus an
|
||||||
|
-- explicit "+ looks like the default, so it also goes to "d.
|
||||||
|
-- Mapped in "x" (Visual), not "v": "v" includes Select mode, where typing a
|
||||||
|
-- letter must replace the selection (snippet placeholders).
|
||||||
local delete_keys = { "d", "D", "c", "C", "x", "X" }
|
local delete_keys = { "d", "D", "c", "C", "x", "X" }
|
||||||
for _, key in ipairs(delete_keys) do
|
for _, key in ipairs(delete_keys) do
|
||||||
vim.keymap.set({ "n", "v" }, key, '"d' .. key, { noremap = true, silent = true })
|
vim.keymap.set({ "n", "x" }, key, function()
|
||||||
|
local reg = vim.v.register
|
||||||
|
return (reg == '"' or reg == "+" or reg == "*") and '"d' .. key or key
|
||||||
|
end, { expr = true, silent = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If you ever need to paste what you just deleted:
|
-- If you ever need to paste what you just deleted:
|
||||||
@@ -75,9 +82,6 @@ end, { desc = "Grep" })
|
|||||||
vim.keymap.set("n", "<leader>:", function()
|
vim.keymap.set("n", "<leader>:", function()
|
||||||
Snacks.picker.command_history()
|
Snacks.picker.command_history()
|
||||||
end, { desc = "Command History" })
|
end, { desc = "Command History" })
|
||||||
vim.keymap.set("n", "<leader>n", function()
|
|
||||||
Snacks.picker.notifications()
|
|
||||||
end, { desc = "Notification History" })
|
|
||||||
vim.keymap.set("n", "<leader>e", function()
|
vim.keymap.set("n", "<leader>e", function()
|
||||||
Snacks.explorer()
|
Snacks.explorer()
|
||||||
end, { desc = "File Explorer" })
|
end, { desc = "File Explorer" })
|
||||||
@@ -211,7 +215,14 @@ vim.keymap.set("n", "<leader>sM", function()
|
|||||||
Snacks.picker.man()
|
Snacks.picker.man()
|
||||||
end, { desc = "Man Pages" })
|
end, { desc = "Man Pages" })
|
||||||
vim.keymap.set("n", "<leader>sp", function()
|
vim.keymap.set("n", "<leader>sp", function()
|
||||||
Snacks.picker.lazy()
|
-- Snacks.picker.lazy() needs lazy.nvim; list the vim.pack specs instead.
|
||||||
|
Snacks.picker.grep({
|
||||||
|
cwd = vim.fn.stdpath("config"),
|
||||||
|
glob = "lua/plugins.lua",
|
||||||
|
search = 'src = "https://',
|
||||||
|
regex = false,
|
||||||
|
live = false,
|
||||||
|
})
|
||||||
end, { desc = "Search for Plugin Spec" })
|
end, { desc = "Search for Plugin Spec" })
|
||||||
vim.keymap.set("n", "<leader>sq", function()
|
vim.keymap.set("n", "<leader>sq", function()
|
||||||
Snacks.picker.qflist()
|
Snacks.picker.qflist()
|
||||||
@@ -233,9 +244,10 @@ end, { desc = "Goto Definition" })
|
|||||||
vim.keymap.set("n", "gD", function()
|
vim.keymap.set("n", "gD", function()
|
||||||
Snacks.picker.lsp_declarations()
|
Snacks.picker.lsp_declarations()
|
||||||
end, { desc = "Goto Declaration" })
|
end, { desc = "Goto Declaration" })
|
||||||
vim.keymap.set("n", "gr", function()
|
-- grr rather than a nowait gr, which would hide Neovim's grn/gra/gri/grt/grx.
|
||||||
|
vim.keymap.set("n", "grr", function()
|
||||||
Snacks.picker.lsp_references()
|
Snacks.picker.lsp_references()
|
||||||
end, { nowait = true, desc = "References" })
|
end, { desc = "References" })
|
||||||
vim.keymap.set("n", "gI", function()
|
vim.keymap.set("n", "gI", function()
|
||||||
Snacks.picker.lsp_implementations()
|
Snacks.picker.lsp_implementations()
|
||||||
end, { desc = "Goto Implementation" })
|
end, { desc = "Goto Implementation" })
|
||||||
@@ -263,7 +275,7 @@ vim.keymap.set("n", "<leader>cr", function()
|
|||||||
end, { expr = true, desc = "Rename Symbol" })
|
end, { expr = true, desc = "Rename Symbol" })
|
||||||
|
|
||||||
-- Other
|
-- Other
|
||||||
vim.keymap.set("n", "<leader>sq", "<cmd>nohlsearch<cr>", { desc = "Clear Search Highlights" })
|
vim.keymap.set("n", "<leader>ur", "<cmd>nohlsearch<cr>", { desc = "Clear Search Highlights" })
|
||||||
vim.keymap.set("n", "<leader>z", function()
|
vim.keymap.set("n", "<leader>z", function()
|
||||||
Snacks.zen()
|
Snacks.zen()
|
||||||
end, { desc = "Toggle Zen Mode" })
|
end, { desc = "Toggle Zen Mode" })
|
||||||
@@ -285,7 +297,7 @@ end, { desc = "Delete Buffer" })
|
|||||||
vim.keymap.set("n", "<leader>cR", function()
|
vim.keymap.set("n", "<leader>cR", function()
|
||||||
Snacks.rename.rename_file()
|
Snacks.rename.rename_file()
|
||||||
end, { desc = "Rename File" })
|
end, { desc = "Rename File" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>gB", function()
|
vim.keymap.set({ "n", "x" }, "<leader>gB", function()
|
||||||
Snacks.gitbrowse()
|
Snacks.gitbrowse()
|
||||||
end, { desc = "Git Browse" })
|
end, { desc = "Git Browse" })
|
||||||
vim.keymap.set("n", "<leader>gg", function()
|
vim.keymap.set("n", "<leader>gg", function()
|
||||||
@@ -300,10 +312,10 @@ end, { desc = "Toggle Terminal" })
|
|||||||
vim.keymap.set({ "n", "t" }, "<c-_>", function()
|
vim.keymap.set({ "n", "t" }, "<c-_>", function()
|
||||||
Snacks.terminal()
|
Snacks.terminal()
|
||||||
end, { desc = "which_key_ignore" })
|
end, { desc = "which_key_ignore" })
|
||||||
vim.keymap.set({ "n", "t" }, "]]", function()
|
vim.keymap.set("n", "]]", function()
|
||||||
Snacks.words.jump(vim.v.count1)
|
Snacks.words.jump(vim.v.count1)
|
||||||
end, { desc = "Next Reference" })
|
end, { desc = "Next Reference" })
|
||||||
vim.keymap.set({ "n", "t" }, "[[", function()
|
vim.keymap.set("n", "[[", function()
|
||||||
Snacks.words.jump(-vim.v.count1)
|
Snacks.words.jump(-vim.v.count1)
|
||||||
end, { desc = "Prev Reference" })
|
end, { desc = "Prev Reference" })
|
||||||
vim.keymap.set("n", "<leader>N", function()
|
vim.keymap.set("n", "<leader>N", function()
|
||||||
@@ -324,9 +336,15 @@ end, { desc = "Neovim News" })
|
|||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
|
|
||||||
-- Sidekick NES: accept next-edit suggestion in normal mode
|
-- Sidekick NES: accept next-edit suggestion in normal mode
|
||||||
|
-- Without a suggestion <Tab> keeps its built-in meaning (jump forward).
|
||||||
|
-- <C-i> is mapped to itself so terminals that can tell it from <Tab> (kitty,
|
||||||
|
-- Neovide) keep it as a plain jump forward (see :h CTRL-I).
|
||||||
vim.keymap.set("n", "<Tab>", function()
|
vim.keymap.set("n", "<Tab>", function()
|
||||||
require("sidekick").nes_jump_or_apply()
|
if not require("sidekick").nes_jump_or_apply() then
|
||||||
|
vim.api.nvim_feedkeys(vim.v.count1 .. vim.keycode("<C-i>"), "n", false)
|
||||||
|
end
|
||||||
end, { desc = "Apply Sidekick NES Suggestion" })
|
end, { desc = "Apply Sidekick NES Suggestion" })
|
||||||
|
vim.keymap.set("n", "<C-i>", "<C-i>", { desc = "Jump Forward" })
|
||||||
|
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
|
|
||||||
@@ -336,8 +354,13 @@ vim.keymap.set("n", "S", "<Plug>(leap-from-window)")
|
|||||||
|
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
|
|
||||||
|
-- Gx Keymaps
|
||||||
|
vim.keymap.set({ "n", "x" }, "gx", "<cmd>Browse<cr>", { desc = "Open with gx.nvim" })
|
||||||
|
|
||||||
|
----------------------------------------------------------
|
||||||
|
|
||||||
-- Conform Keymaps
|
-- Conform Keymaps
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
|
vim.keymap.set({ "n", "x" }, "<leader>cf", function()
|
||||||
require("conform").format({ lsp_format = "fallback" })
|
require("conform").format({ lsp_format = "fallback" })
|
||||||
end, { desc = "Format Buffer" })
|
end, { desc = "Format Buffer" })
|
||||||
|
|
||||||
@@ -349,9 +372,9 @@ vim.keymap.set("n", "<leader>uu", "<cmd>UndotreeToggle<cr>", { desc = "Toggle Un
|
|||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
|
|
||||||
-- Comment Box Keymaps
|
-- Comment Box Keymaps
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cbb", "<cmd>CBccbox<cr>", { desc = "Centered Box" })
|
vim.keymap.set({ "n", "x" }, "<leader>cbb", "<cmd>CBccbox<cr>", { desc = "Centered Box" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cbl", "<cmd>CBcline<cr>", { desc = "Centered Line" })
|
vim.keymap.set({ "n", "x" }, "<leader>cbl", "<cmd>CBcline<cr>", { desc = "Centered Line" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cbd", "<cmd>CBd<cr>", { desc = "Delete Box/Line" })
|
vim.keymap.set({ "n", "x" }, "<leader>cbd", "<cmd>CBd<cr>", { desc = "Delete Box/Line" })
|
||||||
vim.keymap.set("n", "<leader>cbk", "<cmd>CBcatalog<cr>", { desc = "Box Style Catalog" })
|
vim.keymap.set("n", "<leader>cbk", "<cmd>CBcatalog<cr>", { desc = "Box Style Catalog" })
|
||||||
|
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
|
|||||||
@@ -78,17 +78,6 @@ vim.api.nvim_create_user_command("Format", function(args)
|
|||||||
require("conform").format({ async = true, lsp_format = "fallback", range = range })
|
require("conform").format({ async = true, lsp_format = "fallback", range = range })
|
||||||
end, { range = true })
|
end, { range = true })
|
||||||
|
|
||||||
-- FormatOnSave
|
|
||||||
-- Formats the buffer before saving.
|
|
||||||
-- This is a common practice to ensure code is consistently formatted.
|
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
||||||
pattern = "*",
|
|
||||||
callback = function()
|
|
||||||
-- Call Format function
|
|
||||||
vim.api.nvim_command("Format")
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Return to last-known cursor position when reopening files
|
-- Return to last-known cursor position when reopening files
|
||||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||||
desc = "Jump to last known cursor position on open",
|
desc = "Jump to last known cursor position on open",
|
||||||
|
|||||||
+27
-33
@@ -181,8 +181,7 @@ lazyload.on_vim_enter(function()
|
|||||||
-- Flash.nvim
|
-- Flash.nvim
|
||||||
vim.pack.add({ { src = "https://github.com/folke/flash.nvim", name = "flash" } })
|
vim.pack.add({ { src = "https://github.com/folke/flash.nvim", name = "flash" } })
|
||||||
require("flash").setup({
|
require("flash").setup({
|
||||||
modes = { char = { keys = {} } },
|
modes = { char = { multi_line = false } },
|
||||||
keys = {},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Leap.nvim
|
-- Leap.nvim
|
||||||
@@ -318,6 +317,17 @@ lazyload.on_vim_enter(function()
|
|||||||
cmp.setup({
|
cmp.setup({
|
||||||
keymap = {
|
keymap = {
|
||||||
preset = "default",
|
preset = "default",
|
||||||
|
-- The preset's signature toggle would shadow digraphs (i_CTRL-K);
|
||||||
|
-- signature help stays on <C-s> (Neovim default) and auto-trigger.
|
||||||
|
["<C-k>"] = false,
|
||||||
|
-- With the menu closed, open it instead of doing nothing.
|
||||||
|
["<C-n>"] = { "select_next", "show_and_insert" },
|
||||||
|
["<C-p>"] = {
|
||||||
|
"select_prev",
|
||||||
|
function(cmp)
|
||||||
|
return cmp.show_and_insert({ initial_selected_item_idx = -1 })
|
||||||
|
end,
|
||||||
|
},
|
||||||
["<Tab>"] = {
|
["<Tab>"] = {
|
||||||
"snippet_forward",
|
"snippet_forward",
|
||||||
function()
|
function()
|
||||||
@@ -372,8 +382,16 @@ lazyload.on_vim_enter(function()
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
-- Server settings use vim.lsp.config(); mason-lspconfig v2 enables every
|
||||||
local capabilities = (has_blink_bin or has_cargo) and require("blink.cmp").get_lsp_capabilities() or nil
|
-- installed server (automatic_enable) and no longer reads `handlers`.
|
||||||
|
-- blink.cmp adds its completion capabilities to vim.lsp.config("*") itself.
|
||||||
|
vim.lsp.config("lua_ls", {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = { globals = { "Config" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
vim.lsp.config("rust_analyzer", {
|
vim.lsp.config("rust_analyzer", {
|
||||||
settings = {
|
settings = {
|
||||||
@@ -395,35 +413,6 @@ lazyload.on_vim_enter(function()
|
|||||||
"bashls",
|
"bashls",
|
||||||
"copilot",
|
"copilot",
|
||||||
},
|
},
|
||||||
handlers = {
|
|
||||||
-- Default handler
|
|
||||||
function(server_name)
|
|
||||||
lspconfig[server_name].setup({ capabilities = capabilities })
|
|
||||||
end,
|
|
||||||
-- Specific overrides
|
|
||||||
["lua_ls"] = function()
|
|
||||||
lspconfig.lua_ls.setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
diagnostics = { globals = { "Config" } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
["rust_analyzer"] = function()
|
|
||||||
lspconfig.rust_analyzer.setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
settings = {
|
|
||||||
["rust-analyzer"] = {
|
|
||||||
check = {
|
|
||||||
command = "clippy",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Enable native inline completion (ghost text in insert mode)
|
-- Enable native inline completion (ghost text in insert mode)
|
||||||
@@ -433,6 +422,11 @@ lazyload.on_vim_enter(function()
|
|||||||
vim.pack.add({ { src = "https://github.com/echasnovski/mini.ai", name = "mini.ai" } })
|
vim.pack.add({ { src = "https://github.com/echasnovski/mini.ai", name = "mini.ai" } })
|
||||||
|
|
||||||
Config.plugins.mini_ai = {
|
Config.plugins.mini_ai = {
|
||||||
|
-- an/in stay Neovim's LSP selection-range maps (|v_an|, |v_in|).
|
||||||
|
mappings = {
|
||||||
|
around_next = "aN",
|
||||||
|
inside_next = "iN",
|
||||||
|
},
|
||||||
custom_textobjects = {
|
custom_textobjects = {
|
||||||
g = function()
|
g = function()
|
||||||
local n_lines = vim.api.nvim_buf_line_count(0)
|
local n_lines = vim.api.nvim_buf_line_count(0)
|
||||||
|
|||||||
Reference in new issue
Block a user