diff options
author | Damjan 9000 <damjan.9000@gmail.com> | 2024-02-26 20:46:46 +0100 |
---|---|---|
committer | Damjan 9000 <damjan.9000@gmail.com> | 2024-02-26 21:15:29 +0100 |
commit | 1ff3a155aab8ef8f9d14b51c382319fcd14e4da3 (patch) | |
tree | ff8e7695094365a18c3ca21bda1bd3f0bcf83444 /lua/keymaps.lua | |
parent | 4e7e6642a6a5b76c0dbb0e86748fcb12b4c95012 (diff) | |
parent | 8b5d48a199c02658e399f5b43ff8d06df1ede7fb (diff) |
Merge 'upstream/master' rewrite: slimmer, trimmer and more lazy kickstart.nvim
Diffstat (limited to 'lua/keymaps.lua')
-rw-r--r-- | lua/keymaps.lua | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/lua/keymaps.lua b/lua/keymaps.lua index f821e65..56a118f 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -1,28 +1,47 @@ -- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +-- Set highlight on search, but clear on pressing <Esc> in normal mode +vim.opt.hlsearch = true +vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') -- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) +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' }) +vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) +vim.keymap.set('n', '<leader>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 <C-\><C-n>, 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 <C-\><C-n> to exit terminal mode +vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }) + +-- TIP: Disable arrow keys in normal mode +-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>') +-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>') +-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>') +-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>') + +-- Keybinds to make split navigation easier. +-- Use CTRL+<hjkl> to switch between windows +-- +-- 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' }) --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` vim.api.nvim_create_autocmd('TextYankPost', { + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() vim.highlight.on_yank() end, - group = highlight_group, - pattern = '*', }) -- vim: ts=2 sts=2 sw=2 et |