dotfiles/nvim/lua/keymap.lua

59 lines
2.1 KiB
Lua
Raw Normal View History

function map(mode, shortcut, command)
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
end
function nmap(shortcut, command)
map('n', shortcut, command)
end
function imap(shortcut, command)
map('i', shortcut, command)
end
2022-09-19 10:28:51 +02:00
function vmap(shortcut, command)
map('v', shortcut, command)
end
2023-04-15 15:36:44 +02:00
function xmap(shortcut, command)
map('x', shortcut, command)
end
2023-04-15 15:36:44 +02:00
nmap("<SPACE>", "<Nop>")
2022-09-19 15:57:25 +02:00
nmap("<Esc><Esc>", ":noh<cr>")
2023-04-15 15:36:44 +02:00
nmap("<C-f>", ":ToggleTerm direction=float<cr>")
imap("<C-f>", ":ToggleTerm direction=float<cr>")
2022-10-13 23:53:23 +02:00
2023-04-15 15:36:44 +02:00
nmap("<C-l>", ":ToggleTerm direction=horizontal size=10<cr>")
imap("<C-l>", ":ToggleTerm direction=horizontal size=10<cr>")
2022-10-13 23:53:23 +02:00
2023-04-15 15:36:44 +02:00
xmap("p", '\"_dP')
nmap("<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>")
nmap("<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>")
nmap("<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>")
nmap("<leader>ff", "<cmd>lua require('telescope.builtin').find_files()<cr>")
2023-03-14 16:51:50 +01:00
nmap("<leader>vb", "<cmd>lua require('telescope.builtin').git_branches()<cr>")
2023-04-15 15:36:44 +02:00
nmap("<leader>b", "<cmd>lua require('telescope.builtin').buffers()<cr>")
nmap("<C-n>", ":NvimTreeToggle<cr>")
nmap("<leader>r", ":NvimTreeRefresh<cr>")
nmap("<leader>n", ":NvimTreeToggle<cr>")
nmap("<leader>zn", "zf%")
nmap("<leader>y", '\"+y')
vmap("<leader>y", '\"+y')
nmap("<F5>", ":lua require'dap'.continue()<CR>")
nmap("<F10>", ":lua require'dap'.step_over()<CR>")
nmap("<F11>", ":lua require'dap'.step_into()<CR>")
nmap("<F12>", ":lua require'dap'.step_out()<CR>")
nmap("<leader>B", ":lua require'dap'.toggle_breakpoint()<CR>")
nmap("<leader>Bc", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
nmap("<leader>lp", ":lua require'dap'.set_breakpoint(nil,nil,vim.fn.input('Log point message: '))<CR>")
nmap("<leader>lR", ":lua require'dap'.repl.open()<CR>")
nmap("<leader>dK", ":lua require'dap.ui.widgets'.hover()<CR>")
nmap("<leader>dh", ":lua require'dap.ui.variables'.visual_hover()<CR>")
nmap("<leader>d?", ":lua require'dap.ui.variables'.scopes()<CR>")
nmap("<leader>da", ":lua require'debugHelper'.attach()<CR>")