From 0cc4ed7dd6fc5b06de245246723138996d449571 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Fri, 14 Jul 2023 22:49:04 +0530 Subject: nvim: Adding basic neovim config --- .config/nvim/lua/justsaumit/keymaps.lua | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .config/nvim/lua/justsaumit/keymaps.lua (limited to '.config/nvim/lua/justsaumit/keymaps.lua') diff --git a/.config/nvim/lua/justsaumit/keymaps.lua b/.config/nvim/lua/justsaumit/keymaps.lua new file mode 100644 index 0000000..ebe355a --- /dev/null +++ b/.config/nvim/lua/justsaumit/keymaps.lua @@ -0,0 +1,72 @@ +local opts = { noremap = true, silent = true } + +-- Shorten function name +local keymap = vim.keymap.set + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +---Autocompile and Execute +--ANSI C +vim.cmd([[autocmd BufEnter *.c map :w :!gcc % -ansi -o %< && ./%< ]]) +--C99 +vim.cmd([[autocmd BufEnter *.c map :w :!gcc -std=c99 % -o %< && ./%< ]]) +--C +vim.cmd([[autocmd BufEnter *.c map :w :!gcc % -o %< && ./%< ]]) + +--C++ +vim.cmd([[autocmd BufEnter *.cpp map :w :!g++ % -o %< && ./%< ]]) + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- command_mode = "c", + +-- Normal -- +-- +-- +--Save file with Ctrl+S +keymap("n", "", ":w", opts) +--Toggle nvim-tree +keymap("n", "", ":NvimTreeToggle", opts) +--Disable C-e +keymap("n", "", ":", opts) + +-- Better window navigation for split +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +-- Resize with arrows +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) + +-- Move text up and down(better implementation in visual mode) +--keymap("n", "", ":m .+1==gi", opts) +--keymap("n", "", ":m .-2==gi", opts) + +-- Insert -- + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- Move text up and down +keymap("v", "", ":m .+1==", opts) +keymap("v", "", ":m .-2==", opts) +keymap("v", "p", '"_dP', opts) + +-- Visual Block -- +-- Move text up and down +keymap("x", "J", ":move '>+1gv-gv", opts) +keymap("x", "K", ":move '<-2gv-gv", opts) +keymap("x", "", ":move '>+1gv-gv", opts) +keymap("x", "", ":move '<-2gv-gv", opts) -- cgit v1.2.3