local u = require("util")
local m, f = u.cmd_map, u.key_map

-- Normal maps
f("0", "^")
f("-", "0")

-- Maps
m("<leader>w", "up")
m("<leader>W", "wa")
m("<leader>qa", "qa")
m("<leader>qq", "q")
m("<leader>qo", "WinOnly")
m("<leader>ql", "WinOnlyFocusLeft")
m("<leader>qh", "WinOnlyFocusRight")
m("<leader>qj", "WinOnlyFocusDown")
m("<leader>qk", "WinOnlyFocusUp")
m("<leader>qc", "QuickFixClear")
m("<leader>qf", "cwindow")
--  TODO: 2024-06-28 - Create function to cycle through quickfixes
m("<leader>qn", "silent! cnewer")
m("<leader>qp", "silent! colder")
m("[q", "silent! cprev")
m("]q", "silent! cnext")
m("<leader>bn", "bn")
m("<leader>bp", "bp")
m("<leader>bq", "Bdelete")
m("<leader>bd", "bd")
m("<leader>bu", "bufdo :Bdelete")
m("<leader>bo", "BufOnlyWindowOnly")
m("<leader>be", "new")
m("<leader>so", "only")
m("<leader><", "vertical resize -10")
m("<leader>>", "vertical resize +10")
m("<leader>-", "resize -10")
m("<leader>+", "resize +10")
m("<leader>tt", "TermOpenTab")
m("<leader>tj", "TermOpenBottom")
m("<leader>tJ", "TermOpenBottomResized")
m("<leader>ts", "TermOpenBottomVert")
m("<leader>tl", "TermOpenRight")
m("<leader>tL", "TermOpenRightResized")
m("<leader>tq", "tabclose")
m("<leader>tp", "InspectTree")
m("<leader>tc", "MakeOpenQF")

-- User commands
m("<leader>cz", "ToggleCmdHeight")
m({ "<bs>", "<del>" }, "LoadPreviousBuffer")
m("[t", "TagStackUp")
m("]t", "TagStackDown")
m("[p", "SpotifyPrev", { "n", "t" })
m("]p", "SpotifyNext", { "n", "t" })
m("<leader>cp", "CommentYankPaste", { "n", "x" })
m("<leader>hw", "HelpWord")
m("K", "HoverHandler")
m("<leader><Tab>", "TabPrevious")
m("<leader><S-Tab>", "TabNext")
m("<leader>df", "ConformFormatToggle")
m("<leader>dF", "ConformFormatToggle!")
m("<leader>z", "TestingFunction")
m("<leader>'", "FoldParagraph")

vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "J", "mzJ`z")
