config/.config/nvim/lua/user/keymaps.lua
2022-10-11 21:59:03 +10:30

50 lines
1014 B
Lua

local opts = { noremap = true, silent = true }
local map = vim.api.nvim_set_keymap
-- set Space as leader key
map("n", "<Space>", "", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- NORMAL
-- Move text up and down
map("n", "<C-k>", "<ESC>:m .-2<CR>==", opts)
map("n", "<C-j>", "<ESC>:m .+1<CR>==", opts)
-- Copy/Paste
map("n", "<C-y>", '"+y', opts)
map("n", "<C-p>", '"+y', opts)
-- Save
map("n", "<C-s>", ":w<CR>", opts)
-- Switch between buffers
map("n", "<S-l>", ":CybuNext<CR>", opts)
map("n", "<S-h>", ":CybuPrev<CR>", opts)
-- Show definition
map("n", "<S-k>", ":lua vim.lsp.buf.hover()<CR>", opts)
-- INSERT
-- Easy exit insert mode
map("i", "jk", "<ESC>", opts)
-- Paste
map("i", "<C-p>", '"+y', opts)
-- Save
map("i", "<C-s>", "<ESC>:w<CR>a", opts)
-- VISUAL
-- Indenting
map("v", "<", "<gv", opts)
map("v", ">", ">gv", opts)
-- Move text up and down
map("v", "<C-j>", ":m .+1<CR>==<ESC>V", opts)
map("v", "<C-k>", ":m .-2<CR>==<ESC>V", opts)
-- Copy
map("v", "<C-y>", '"+y', opts)