-- This file is responsible for setting up the keymaps

local mapkey = require("util.keymapper").mapvimkey

-- Buffer Navigation
mapkey("<leader>bn", "bnext", "n") -- Next buffer
mapkey("<leader>bp", "bprevious", "n") -- Prev buffer
mapkey("<leader>bd", "bdelete", "n") -- Del buffer
mapkey("<leader>bb", "e #", "n") -- Switch to Other Buffer
-- mapkey("<leader>`", "e #", "n") -- Switch to Other Buffer

-- Directory Navigation (File Tree)
mapkey("<leader>e", "NvimTreeToggle", "n") -- Toggle File tree
-- mapkey("<leader>m", "NvimTreeFocus", "n") -- Move focus to file tree

-- Pane and Window Navigation
mapkey("<C-h>", "<C-w>h", "n") -- Navigate Left
mapkey("<C-j>", "<C-w>j", "n") -- Navigate Down
mapkey("<C-k>", "<C-w>k", "n") -- Navigate Up
mapkey("<C-l>", "<C-w>l", "n") -- Navigate Right
mapkey("<C-h>", "wincmd h", "t") -- Navigate Left
mapkey("<C-j>", "wincmd j", "t") -- Navigate Down
mapkey("<C-k>", "wincmd k", "t") -- Navigate Up
mapkey("<C-l>", "wincmd l", "t") -- Navigate Right
mapkey("<C-h>", "TmuxNavigateLeft", "n") -- Navigate Left
mapkey("<C-j>", "TmuxNavigateDown", "n") -- Navigate Down
mapkey("<C-k>", "TmuxNavigateUp", "n") -- Navigate Up
mapkey("<C-l>", "TmuxNavigateRight", "n") -- Navigate Right

-- Window Management
mapkey("<leader>sv", "vsplit", "n") -- Split Vertically
mapkey("<leader>sh", "split", "n") -- Split Horizontally
mapkey("<C-Up>", "resize +2", "n")
mapkey("<C-Down>", "resize -2", "n")
mapkey("<C-Left>", "vertical resize +2", "n")
mapkey("<C-Right>", "vertical resize -2", "n")

-- Show Full File-Path
mapkey("<leader>pa", "file", "n") -- Show Full File Path

-- Indenting
vim.keymap.set("v", "<", "<gv", { silent = true, noremap = true }) -- Indent left in v mode
vim.keymap.set("v", ">", ">gv", { silent = true, noremap = true }) -- Indent right in v mode

local api = vim.api

-- Escaping vim modes
vim.api.nvim_set_keymap("i", "jk", "<ESC>", { noremap = false })
vim.api.nvim_set_keymap("v", "jk", "<ESC>", { noremap = false })

-- Comments

if vim.env.TMUX ~= nil then
	api.nvim_set_keymap("n", "<C-_>", "gtc", { noremap = false })
	api.nvim_set_keymap("v", "<C-_>", "goc", { noremap = false })
else
	api.nvim_set_keymap("n", "<C-/>", "gtc", { noremap = false })
	api.nvim_set_keymap("v", "<C-/>", "goc", { noremap = false })
end

-- DAP (Debugger Adapter Protocol)
mapkey("<leader>db", "DapToggleBreakpoint", "n")
mapkey("<F5>", "DapContinue", "n")
mapkey("<F6>", "DapStepOver", "n")
mapkey("<F7>", "DapStepInto", "n")
mapkey("<F8>", "DapStepOut", "n")
