net config

This commit is contained in:
Harivansh Rathi 2026-02-04 15:18:34 -05:00
parent 93b7b93d64
commit dd59a54b92
36 changed files with 960 additions and 631 deletions

36
plugin/autocmds.lua Normal file
View file

@ -0,0 +1,36 @@
-- Autocommands
local api = vim.api
local augroup = api.nvim_create_augroup("UserAutocmds", { clear = true })
-- Highlight on yank
api.nvim_create_autocmd("TextYankPost", {
group = augroup,
callback = function()
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
end,
desc = "Highlight text on yank",
})
-- Restore cursor position on file open
api.nvim_create_autocmd("BufReadPost", {
group = augroup,
callback = function()
local mark = api.nvim_buf_get_mark(0, '"')
local line_count = api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= line_count then
pcall(api.nvim_win_set_cursor, 0, mark)
end
end,
desc = "Restore cursor position",
})
-- Auto-resize splits on VimResized
api.nvim_create_autocmd("VimResized", {
group = augroup,
callback = function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
vim.cmd("tabnext " .. current_tab)
end,
desc = "Auto-resize splits",
})

26
plugin/keymaps.lua Normal file
View file

@ -0,0 +1,26 @@
-- Keymaps using global map() helper
-- File operations
map("n", "<leader>w", "<cmd>w<cr>", { desc = "Save file" })
map("n", "<leader>q", "<cmd>q<cr>", { desc = "Quit" })
-- Buffer navigation
map("n", "<Tab>", "<cmd>bnext<cr>", { desc = "Next buffer" })
map("n", "<S-Tab>", "<cmd>bprev<cr>", { desc = "Previous buffer" })
map("n", "<leader>x", "<cmd>bdelete<cr>", { desc = "Close buffer" })
map("n", "<leader>b", "<cmd>enew<cr>", { desc = "New buffer" })
-- Window navigation
map("n", "<C-h>", "<C-w>h", { desc = "Move to left window" })
map("n", "<C-j>", "<C-w>j", { desc = "Move to lower window" })
map("n", "<C-k>", "<C-w>k", { desc = "Move to upper window" })
map("n", "<C-l>", "<C-w>l", { desc = "Move to right window" })
-- Better defaults
map("n", "J", "mzJ`z", { desc = "Join lines keeping cursor position" })
map("x", "x", '"_x', { desc = "Delete char without yanking" })
map("x", "p", '"_dP', { desc = "Paste without yanking replaced text" })
map("n", "<Esc>", "<cmd>nohlsearch<cr>", { desc = "Clear search highlight" })
-- Terminal
map("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })

47
plugin/options.lua Normal file
View file

@ -0,0 +1,47 @@
-- Vim options
local o, opt = vim.o, vim.opt
-- Line numbers
o.number = true
o.relativenumber = true
-- Indentation
o.tabstop = 2
o.shiftwidth = 2
o.expandtab = true
o.smartindent = true
o.breakindent = true
-- Search
o.ignorecase = true
o.smartcase = true
o.hlsearch = false
o.incsearch = true
-- UI
o.termguicolors = true
o.cursorline = true
o.scrolloff = 8
o.signcolumn = "yes"
o.wrap = false
o.showmode = false
o.laststatus = 3
o.cmdheight = 0
opt.fillchars = { vert = "", fold = "", foldsep = "", diff = "" }
opt.shortmess:append("S")
-- Splits
o.splitbelow = true
o.splitright = true
-- Files
o.swapfile = false
o.backup = false
o.undofile = true
o.undodir = vim.fn.stdpath("data") .. "/undo"
-- Misc
o.updatetime = 250
o.mouse = "a"
o.clipboard = "unnamedplus"