diff options
author | sinanmohd <sinan@sinanmohd.com> | 2025-08-31 15:39:39 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2025-08-31 22:28:28 +0530 |
commit | 31458b74b81df4ef5101c01b26fc28fc32ee821b (patch) | |
tree | 15846c395e3ac5aa085a30d11833b6f531abb345 /home/common/modules/neovim/config/lua/keymaps.lua | |
parent | 07854ac073b6c4a3e749078fa113367105a7af08 (diff) |
feat(home/common): init neovim
Diffstat (limited to 'home/common/modules/neovim/config/lua/keymaps.lua')
-rw-r--r-- | home/common/modules/neovim/config/lua/keymaps.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/home/common/modules/neovim/config/lua/keymaps.lua b/home/common/modules/neovim/config/lua/keymaps.lua new file mode 100644 index 0000000..b80c7db --- /dev/null +++ b/home/common/modules/neovim/config/lua/keymaps.lua @@ -0,0 +1,54 @@ +-- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` + +-- Clear highlights on search when pressing <Esc> in normal mode +-- See `:help hlsearch` +vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') + +-- Diagnostic keymaps +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' }) + +-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes +vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" }) +vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" }) +vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" }) +vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" }) + +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.hl.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('sinan-highlight-yank', { clear = true }), + callback = function() + vim.hl.on_yank() + end, +}) + +-- vim: ts=2 sts=2 sw=2 et |