neovim-confs/lua/custom/mappings.lua

396 lines
9.3 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>"] = "",
2024-01-20 01:42:31 +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 01:42:31 +01:00
["<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"] = "",
2024-01-20 01:03:01 +01:00
["#"] = "",
["?"] = "",
2024-01-19 23:44:07 +01:00
},
t = {
["<C-t>"] = "",
},
v = {
2024-01-20 01:03:01 +01:00
["#"] = "",
["?"] = "",
2024-01-20 01:42:31 +01:00
["<LEADER>/"] = "",
2024-01-19 23:44:07 +01:00
},
}
M.tabufline = {
plugin = true,
n = {
-- cycle through buffers
2024-01-20 01:42:31 +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 01:42:31 +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 01:42:31 +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 01:42:31 +01:00
["<LEADER>s"] = {
"<PLUG>(leap-forward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 01:42:31 +01:00
["<LEADER>S"] = {
"<PLUG>(leap-backward)",
2024-01-19 23:13:23 +01:00
"leap backward",
},
2024-01-20 01:42:31 +01:00
["<LEADER>gs"] = {
"<PLUG>(leap-from-window)",
2024-01-19 23:13:23 +01:00
"leap from window",
},
},
x = {
2024-01-20 01:42:31 +01:00
["<LEADER>s"] = {
"<PLUG>(leap-forward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 01:42:31 +01:00
["<LEADER>S"] = {
"<PLUG>(leap-backward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 01:42:31 +01:00
["<LEADER>gs"] = {
"<PLUG>(leap-from-window)",
2024-01-19 23:13:23 +01:00
"leap from window",
},
},
o = {
2024-01-20 01:42:31 +01:00
["<LEADER>s"] = {
"<PLUG>(leap-forward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 01:42:31 +01:00
["<LEADER>S"] = {
"<PLUG>(leap-backward)",
2024-01-19 23:13:23 +01:00
"leap forward",
},
2024-01-20 01:42:31 +01:00
["<LEADER>gs"] = {
"<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 01:42:31 +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 01:42:31 +01:00
["<LEADER>ck"] = {
2024-01-19 23:44:07 +01:00
function()
vim.diagnostic.goto_prev { float = { border = "rounded" } }
end,
"Goto prev",
},
2024-01-20 01:42:31 +01:00
["<LEADER>cj"] = {
2024-01-19 23:44:07 +01:00
function()
vim.diagnostic.goto_next { float = { border = "rounded" } }
end,
"Goto next",
},
},
}
2024-01-19 22:34:37 +01:00
M.clipboard = {
plugin = false,
n = {
2024-01-20 01:42:31 +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 01:42:31 +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 01:42:31 +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 01:42:31 +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 01:42:31 +01:00
["<LOCALLEADER>pt"] = { "<CMD> Telescope terms <CR>", "Pick hidden term" },
2024-01-19 22:34:37 +01:00
-- theme switcher
2024-01-20 01:42:31 +01:00
["<LOCALLEADER>th"] = { "<CMD> Telescope themes <CR>", "Nvchad themes" },
2024-01-19 22:34:37 +01:00
2024-01-20 01:42:31 +01:00
["<LOCALLEADER>ma"] = { "<CMD> Telescope marks <CR>", "telescope bookmarks" },
2024-01-19 22:34:37 +01:00
},
}
2024-01-19 23:44:07 +01:00
M.nvterm = {
plugin = true,
t = {
-- preserve defaults
2024-01-20 01:03:01 +01:00
["<F12>"] = {
function()
require("nvterm.terminal").toggle "float"
end,
"Toggle floating term",
},
2024-01-19 23:44:07 +01:00
},
n = {
-- preserve defaults
2024-01-20 01:03:01 +01:00
["<F12>"] = {
function()
require("nvterm.terminal").toggle "float"
end,
"Toggle floating term",
},
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 01:42:31 +01:00
["<C-n>"] = { "<CMD> NvimTreeToggle <CR>", "Toggle nvimtree" },
["<F5>"] = { "<CMD> NvimTreeToggle <CR>", "Toggle nvimtree" },
2024-01-19 22:34:37 +01:00
-- focus
2024-01-20 01:42:31 +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
["<C-b>"] = { "<HOME>", "Beginning of line" },
2024-01-20 01:42:31 +01:00
["<C-e>"] = { "<END>", "End of line" },
2024-01-19 22:34:37 +01:00
-- navigate within insert mode
2024-01-20 01:42:31 +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
["H"] = { "<HOME>", "Beginning of line" },
2024-01-20 01:42:31 +01:00
["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
["zn"] = { "]s", "go to next spelling mark"},
["zN"] = { "[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
["H"] = { "<HOME>", "Beginning of line" },
2024-01-20 01:42:31 +01:00
["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
["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
2024-01-20 01:42:31 +01:00
["<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 } },
2024-01-19 22:34:37 +01:00
-- format with conform
2024-01-20 01:42:31 +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",
},
--
-- remove trailing whitespace
2024-01-20 01:42:31 +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
},
},
v = {
["<LEFT>"] = { "<gv", "Less indentation" },
["<RIGHT>"] = { ">gv", "More indentation" },
},
x = {
2024-01-20 01:42:31 +01:00
["<UP>"] = { "move'<-2<CR>gv=gv", "Move line up", opts = { expr = true } },
["<DOWN>"] = { "move'<-2<CR>gv=gv", "Move line down", opts = { expr = true } },
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 01:42:31 +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 01:42:31 +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 01:03:01 +01:00
-- open windows
2024-01-20 01:42:31 +01:00
['<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" },
2024-01-20 01:03:01 +01:00
-- tabs
2024-01-20 01:42:31 +01:00
["<LEADER>wtn"] = { "<CMD>tabnew<CR>", "open a new tab" },
["<LEADER>wtc"] = { "<CMD>tabclose<CR>", "close current tab" },
["<LEADER>wtj"] = { "<CMD>tabnext<CR>", "open a new tab" },
["<LEADER>wtk"] = { "<CMD>tabprevious<CR>", "open a new tab" },
-- folds
["<S-RETURN>"] = { "zMzv", "focus on this fold" },
2024-01-19 22:34:37 +01:00
},
}
return M