61 lines
3.5 KiB
Lua
61 lines
3.5 KiB
Lua
--------------------------------------------------------------------------------
|
|
-- Toggles
|
|
--------------------------------------------------------------------------------
|
|
-- Clear highlighted searched on pressing <Esc> in normal mode
|
|
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>', { desc = 'Hide search results' })
|
|
|
|
-- line numbers
|
|
vim.keymap.set('n', '<leader>tn', '<cmd> set nu! <cr>', { desc = '[T]oggle line [N]umbers' })
|
|
vim.keymap.set('n', '<leader>trn', '<cmd> set rnu! <cr>', { desc = '[T]oggle [R]elative line [N]umbers' })
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Insert movements
|
|
--------------------------------------------------------------------------------
|
|
-- go to beginning and end
|
|
vim.keymap.set('i', '<C-s>', '<esc>^i', { desc = 'Go to the start of the line' })
|
|
vim.keymap.set('i', '<C-e>', '<End>', { desc = 'Go to the end of the line' })
|
|
vim.keymap.set('i', '<C-w>', '<esc>wa', { desc = 'Go a word further' })
|
|
vim.keymap.set('i', '<C-b>', '<esc>ba', { desc = 'Go a word backward' })
|
|
|
|
-- navigate within insert mode
|
|
vim.keymap.set('i', '<C-h>', '<Left>', { desc = 'Move left' })
|
|
vim.keymap.set('i', '<C-j>', '<Right>', { desc = 'Move right' })
|
|
vim.keymap.set('i', '<C-k>', '<Down>', { desc = 'Move down' })
|
|
vim.keymap.set('i', '<C-l>', '<Up>', { desc = 'Move up' })
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Workspace, buffer and window manipulation
|
|
--------------------------------------------------------------------------------
|
|
-- split windows
|
|
vim.keymap.set('n', '<leader>"', '<cmd>vsplit<cr>', { desc = 'Split the window vertically' })
|
|
vim.keymap.set('n', '<leader>%', '<cmd>split<cr>', { desc = 'Split the window horizontally' })
|
|
|
|
-- window actions
|
|
vim.keymap.set('n', '<leader>wbn', '<cmd>enew<cr>', { desc = 'Open a [N]ew [B]uffer' })
|
|
vim.keymap.set('n', '<leader>wbc', '<cmd>bw<cr>', { desc = '[C]lose current [B]uffer' }) -- :bd would keep in background
|
|
vim.keymap.set('n', '<C-Up>', '<cmd>resize +1<cr>', { desc = 'Resize window' })
|
|
vim.keymap.set('n', '<C-Down>', '<cmd>resize -1<cr>', { desc = 'Resize window' })
|
|
vim.keymap.set('n', '<C-Left>', '<cmd>vertical resize +1<cr>', { desc = 'Resize window vertically' })
|
|
vim.keymap.set('n', '<C-Right>', '<cmd>vertical resize -1<cr>', { desc = 'Resize window vertically' })
|
|
|
|
|
|
-- tabs/workspaces
|
|
vim.keymap.set('n', '<leader>wn', '<cmd>tabnew<cr>', { desc = 'Open a [N]ew [W]orkspace/Tab' })
|
|
vim.keymap.set('n', '<leader>wc', '<cmd>tabclose<cr>', { desc = '[C]lose a [W]orkspace/Tab' })
|
|
vim.keymap.set('n', '<leader>wk', '<cmd>tabnext<cr>', { desc = 'Next [W]orkspace/Tab' })
|
|
vim.keymap.set('n', '<leader>wj', '<cmd>tabprevious<cr>', { desc = 'Last [W]orkspace/Tab' })
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Move to things
|
|
--------------------------------------------------------------------------------
|
|
-- move to window
|
|
-- See `:help wincmd` for a list of all window commands
|
|
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
|
|
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
|
|
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
|
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
|
|
|
-- diagnostics
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
|