Skip to content

Instantly share code, notes, and snippets.

@noisesfromspace
Created March 24, 2026 12:16
Show Gist options
  • Select an option

  • Save noisesfromspace/e8012ba0b4f6b38e0d81296acc3931cc to your computer and use it in GitHub Desktop.

Select an option

Save noisesfromspace/e8012ba0b4f6b38e0d81296acc3931cc to your computer and use it in GitHub Desktop.
minimal vim config
-- ==============================================================================
-- ~/.config/nvim/init.lua
--
-- 1. LEADER KEY
-- ==============================================================================
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- ==============================================================================
-- 2. OPTIONS
-- ==============================================================================
local opt = vim.opt
-- Indentation & Tabs
opt.expandtab = true -- Use spaces instead of tabs
opt.shiftwidth = 2 -- Size of an indent
opt.tabstop = 2 -- Number of spaces tabs count for
opt.softtabstop = 2
-- UI & Display
opt.number = true -- Show absolute line number on cursor line
opt.relativenumber = true -- Show relative line numbers elsewhere
opt.cmdheight = 0 -- Hide command line unless typing
opt.smoothscroll = true
-- Search
opt.ignorecase = true -- Ignore case in search patterns
opt.smartcase = true -- Override ignorecase if search contains capitals
-- Backup & Undo
opt.swapfile = false -- Don't create cluttering .swp files
opt.undofile = true -- Save undo history between sessions
-- Completion (Wildmenu)
opt.wildoptions = "pum"
opt.wildmode = "longest:full,full"
opt.completeopt = "menu,menuone,noinsert"
opt.complete = "."
opt.infercase = true
opt.pumheight = 15
opt.pumwidth = 30
-- Indent-based folding works everywhere instantly.
opt.foldenable = true
opt.foldlevel = 20
opt.foldmethod = "indent" -- Fold based on how many spaces/tabs prefix the line
-- Sessions
opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,globals"
-- ==============================================================================
-- 3. KEYMAPS (Native only, no plugins required)
-- ==============================================================================
local map = vim.keymap.set
-- Terminal mode escape (`tnoremap`)
map('t', '<Esc>', [[<C-\><C-n>]], { silent = true, desc = 'Exit terminal mode' })
-- System Clipboard Integration
map('v', '<Leader>y', '"+y', { desc = 'Add selection to system clipboard' })
map('n', '<Leader>y', ':%y+<CR>', { desc = 'Add whole file to system clipboard' })
-- Git Hunk Manipulation (Using native visual piping!)
map('n', '-', function()
if vim.fn.winnr("$") == 1 then return end -- Don't resize if only one window
if vim.api.nvim_win_get_width(0) >= vim.o.columns - 2 then
vim.cmd("resize -3")
else
vim.cmd("vertical resize -3")
end
end, { desc = "Decrease window size" })
map('n', '+', function()
if vim.fn.winnr("$") == 1 then return end
if vim.api.nvim_win_get_width(0) >= vim.o.columns - 2 then
vim.cmd("resize +3")
else
vim.cmd("vertical resize +3")
end
end, { desc = "Increase window size" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment