local map = vim.keymap.set map('n', 'gb', 'bnext', { desc = 'Buf next' }) map('n', 'gB', 'bprevious', { desc = 'Buf prev' }) map('n', '', 'tabprev', { desc = 'Tab prev' }) map('n', '', 'bprev', { desc = 'Buf prev' }) map('n', '', 'bnext', { desc = 'Buf next' }) map('n', '', 'tabnext', { desc = 'Tab next' }) map('n', '', 'cnext', { desc = 'Quickfix next' }) map('n', '', 'cprev', { desc = 'Quickfix prev' }) map('v', '<', '', '>gv', { desc = 'Outdent' }) map('t', '', [[ ]], { desc = 'Terminal: Exit INSERT mode' }) map( 'n', 'gx', 'lua vim.ui.open(vim.fn.expand(""))', { desc = 'Open file under cursor' } ) vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, { group = vim.api.nvim_create_augroup('bufclose', {}), callback = function() if (vim.fn.maparg('q', 'n') == '') and vim.list_contains({ 'help', 'nofile', 'nowrite', 'quickfix' }, vim.bo.buftype) then map('n', 'q', 'close', { desc = 'Close buffer', buffer = 0 }) end end, }) map('n', 'x', function() local file = vim.fn.expand('%') vim.cmd.source(file) vim.notify('** sourced ' .. file, vim.log.levels.INFO) end, { desc = 'source current file' }) map('n', 'a', 'edit #', { desc = 'open alternative file' }) -- yank buffer name map('n', ';yb', [[let @+ = expand('%')]], { desc = 'yank buffer name' }) map('n', ';yn', [[let @+ = expand('%:t')]], { desc = 'yank filename' }) map('n', ';yp', [[let @+ = expand('%:p')]], { desc = 'yank path' })