neovim-confs/lua/custom/mappings.lua

399 lines
9.4 KiB
Lua

---@type MappingsTable
local M = {}
-- NOTE: The mappings here are case sensitive!!! Removing a specific default
-- mapping requires the same case here!
M.disabled = {
n = {
["<C-a>"] = "",
["<C-s>"] = "",
["<C-c>"] = "",
["<leader>n"] = "",
["<leader>rn"] = "",
["<Up>"] = "",
["<Down>"] = "",
["<leader>x"] = "",
["<leader>/"] = "",
["<leader>ra"] = "",
["[d"] = "",
["]d"] = "",
["[c"] = "",
["]c"] = "",
["<leader>h"] = "",
["<leader>ff"] = "",
["<leader>fm"] = "",
["<leader>fa"] = "",
["<leader>fw"] = "",
["<leader>fb"] = "",
["<leader>fh"] = "",
["<leader>fo"] = "",
["<leader>fz"] = "",
["<leader>cm"] = "",
["<leader>gt"] = "",
["<leader>pt"] = "",
["<leader>th"] = "",
["<leader>ma"] = "",
["<leader>v"] = "",
["<leader>rh"] = "",
["<leader>ph"] = "",
["<leader>gb"] = "",
["<leader>td"] = "",
["<leader>wk"] = "",
["#"] = "",
["?"] = "",
},
t = {
["<C-t>"] = "",
},
v = {
["#"] = "",
["?"] = "",
["<leader>/"] = "",
},
}
M.tabufline = {
plugin = true,
n = {
-- cycle through buffers
["<Tab>"] = {
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
["<A-c>"] = {
function()
require("nvchad.tabufline").close_buffer()
end,
"Close buffer",
},
},
}
M.comment = {
plugin = true,
-- toggle comment in both modes
n = {
["<leader>v"] = {
function()
require("Comment.api").toggle.linewise.current()
end,
"Toggle comment",
},
},
v = {
["<leader>v"] = {
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>",
"Toggle comment",
},
},
}
M.leap = {
plugin = true,
n = {
["<leader>s"] = {
"<plug>(leap-forward)",
"leap forward",
},
["<leader>S"] = {
"<plug>(leap-backward)",
"leap backward",
},
["<leader>gs"] = {
"<plug>(leap-from-window)",
"leap from window",
},
},
x = {
["<leader>s"] = {
"<plug>(leap-forward)",
"leap forward",
},
["<leader>S"] = {
"<plug>(leap-backward)",
"leap forward",
},
["<leader>gs"] = {
"<plug>(leap-from-window)",
"leap from window",
},
},
o = {
["<leader>s"] = {
"<plug>(leap-forward)",
"leap forward",
},
["<leader>S"] = {
"<plug>(leap-backward)",
"leap forward",
},
["<leader>gs"] = {
"<plug>(leap-from-window)",
"leap from window",
},
},
}
M.lazygit = {
plugin = true,
n = {
["<leader>gg"] = { "<cmd> LazyGit <cr>", "Open LazyGit" },
},
}
M.lspconfig = {
plugin = true,
n = {
["[d"] = {
function()
vim.diagnostic.goto_prev { float = { border = "rounded" } }
end,
"Goto prev",
},
["]d"] = {
function()
vim.diagnostic.goto_next { float = { border = "rounded" } }
end,
"Goto next",
},
},
}
M.clipboard = {
plugin = false,
n = {
["<leader>y"] = { '"+y', "yank to system" },
["<leader>Y"] = { '"+Y', "yank to system" },
["<leader>yy"] = { '"+y', "yank to system" },
},
v = {
["<leader>y"] = { '"+y', "yank to system" },
["<leader>Y"] = { '"+Y', "yank to system" },
["<leader>yy"] = { '"+y', "yank to system" },
},
}
M.telescope = {
plugin = true,
n = {
-- find
["<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" },
-- git
["<localleader>cm"] = { "<cmd> Telescope git_commits <cr>", "Git commits" },
["<localleader>gt"] = { "<cmd> Telescope git_status <cr>", "Git status" },
-- pick a hidden term
["<localleader>pt"] = { "<cmd> Telescope terms <cr>", "Pick hidden term" },
-- theme switcher
["<localleader>th"] = { "<cmd> Telescope themes <cr>", "Nvchad themes" },
["<localleader>ma"] = { "<cmd> Telescope marks <cr>", "telescope bookmarks" },
},
}
M.nvterm = {
plugin = true,
t = {
-- preserve defaults
["<F12>"] = {
function()
require("nvterm.terminal").toggle "float"
end,
"Toggle floating term",
},
},
n = {
-- preserve defaults
["<F12>"] = {
function()
require("nvterm.terminal").toggle "float"
end,
"Toggle floating term",
},
},
}
M.nvimtree = {
plugin = true,
n = {
-- toggle
["<C-n>"] = { "<cmd> NvimTreeToggle <cr>", "Toggle nvimtree" },
["<F5>"] = { "<cmd> NvimTreeToggle <cr>", "Toggle nvimtree" },
-- focus
["<localleader>e"] = { "<cmd> NvimTreeFocus <cr>", "Focus nvimtree" },
},
}
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
["<C-b>"] = { "<home>", "Beginning of line" },
["<C-e>"] = { "<end>", "End of line" },
-- navigate within insert mode
["<C-h>"] = { "<left>", "Move left" },
["<C-l>"] = { "<right>", "Move right" },
["<C-j>"] = { "<down>", "Move down" },
["<C-k>"] = { "<up>", "Move up" },
},
n = {
--big move
["<A-k>"] = { "<C-u>", "big step down" },
["<A-j>"] = { "<C-d>", "big step down" },
-- go to beginning and end
["H"] = { "<home>", "Beginning of line" },
["L"] = { "<end>", "End of line" },
-- go to mark with "#"
["#"] = { "'", "go to mark" },
-- spell
["]s"] = { "]s", "go to next spelling mark"},
["[s"] = { "[s", "go to last spelling mark"},
},
v = {
--big move
["<A-k>"] = { "<C-u>", "big step down" },
["<A-j>"] = { "<C-d>", "big step down" },
-- go to beginning and end
["H"] = { "<home>", "Beginning of line" },
["L"] = { "<end>", "End of line" },
},
t = {
["<C-w>"] = {
vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true),
"Escape terminal mode",
},
},
}
M.edit = {
plugin = false,
n = {
-- easy newline
["OO"] = { "O<esc>", "insert a line above", opts = { nowait = false } },
["oo"] = { "o<esc>", "insert a line below", opts = { nowait = false } },
-- split and join lines
-- "J" for join is defaul
["S"] = {
"i<cr><esc>l",
"split line",
},
-- do something useful with the arrows
["<Up>"] = { "<cmd> move-2<cr>", "Move line up", opts = { expr = true } },
["<Down>"] = { "<cmd> move+<cr>", "Move line down", opts = { expr = true } },
["<Left>"] = { "<cmd> << <cr>", "Less indentation", opts = { expr = true } },
["<Right>"] = { "<cmd> >> <cr>", "More indentation", opts = { expr = true } },
-- format with conform
["<leader>ff"] = {
function()
require("conform").format()
end,
"format buffer",
},
--
-- remove trailing whitespace
["<leader>fw"] = {
function()
require("mini.trailspace").trim()
end,
"remove whitespace",
},
},
v = {
["<Left>"] = { "<gv", "Less indentation" },
["<Right>"] = { ">gv", "More indentation" },
},
x = {
["<Up>"] = { "move'<-2<cr>gv=gv", "Move line up", opts = { expr = true } },
["<Down>"] = { "move'<-2<cr>gv=gv", "Move line down", opts = { expr = true } },
},
t = {
--big move
["<A-k>"] = { "<C-u>", "big step down" },
["<A-j>"] = { "<C-d>", "big step down" },
},
}
M.ui = {
plugin = false,
n = {
-- toggle wrap
["<leader>tw"] = {
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",
},
-- toggle some features
["<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" },
-- open windows
['<leader>"'] = { "<cmd>vsplit<cr>", "open a new window to the side" },
["<leader>%"] = { "<cmd>split<cr>", "open a new window on the totop" },
-- resize windows
["<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" },
-- tabs
["<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" },
-- folds
["<S-Return>"] = { "zMzv", "focus on this fold" },
},
}
return M