diff options
| author | Ibrahim Muftee <ibrahim@muftee.net> | 2026-08-24 03:42:22 +0000 |
|---|---|---|
| committer | Ibrahim Muftee <ibrahim@muftee.net> | 2026-08-24 03:42:27 +0000 |
| commit | c54c0146db22d0c682cb6df2a0fe6eae9185baac (patch) | |
| tree | c20d1964d64b331ba2661ebd9a2eeed089d34e9f | |
| -rw-r--r-- | init.lua | 98 | ||||
| -rw-r--r-- | nvim-pack-lock.json | 16 |
2 files changed, 114 insertions, 0 deletions
diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..c073de8 --- /dev/null +++ b/init.lua @@ -0,0 +1,98 @@ +------------------------- +-------- Options -------- +------------------------- +vim.opt.autoindent = true +vim.opt.backup = false +vim.opt.breakindent = true +vim.opt.expandtab = true +vim.opt.ignorecase = true +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.scrolloff = 8 +vim.opt.shiftwidth = 0 +vim.opt.smartcase = true +vim.opt.smartindent = true +vim.opt.softtabstop = 4 +vim.opt.swapfile = false +vim.opt.swapfile = false +vim.opt.tabstop = 4 +vim.opt.termguicolors = true +vim.opt.undodir = vim.fn.expand("~/.local/state/nvim/undodir") +vim.opt.undofile = true +vim.cmd("colorscheme retrobox") + +-- Syntax highlighting will be handled by tree-sitter +vim.cmd('syntax off') + +------------------------- +-------- Keymaps -------- +------------------------- +vim.g.mapleader = ' ' + +local function map(mode, left, right, opts) + local default_opts = { + noremap = true, + silent = true, + } + opts = opts or {} + -- "keep" mode preserves the values from the leftmost table, + -- so prioritize any options provided over the defaults + local full_opts = vim.tbl_extend("keep", opts, default_opts) + vim.keymap.set(mode, left, right, full_opts) +end + +-- Toggle background mode (light/dark) +map("n", "<leader>ct", function() + local target = vim.o.bg == "dark" and "light" or "dark" + vim.opt.background = target +end, { desc = "Toggle background mode (light/dark)" }) + +-- Clear any highlighted searches when pressing Esc +-- This lets me leave hlsearch on by default while having an easy way to clear +-- it again. +map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" }) + +-- Move lines while in visual mode with J and K +map("v", "J", ":m '>+1<CR>gv=gv") +map("v", "K", ":m '<-2<CR>gv=gv") + +-- Keep cursor in the same place when using J to join lines +map("n", "J", "mzJ`z") + +-- Center the screen when jumping around with C-d and C-u +map("n", "<C-d>", "<C-d>zz") +map("n", "<C-u>", "<C-u>zz") + +-- Center the screen when jumping to next / previous search terms +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + +-- Quick maps to paste/delete without overwriting the current buffer +map("x", "<leader>p", '"_dP') +map({ "n", "v" }, "<leader>d", '"_dP') + +-- System clipboard +map({ "n", "v" }, "<leader>cd", '"+d', { desc = "Clipboard delete" }) +map({ "n", "v" }, "<leader>cp", '"+p', { desc = "Clipboard paste" }) +map({ "n", "v" }, "<leader>cy", '"+y', { desc = "Clipboard yank" }) + +------------------------- +-------- Plugins -------- +------------------------- +vim.pack.add { + 'https://github.com/stevearc/oil.nvim', + 'https://github.com/nvim-treesitter/nvim-treesitter', +} + +-- Oil +require('oil').setup({ + skip_confirm_for_simple_edits = true, + columns = {"size", "mtime"}, + map("n", "g-", vim.cmd.Oil, { desc = "Open Oil" }), +}) + +-- Tree-sitter +require('nvim-treesitter').setup() +vim.api.nvim_create_autocmd('FileType', { + callback = function() pcall(vim.treesitter.start) end, +}) diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..333e9aa --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,16 @@ +{ + "plugins": { + "neovim": { + "rev": "ff483051a47e27d84bdef47703538df1ed9f4a47", + "src": "https://github.com/rose-pine/neovim" + }, + "nvim-treesitter": { + "rev": "8b98b4470eb326f1c7b50dae79f8c963568e5720", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "oil.nvim": { + "rev": "b73018b75affd13fa38e2fc94ef753b465f770d7", + "src": "https://github.com/stevearc/oil.nvim" + } + } +} |
