local map = vim.api.nvim_set_keymap
local opts = { noremap=true, silent=true }

-- move lines around
map('n', '<A-Down>', ':m .+1<CR>==', opts)
map('n', '<A-Up>', ':m .-2<CR>==', opts)
map('i', '<A-Down>', '<Esc>:m .+1<CR>==gi', opts)
map('i', '<A-Up>', '<Esc>:m .-2<CR>==gi', opts)
map('v', '<A-Down>', ":m '>+1<CR>gv=gv", opts)
map('v', '<A-Up>', ":m '<-2<CR>gv=gv", opts)

-- Quickfix and location lists key mappings
map('n','<space>cf', ':cfirst<CR>', opts)
map('n','<space>cn', ':cnext<CR>', opts)
map('n','<space>cp', ':cprevious<CR>', opts)
map('n','<space>co', ':copen<CR>', opts)
map('n','<space>cc', ':cexpr [] | cclose<CR>', opts)
map('n','<space>lf', ':lfirst<CR>', opts)
map('n','<space>ln', ':lnext<CR>', opts)
map('n','<space>lp', ':lprevious<CR>', opts)
map('n','<space>lo', ':lopen<CR>', opts)
map('n','<space>lc', ':lclose<CR>', opts)

-- Easier to exit terminal insert mode with Esc
map('t', '<Esc>', '<C-\\><C-n>', opts)
