-- function to assist with keymapping function map(mode, lhs, rhs, opts) local options = { noremap = true, silent = true } if opts then options = vim.tbl_extend('force', options, opts) end vim.keymap.set(mode, lhs, rhs, options) end return { -- [[ Basic Keymaps ]] -- See `:help map()` -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` map('n', '', 'nohlsearch'), -- Diagnostic keymaps map('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }), -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. -- -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping -- or just use to exit terminal mode map('t', '', '', { desc = 'Exit terminal mode' }), -- Window and buffer handling -- Use CTRL+ to switch between windows -- See `:help wincmd` for a list of all window commands map('n', '', '', { desc = 'Move focus to the left window' }), map('n', '', '', { desc = 'Move focus to the right window' }), map('n', '', '', { desc = 'Move focus to the lower window' }), map('n', '', '', { desc = 'Move focus to the upper window' }), map('n', '', ':bn!', { desc = 'Go to next buffer' }), map('n', '', ':bp!', { desc = 'Go to previous buffer' }), map('n', 'bd', ':bd', { desc = 'close the current buffer' }), map('n', 'bl', ':FlyBuf', { desc = 'open up a list of all buffers in a float' }), -- terraform map('n', 'ti', ':!terraform init -no-color', { desc = 'terraform init' }), map('n', 'tv', ':!terraform validate -no-color', { desc = 'terraform validate' }), map('n', 'tp', ':!terraform plan -no-color', { desc = 'terraform plan' }), map('n', 'ta', ':!terraform apply -no-color -auto-approve', { desc = 'terraform apply' }), -- Toggles map('n', 'n', ':set number!:set relativenumber!'), map('n', 'g', ':Gitsigns toggle_signs', { desc = 'Toggle Gitsigns' }), map('n', 'l', ':set list!', { desc = 'Toggle list mode' }), map('n', 'p', ':set paste!', { desc = 'Toggle paste mode' }), }