From 04521bddb2c0c24a0f21ed53d8e179edc1fe9613 Mon Sep 17 00:00:00 2001 From: Dhanus M Lal Date: Wed, 10 Jul 2024 17:00:57 +0530 Subject: [PATCH] updated config --- nvim/bindings.lua | 60 ++++++++++++++++++++++++++++++++++++++++++++++- nvim/settings.lua | 6 +++-- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/nvim/bindings.lua b/nvim/bindings.lua index 0f4f6aa..79e2ebd 100644 --- a/nvim/bindings.lua +++ b/nvim/bindings.lua @@ -1,8 +1,66 @@ -- bindings -vim.keymap.set('i', 'jk', '') + +local function invert_hl () + vim.opt.hlsearch = not vim.opt.hlsearch._value +end + +-- Normal mode vim.keymap.set('n', 'l', 'l') vim.keymap.set('n', 'h', 'h') vim.keymap.set('n', 'j', 'j') vim.keymap.set('n', 'k', 'k') vim.keymap.set('n', 'sv', ':source $MYVIMRC') vim.keymap.set('n', 'ev', ':edit $MYVIMRC') +vim.keymap.set('n', 'n', invert_hl) + +-- Insert mode +vim.keymap.set('i', 'jk', '') + +-- Autocorrect +vim.cmd('inoreabbrev paht path') +vim.cmd('inoreabbrev taht that') +vim.cmd('inoreabbrev classificaton classification') +vim.cmd('inoreabbrev compnents components') +vim.cmd('inoreabbrev compnent component') +vim.cmd('inoreabbrev pythone python') +vim.cmd('inoreabbrev smaples samples') +vim.cmd('inoreabbrev sover solver') +vim.cmd('inoreabbrev souce source') + +-- Autocmds +local common_group = vim.api.nvim_create_augroup('common', {clear = true}) +local spec_group = vim.api.nvim_create_augroup('lang_spec', {clear = true}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "python", "make", "sh", "cmake" }, + callback = function(args) + vim.keymap.set('v', '#', ':normal 0i#', { buffer = args.buf }) + end, + group = 'lang_spec', + desc = "comment multiple lines for python source file" +}) + + +vim.api.nvim_create_autocmd("FileType", { + pattern = { 'c', 'cpp' }, + callback = function(args) + vim.keymap.set('v', '//', ':normal 0i//', { buffer = args.buf }) + end, + group = 'lang_spec', + desc = 'comment multiple lines for c/c++' +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { 'c', 'cpp' }, + callback = function(args) + vim.keymap.set('v', '/*', '``>i*/', { buffer = args.buf }) + end, + group = 'lang_spec', + desc = 'comment multiple lines for c/c++' +}) + +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() vim.highlight.on_yank({ timeout = 1000 }) end, + group = 'common', + desc = "briefly highlight yanked text" +}) diff --git a/nvim/settings.lua b/nvim/settings.lua index 19d7fd5..2233311 100644 --- a/nvim/settings.lua +++ b/nvim/settings.lua @@ -1,16 +1,18 @@ -- global settings vim.g.mapleader = ' ' +vim.cmd.colorscheme('habamax') vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.softtabstop = 2 vim.opt.expandtab = true +vim.opt.hlsearch = false + vim.opt.autoindent = true vim.opt.number = true vim.opt.relativenumber = true - vim.opt.cursorline = true -vim.opt.statusline = '%f %y %= C:%c L:%L %p%%' +vim.opt.statusline = '%f %m %y %= C:%c L:%L %p%%'