neovim-confs/lua/custom/mappings.lua

549 lines
13 KiB
Lua
Raw Normal View History

2024-01-19 22:34:37 +01:00
---@type MappingsTable
2024-01-21 22:26:37 +01:00
2024-01-19 22:34:37 +01:00
local M = {}
2024-01-20 03:03:39 +01:00
-- NOTE: The mappings here are case sensitive!!! Removing a specific default
-- mapping requires the same case here!
2024-01-19 22:34:37 +01:00
M.disabled = {
n = {
["<C-a>"] = "",
["<C-s>"] = "",
2024-01-19 23:44:07 +01:00
["<C-c>"] = "",
2024-01-20 03:03:39 +01:00
["<leader>n"] = "",
["<leader>rn"] = "",
["<Up>"] = "",
["<Down>"] = "",
["<leader>x"] = "",
["<leader>/"] = "",
["<leader>ra"] = "",
2024-01-19 23:44:07 +01:00
["[d"] = "",
["]d"] = "",
["[c"] = "",
["]c"] = "",
2024-01-20 03:03:39 +01:00
["<leader>h"] = "",
["<leader>ff"] = "",
["<leader>fm"] = "",
["<leader>fa"] = "",
["<leader>fw"] = "",
["<leader>fb"] = "",
2024-01-20 18:36:48 +01:00
["<leader>th"] = "",
2024-01-20 03:03:39 +01:00
["<leader>fh"] = "",
["<leader>fo"] = "",
["<leader>fz"] = "",
["<leader>cm"] = "",
["<leader>gt"] = "",
["<leader>pt"] = "",
["<leader>ma"] = "",
["<leader>v"] = "",
["<leader>rh"] = "",
["<leader>ph"] = "",
["<leader>gb"] = "",
["<leader>td"] = "",
["<leader>wk"] = "",
2024-01-20 01:03:01 +01:00
["#"] = "",
2024-01-21 02:07:56 +01:00
["J"] = "",
2024-01-19 23:44:07 +01:00
},
t = {
["<C-t>"] = "",
},
v = {
2024-01-20 01:03:01 +01:00
["#"] = "",
["?"] = "",
2024-01-20 03:03:39 +01:00
["<leader>/"] = "",
2024-01-21 02:07:56 +01:00
["J"] = "",
2024-01-19 23:44:07 +01:00
},
}
M.tabufline = {
plugin = true,
n = {
-- cycle through buffers
2024-01-20 03:03:39 +01:00
["<Tab>"] = {
2024-01-19 23:44:07 +01:00
function()
require("nvchad.tabufline").tabuflineNext()
end,
"Goto next buffer",
},
["<S-tab>"] = {
function()
require("nvchad.tabufline").tabuflinePrev()
end,
"Goto prev buffer",
},
-- close buffer + hide terminal buffer
2024-01-20 01:03:01 +01:00
["<A-c>"] = {
2024-01-19 23:44:07 +01:00
function()
require("nvchad.tabufline").close_buffer()
end,
"Close buffer",
},
},
}
M.comment = {
plugin = true,
-- toggle comment in both modes
n = {
2024-01-20 03:03:39 +01:00
["<leader>v"] = {
2024-01-19 23:44:07 +01:00
function()
require("Comment.api").toggle.linewise.current()
end,
"Toggle comment",
},
},
v = {
2024-01-20 03:03:39 +01:00
["<leader>v"] = {
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>",
2024-01-19 23:44:07 +01:00
"Toggle comment",
},
2024-01-19 22:34:37 +01:00
},
2024-01-19 23:13:23 +01:00
}
M.leap = {
plugin = true,
n = {
2024-01-20 16:27:44 +01:00
["s"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-forward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 16:27:44 +01:00
["S"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-backward)",
2024-01-19 23:13:23 +01:00
"leap backward",
},
2024-01-20 16:27:44 +01:00
["gs"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-from-window)",
2024-01-19 23:13:23 +01:00
"leap from window",
},
},
x = {
2024-01-20 16:27:44 +01:00
["s"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-forward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 16:27:44 +01:00
["S"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-backward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 16:27:44 +01:00
["gs"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-from-window)",
2024-01-19 23:13:23 +01:00
"leap from window",
},
},
o = {
2024-01-20 16:27:44 +01:00
["s"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-forward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 16:27:44 +01:00
["S"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-backward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 16:27:44 +01:00
["gs"] = {
2024-01-20 03:03:39 +01:00
"<plug>(leap-from-window)",
2024-01-19 23:13:23 +01:00
"leap from window",
},
},
2024-01-19 22:34:37 +01:00
}
M.lazygit = {
plugin = true,
n = {
2024-01-20 03:03:39 +01:00
["<leader>gg"] = { "<cmd> LazyGit <cr>", "Open LazyGit" },
2024-01-19 22:34:37 +01:00
},
}
2024-01-19 23:44:07 +01:00
M.lspconfig = {
plugin = true,
n = {
2024-01-20 03:03:39 +01:00
["[d"] = {
2024-01-19 23:44:07 +01:00
function()
vim.diagnostic.goto_prev { float = { border = "rounded" } }
end,
"Goto prev",
},
2024-01-20 03:03:39 +01:00
["]d"] = {
2024-01-19 23:44:07 +01:00
function()
vim.diagnostic.goto_next { float = { border = "rounded" } }
end,
"Goto next",
},
2024-01-20 19:06:50 +01:00
["<leader>cr"] = {
function()
require("nvchad.renamer").open()
end,
"LSP rename",
},
2024-01-19 23:44:07 +01:00
},
}
2024-01-19 22:34:37 +01:00
M.clipboard = {
plugin = false,
n = {
2024-01-20 03:03:39 +01:00
["<leader>y"] = { '"+y', "yank to system" },
["<leader>Y"] = { '"+Y', "yank to system" },
["<leader>yy"] = { '"+y', "yank to system" },
2024-01-19 22:34:37 +01:00
},
v = {
2024-01-20 03:03:39 +01:00
["<leader>y"] = { '"+y', "yank to system" },
["<leader>Y"] = { '"+Y', "yank to system" },
["<leader>yy"] = { '"+y', "yank to system" },
2024-01-19 22:34:37 +01:00
},
}
M.telescope = {
plugin = true,
n = {
-- find
2024-01-20 03:03:39 +01:00
["<localleader>ff"] = { "<cmd> Telescope find_files <cr>", "Find files" },
["<localleader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <cr>", "Find all" },
["<localleader>fw"] = { "<cmd> Telescope live_grep <cr>", "Live grep" },
["<localleader>fb"] = { "<cmd> Telescope buffers <cr>", "Find buffers" },
["<localleader>fh"] = { "<cmd> Telescope help_tags <cr>", "Help page" },
["<localleader>fo"] = { "<cmd> Telescope oldfiles <cr>", "Find oldfiles" },
["<localleader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <cr>", "Find in current buffer" },
2024-01-19 22:34:37 +01:00
-- git
2024-01-20 03:03:39 +01:00
["<localleader>cm"] = { "<cmd> Telescope git_commits <cr>", "Git commits" },
["<localleader>gt"] = { "<cmd> Telescope git_status <cr>", "Git status" },
2024-01-19 22:34:37 +01:00
-- pick a hidden term
2024-01-20 03:03:39 +01:00
["<localleader>pt"] = { "<cmd> Telescope terms <cr>", "Pick hidden term" },
2024-01-19 22:34:37 +01:00
-- theme switcher
2024-01-20 03:03:39 +01:00
["<localleader>th"] = { "<cmd> Telescope themes <cr>", "Nvchad themes" },
2024-01-19 22:34:37 +01:00
2024-01-20 03:03:39 +01:00
["<localleader>ma"] = { "<cmd> Telescope marks <cr>", "telescope bookmarks" },
2024-01-19 22:34:37 +01:00
},
}
2024-01-20 04:05:27 +01:00
M.toggleterm = {
2024-01-19 23:44:07 +01:00
plugin = true,
2024-01-20 04:05:27 +01:00
n = {
2024-01-20 01:03:01 +01:00
["<F12>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-i>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-t>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=tab\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-h>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=horizontal\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-v>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=vertical\"<cr>",
"toggle terminal",
},
},
i = {
["<F12>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
"toggle terminal",
},
["<A-i>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
"toggle terminal",
},
["<A-t>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=tab\"<cr>",
"toggle terminal",
},
["<A-h>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=horizontal\"<cr>",
"toggle terminal",
},
["<A-v>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=vertical\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
2024-01-20 01:03:01 +01:00
},
2024-01-19 23:44:07 +01:00
},
2024-01-20 04:05:27 +01:00
t = {
2024-01-20 01:03:01 +01:00
["<F12>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
"toggle terminal",
},
["<A-i>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
"toggle terminal",
},
["<A-t>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=tab\"<cr>",
"toggle terminal",
},
["<A-h>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=horizontal\"<cr>",
"toggle terminal",
},
["<A-v>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=vertical\"<cr>",
"toggle terminal",
},
},
x = {
["<F12>"] = {
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-i>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=float\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-t>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=tab\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-h>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=horizontal\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
},
["<A-v>"] = {
2024-01-21 21:53:32 +01:00
"<cmd>exe v:count1 \"ToggleTerm direction=vertical\"<cr>",
2024-01-20 04:05:27 +01:00
"toggle terminal",
2024-01-20 01:03:01 +01:00
},
2024-01-19 23:44:07 +01:00
},
}
2024-01-19 22:34:37 +01:00
M.nvimtree = {
plugin = true,
n = {
-- toggle
2024-01-20 03:03:39 +01:00
["<C-n>"] = { "<cmd> NvimTreeToggle <cr>", "Toggle nvimtree" },
["<F5>"] = { "<cmd> NvimTreeToggle <cr>", "Toggle nvimtree" },
2024-01-21 18:56:32 +01:00
["<leader>tf"] = { "<cmd> NvimTreeToggle <cr>", "Toggle nvimtree" },
2024-01-19 22:34:37 +01:00
-- focus
2024-01-20 03:03:39 +01:00
["<localleader>e"] = { "<cmd> NvimTreeFocus <cr>", "Focus nvimtree" },
2024-01-19 22:34:37 +01:00
},
}
M.movements = {
plugin = false,
i = {
--big move
["<A-k>"] = { "<C-u>", "big step down" },
["<A-j>"] = { "<C-d>", "big step down" },
-- go to beginning and end
2024-01-20 03:03:39 +01:00
["<C-b>"] = { "<home>", "Beginning of line" },
["<C-e>"] = { "<end>", "End of line" },
2024-01-19 22:34:37 +01:00
-- navigate within insert mode
2024-01-20 03:03:39 +01:00
["<C-h>"] = { "<left>", "Move left" },
["<C-l>"] = { "<right>", "Move right" },
["<C-j>"] = { "<down>", "Move down" },
["<C-k>"] = { "<up>", "Move up" },
2024-01-19 22:34:37 +01:00
},
n = {
--big move
["<A-k>"] = { "<C-u>", "big step down" },
["<A-j>"] = { "<C-d>", "big step down" },
-- go to beginning and end
2024-01-20 03:03:39 +01:00
["H"] = { "<home>", "Beginning of line" },
["L"] = { "<end>", "End of line" },
2024-01-20 01:03:01 +01:00
-- go to mark with "#"
["#"] = { "'", "go to mark" },
2024-01-20 01:42:31 +01:00
-- spell
2024-01-20 04:05:27 +01:00
["]s"] = { "]s", "go to next spelling mark" },
["[s"] = { "[s", "go to last spelling mark" },
2024-01-19 22:34:37 +01:00
},
v = {
--big move
["<A-k>"] = { "<C-u>", "big step down" },
["<A-j>"] = { "<C-d>", "big step down" },
-- go to beginning and end
2024-01-20 03:03:39 +01:00
["H"] = { "<home>", "Beginning of line" },
["L"] = { "<end>", "End of line" },
2024-01-19 22:34:37 +01:00
},
t = {
["<C-w>"] = {
vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true),
"Escape terminal mode",
},
},
}
M.edit = {
plugin = false,
n = {
-- easy newline
2024-01-21 02:20:47 +01:00
["OO"] = { "O<esc>", "insert a line above" },
["oo"] = { "o<esc>", "insert a line below" },
2024-01-21 02:07:56 +01:00
-- substitute (change hovered/selection with insert mode)
-- normally, this is s, but that is leaps binding now
2024-01-21 02:20:47 +01:00
["<leader>s"] = { "s", "replace with insert mode" },
2024-01-19 22:34:37 +01:00
-- split and join lines
2024-01-21 22:26:37 +01:00
["J"] = { "j" },
["<C-s-j>"] = { "<cmd>join<cr>", "join lines" },
["<C-s-s>"] = { "i<cr><esc>l", "split line" },
2024-01-19 22:34:37 +01:00
-- do something useful with the arrows
2024-01-21 02:20:47 +01:00
["<Up>"] = { "<cmd> move-2<cr>", "Move line up" },
["<Down>"] = { "<cmd> move+<cr>", "Move line down" },
["<Left>"] = { "<<", "Less indentation" },
["<Right>"] = { ">>", "More indentation" },
2024-01-19 22:34:37 +01:00
-- format with conform
2024-01-20 03:03:39 +01:00
["<leader>ff"] = {
2024-01-19 22:34:37 +01:00
function()
require("conform").format()
end,
2024-01-20 00:37:13 +01:00
"format buffer",
},
2024-01-20 19:02:57 +01:00
2024-01-20 00:37:13 +01:00
-- remove trailing whitespace
2024-01-20 03:03:39 +01:00
["<leader>fw"] = {
2024-01-20 00:37:13 +01:00
function()
2024-01-20 01:03:01 +01:00
require("mini.trailspace").trim()
2024-01-20 00:37:13 +01:00
end,
"remove whitespace",
2024-01-19 22:34:37 +01:00
},
2024-01-20 19:02:57 +01:00
-- spell
["z<space>"] = { "<cmd>Telescope spell_suggest<CR>", "Spell suggest" },
["z="] = { "<cmd>Telescope spell_suggest<CR>", "Spell suggest" },
2024-01-19 22:34:37 +01:00
},
v = {
2024-01-21 02:20:47 +01:00
-- NOTE: I would love to know why these commands work, they seem really
-- crazy.
["<Up>"] = { ":move'<-2<CR>gv=gv", "Move lines up", opts = { silent = true } },
["<Down>"] = { ":move'>+<CR>gv=gv", "Move lines down", opts = { silent = true } },
2024-01-20 03:03:39 +01:00
["<Left>"] = { "<gv", "Less indentation" },
["<Right>"] = { ">gv", "More indentation" },
2024-01-19 22:34:37 +01:00
},
2024-01-21 02:20:47 +01:00
x = {},
2024-01-19 22:34:37 +01:00
t = {
--big move
["<A-k>"] = { "<C-u>", "big step down" },
["<A-j>"] = { "<C-d>", "big step down" },
},
}
M.ui = {
plugin = false,
n = {
-- toggle wrap
2024-01-20 03:03:39 +01:00
["<leader>tw"] = {
2024-01-19 22:34:37 +01:00
function()
vim.opt_local.wrap = not vim.wo.wrap
vim.opt_local.breakindent = not vim.wo.breakindent
if vim.wo.colorcolumn == "" then
vim.opt_local.colorcolumn = tostring(vim.bo.textwidth)
else
vim.opt_local.colorcolumn = ""
end
end,
"toggle wrap",
},
2024-01-20 01:03:01 +01:00
-- toggle some features
2024-01-20 03:03:39 +01:00
["<leader>tn"] = { "<cmd>setlocal nonumber!<cr>", "toggle line numbers" },
["<leader>trn"] = { "<cmd>setlocal nornu!<cr>", "toggle relative line numbers" },
["<leader>ts"] = { "<cmd>setlocal spell!<cr>", "toggle spell check" },
2024-01-20 16:05:24 +01:00
["<leader>ti"] = {
function()
require("lsp-inlayhints").toggle()
end,
"toggle inlay hints",
},
2024-01-20 19:06:50 +01:00
["<leader>th"] = {
function()
require("base46").toggle_theme()
end,
"toggle theme",
},
["<leader>te"] = {
function()
require("base46").toggle_transparency()
end,
"toggle transparency",
},
2024-01-20 01:03:01 +01:00
-- open windows
2024-01-20 03:03:39 +01:00
['<leader>"'] = { "<cmd>vsplit<cr>", "open a new window to the side" },
["<leader>%"] = { "<cmd>split<cr>", "open a new window on the totop" },
2024-01-20 01:42:31 +01:00
-- resize windows
2024-01-20 03:03:39 +01:00
["<C-Up>"] = { "<cmd>resize +1<cr>", "resize window" },
["<C-Down>"] = { "<cmd>resize -1<cr>", "resize window" },
["<C-Left>"] = { "<cmd>vertical resize +1<cr>", "resize window" },
["<C-Right>"] = { "<cmd>vertical resize -1<cr>", "resize window" },
2024-01-20 01:03:01 +01:00
-- tabs
2024-01-20 03:03:39 +01:00
["<leader>wn"] = { "<cmd>tabnew<cr>", "open a new tab" },
["<leader>wc"] = { "<cmd>tabclose<cr>", "close current tab" },
["<leader>wk"] = { "<cmd>tabnext<cr>", "go to next tab" },
["<leader>wj"] = { "<cmd>tabprevious<cr>", "go to prev tab" },
2024-01-20 01:42:31 +01:00
-- folds
2024-01-20 03:03:39 +01:00
["<S-Return>"] = { "zMzv", "focus on this fold" },
2024-01-19 22:34:37 +01:00
},
}
2024-01-20 06:05:07 +01:00
M.goto_preview = {
plugin = true,
n = {
["gpd"] = {
function()
require("goto-preview").goto_preview_definition()
end,
"go to definition preview",
noremap = true,
},
["gpD"] = {
function()
require("goto-preview").goto_preview_declaration()
end,
"go to declaration preview",
noremap = true,
},
["gpi"] = {
function()
require("goto-preview").goto_preview_implementation()
end,
"go to implementation preview",
noremap = true,
},
["gpt"] = {
function()
require("goto-preview").goto_preview_type_definition()
end,
"go to type preview",
noremap = true,
},
["gpr"] = {
function()
require("goto-preview").goto_preview_type_references()
end,
"go to references preview",
noremap = true,
},
["gpc"] = {
function()
require("goto-preview").close_all_win()
end,
"close previews",
noremap = true,
},
},
}
2024-01-19 22:34:37 +01:00
return M