neovim-confs/lua/custom/mappings.lua

351 lines
7.7 KiB
Lua
Raw Normal View History

2024-01-19 22:34:37 +01:00
---@type MappingsTable
local M = {}
M.disabled = {
n = {
["<C-a>"] = "",
["<C-s>"] = "",
2024-01-19 23:44:07 +01:00
["<C-c>"] = "",
["<leader>n"] = "",
["<leader>rn"] = "",
["<Up>"] = "",
["<Down>"] = "",
["<leader>x"] = "",
["<leader>/"] = "",
["<leader>ra"] = "",
["[d"] = "",
["]d"] = "",
["[c"] = "",
["]c"] = "",
["<leader>h"] = "",
["<leader>ff"] = "",
["<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"] = "",
},
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-x>"] = {
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",
},
2024-01-19 22:34:37 +01:00
},
2024-01-19 23:13:23 +01:00
}
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",
},
},
2024-01-19 22:34:37 +01:00
}
M.lazygit = {
plugin = true,
n = {
["<leader>gg"] = { "<cmd> LazyGit <CR>", "Open LazyGit" },
},
}
2024-01-19 23:44:07 +01:00
M.lspconfig = {
plugin = true,
n = {
["[d"] = {
function()
vim.diagnostic.goto_prev { float = { border = "rounded" } }
end,
"Goto prev",
},
["<leader>cj"] = {
function()
vim.diagnostic.goto_next { float = { border = "rounded" } }
end,
"Goto next",
},
},
}
2024-01-19 22:34:37 +01:00
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" },
},
}
2024-01-19 23:44:07 +01:00
M.nvterm = {
plugin = true,
t = {
-- preserve defaults
},
n = {
-- preserve defaults
},
}
2024-01-19 22:34:37 +01:00
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" },
},
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
2024-01-19 23:13:23 +01:00
-- "J" for join is defaul
2024-01-19 23:44:07 +01:00
["S"] = {
2024-01-20 00:37:13 +01:00
"i<CR><ESC>l",
2024-01-19 23:44:07 +01:00
"split line",
},
2024-01-19 22:34:37 +01:00
-- 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 } },
2024-01-20 00:37:13 +01:00
["<LEFT>"] = { "<cmd> << <CR>", "Less indentation", opts = { expr = true } },
["<RIGHT>"] = { "<cmd> >> <CR>", "More indentation", opts = { expr = true } },
2024-01-19 22:34:37 +01:00
-- format with conform
["<leader>ff"] = {
function()
require("conform").format()
end,
2024-01-20 00:37:13 +01:00
"format buffer",
},
--
-- remove trailing whitespace
["<leader>fw"] = {
function()
require('mini.trailspace').trim()
end,
"remove whitespace",
2024-01-19 22:34:37 +01:00
},
},
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",
},
},
}
-- more keybinds!
return M