-- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') vim.keymap.set('n', 'e', function() require('neo-tree.command').execute { toggle = true, dir = vim.uv.cwd() } end) -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) vim.keymap.set('n', ']e', function() vim.diagnostic.jump { forward = true, float = true, count = 1, severity = 'ERROR' } end, { desc = 'Go to next diagnostic' }) vim.keymap.set('n', '[e', function() vim.diagnostic.jump { forward = false, float = true, count = 1, severity = 'ERROR' } end, { desc = 'Go to previous diagnostic' }) vim.keymap.set('n', ']w', function() vim.diagnostic.jump { forward = true, float = true, count = 1, severity = 'WARN' } end, { desc = 'Go to next diagnostic' }) vim.keymap.set('n', '[w', function() vim.diagnostic.jump { forward = false, float = true, count = 1, severity = 'WARN' } end, { desc = 'Go to previous diagnostic' }) vim.keymap.set('n', 'cd', vim.diagnostic.open_float, { desc = 'Line Diagnostics' }) -- 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 vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- TIP: Disable arrow keys in normal mode -- vim.keymap.set('n', '', 'echo "Use h to move!!"') -- vim.keymap.set('n', '', 'echo "Use l to move!!"') -- vim.keymap.set('n', '', 'echo "Use k to move!!"') -- vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows -- -- See `:help wincmd` for a list of all window commands vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) -- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes -- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) -- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` -- buffers local function close_other_buffers() local current = vim.api.nvim_get_current_buf() local bufs = vim.api.nvim_list_bufs() for _, buf in ipairs(bufs) do if vim.api.nvim_buf_is_loaded(buf) and buf ~= current then vim.api.nvim_buf_delete(buf, { force = true }) end end end vim.keymap.set('n', 'bd', ':bd', { desc = 'Close current buffer' }) vim.keymap.set('n', 'bo', close_other_buffers, { desc = 'Close all buffers except current' })