diff --git a/Readme.md b/Readme.md index 409cd3a..b9f68e4 100644 --- a/Readme.md +++ b/Readme.md @@ -2,4 +2,4 @@ I've always been fascinated with vim and had been functioning with other's customized vim configs. Felt like working with a crutch. Decided to take things in my own hands and try to learn the "modern" vim ecosystem and start with nvim. Tried NvChad but the native lsp just didn't sit right with me, and also felt like I'm diving down the same path of using somebody else's customized setups. And so this repo was born. -Born a timeline of how and what things have changed, go through the commit history. +To see a timeline of how and what things have changed, go through the commit history. diff --git a/init.lua b/init.lua index f145519..86565ba 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,3 @@ -- require necessary modules require('macbook.settings') - +require('macbook.keybindings') diff --git a/lua/macbook/keybindings.lua b/lua/macbook/keybindings.lua new file mode 100644 index 0000000..53fa10b --- /dev/null +++ b/lua/macbook/keybindings.lua @@ -0,0 +1,48 @@ +local function map(m, k, v) + vim.keymap.set(m, k, v, { silent = true }) +end + +-- Fix * (keep the cursor position, don't move to next match) +-- map('n', '*', '*N') + +-- Fix n and N. This keeps cursor always in the center when jumping between next and previous matches. +map('n', 'n', 'nzz') +map('n', 'N', 'Nzz') + +-- Mimic shell movements +map('i', '', '$') +map('i', '', '^') + +-- Quickly save the current buffer or all buffers +map('n', 'w', 'update') +map('n', 'W', 'wall') + +-- Quit neovim +map('n', '', 'q') + +-- leader-o/O inserts blank line below/above. Comes in handly when inserting blank lines between code blocks. +map('n', 'o', 'o') +map('n', 'O', 'O') + +-- Move to the next/previous buffer +map('n', '[', 'bp') +map('n', ']', 'bn') + +-- Move to the last buffer (CTRL-Tab style) +map('n', "''", 'b#') + +-- Copying the vscode behaviour of making tab splits +map('n', '', 'vsplit') +map('n', '', 'split') + +-- Move line up and down in NORMAL and VISUAL modes +-- Reference: https://vim.fandom.com/wiki/Moving_lines_up_or_down +map('n', '', 'move .+1') +map('n', '', 'move .-2') +map('x', '', ":move '>+1gv=gv") +map('x', '', ":move '<-2gv=gv") + +-- Use operator pending mode to visually select the whole buffer +-- e.g. dA = delete buffer ALL, yA = copy whole buffer ALL +map('o', 'A', ':normal! mzggVG`z') +map('x', 'A', ':normal! ggVG') diff --git a/lua/macbook/settings.lua b/lua/macbook/settings.lua index 710eb0e..ceea65f 100644 --- a/lua/macbook/settings.lua +++ b/lua/macbook/settings.lua @@ -12,9 +12,9 @@ o.termguicolors = true o.scrolloff = 8 -- Better editor UI -o.number = false -- show line number +o.number = true -- show line number o.numberwidth = 2 -o.relativenumber = false +o.relativenumber = true o.signcolumn = 'auto' o.cursorline = true -- highlight entire cursor line, increases readability @@ -33,3 +33,27 @@ o.listchars = 'trail:·,nbsp:◇,tab:→ ,extends:▸,precedes:◂' -- list of c -- Makes neovim and host OS clipboard play nicely with each other o.clipboard = 'unnamedplus' + +-- Case insensitive searching unless /C or capital in search +o.ignorecase = true +o.smartcase = true + +-- Undo and backup options +o.backup = false +o.writebackup = false +o.undofile = true +o.swapfile = false + +-- Remember 50 items in commandline history +o.history = 50 + +-- Better buffer splitting +o.splitright = true +o.splitbelow = true + +-- Preserve view while jumpting [TODO] Figure out what these jumpoptions mean +o.jumpoptions = 'view' + +-- Map to space +g.mapleader = ' ' +g.maplocalleader = ' '