------------------------- -------- 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", "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" }, "", "noh", { desc = "Escape and clear hlsearch" }) -- Move lines while in visual mode with J and K map("v", "J", ":m '>+1gv=gv") map("v", "K", ":m '<-2gv=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", "", "zz") map("n", "", "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", "p", '"_dP') map({ "n", "v" }, "d", '"_dP') -- System clipboard map({ "n", "v" }, "cd", '"+d', { desc = "Clipboard delete" }) map({ "n", "v" }, "cp", '"+p', { desc = "Clipboard paste" }) map({ "n", "v" }, "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, })