--[[ BASIC-SETTINGS.LUA This file contains fundamental Neovim settings that don't require plugins. These are applied to Neovim globally and affect the core editing experience. In Lua (this file), we use: - vim.opt.* for options that take values - vim.g.* for global variables - vim.go.* for global option shorthand ]] -- ============================================================================ -- TREESITTER (Built-in Neovim 0.10+ features) -- ============================================================================ -- Enable Treesitter syntax highlighting (native in Neovim 0.10+) -- This replaces the old nvim-treesitter highlight module vim.api.nvim_create_autocmd("FileType", { pattern = "*", callback = function() if vim.bo.buftype == "" and vim.bo.filetype ~= "" then pcall(vim.treesitter.start) end end, desc = "Enable Treesitter highlighting", }) -- ============================================================================ -- FOLDING SETTINGS (Code folding) -- ============================================================================ -- NOTE: In Neovim 0.10+, Treesitter folding must be set per-buffer via FileType autocmd -- Setting it globally causes the foldexpr to evaluate before Treesitter attaches -- Foldlevel: Higher number = more folds are open by default -- 1-2 means you'll see folds by default; 99 means all folds are open vim.opt.foldlevel = 99 vim.opt.foldlevelstart = 99 -- Setup Treesitter folding for each buffer after filetype is detected -- This ensures the parser is loaded before foldexpr evaluates vim.api.nvim_create_autocmd("FileType", { pattern = "*", callback = function() -- Only set folding for file buffers with Treesitter support if vim.bo.buftype == "" then vim.wo.foldmethod = "expr" vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" end end, desc = "Setup Treesitter folding per filetype", }) -- ============================================================================ -- LINE NUMBERS -- ============================================================================ -- Show line numbers (absolute numbering) vim.opt.number = true -- Show relative line numbers (helps with motions like 5j, 3k, etc.) -- When combined with 'number', the current line shows absolute number -- vim.opt.relativenumber = true -- ============================================================================ -- INDENTATION SETTINGS -- ============================================================================ -- Tabstop: How many spaces a TAB character counts for -- When viewing a file, TABs appear as this many spaces vim.opt.tabstop = 4 -- Shiftwidth: How many spaces to use for auto-indentation and >> << commands vim.opt.shiftwidth = 4 -- Expandtab: Convert TABs to spaces when typing -- true = pressing TAB inserts spaces; false = inserts actual TAB characters -- Recommendation: Use true (spaces) for better portability across systems vim.opt.expandtab = true -- Smartindent: Auto-indent based on file type and syntax -- Automatically adds indent after lines ending with specific characters vim.opt.smartindent = true -- ============================================================================ -- UI/UX SETTINGS -- ============================================================================ -- Show line length marker (optional, helps keep lines under 80/120 chars) -- Uncomment if you want: vim.opt.colorcolumn = "80" -- Enable cursor line highlighting (subtle background on current line) vim.opt.cursorline = true -- Enable cursor column highlighting (column where cursor is) vim.opt.cursorcolumn = true -- Better command-line completion (popup menu for completions) vim.opt.wildmenu = true -- Ignore case when searching UNLESS you include an uppercase letter vim.opt.ignorecase = true vim.opt.smartcase = true -- Highlight search matches as you type vim.opt.incsearch = true -- When search reaches end, wrap back to beginning vim.opt.wrapscan = true -- Show matching brackets/parentheses vim.opt.showmatch = true -- How long (ms) to show matching bracket vim.opt.matchtime = 2 -- Show current mode in last line (like -- INSERT --) vim.opt.showmode = true -- Show incomplete commands at bottom vim.opt.showcmd = true -- Command line height (number of lines for command area) vim.opt.cmdheight = 1 -- Always show status line (even in single window) vim.opt.laststatus = 3 -- Don't redraw while executing macros (faster) vim.opt.lazyredraw = false -- Don't show mode in the window title (cleaner) vim.opt.title = false -- ============================================================================ -- EDITING BEHAVIOR -- ============================================================================ -- Enable mouse support (click to move cursor, resize splits) vim.opt.mouse = "a" -- Allow backspace to delete indent, eol, and start of line vim.opt.backspace = "indent,eol,start" -- Auto-read file when changed externally (e.g., by another program) vim.opt.autoread = true -- Auto-write when switching buffers or leaving -- 'a' = auto-write for all buffers; uncomment if you want: -- vim.opt.autowrite = true -- Remember moreundo for longer undo history vim.opt.undofile = true -- ============================================================================ -- SPLIT AND TAB SETTINGS -- ============================================================================ -- Split below (instead of above) when creating horizontal splits vim.opt.splitbelow = true -- Split right (instead of left) when creating vertical splits vim.opt.splitright = true -- ============================================================================ -- PERFORMANCE SETTINGS -- ============================================================================ -- Faster terminal response vim.opt.timeout = true vim.opt.timeoutlen = 300 -- Time in ms to wait for a mapped sequence -- Async handling for some operations vim.opt.ttimeoutlen = 10 -- ============================================================================ -- LEADER KEY -- ============================================================================ -- The key is used as a prefix for custom keybindings -- By convention, space is commonly used as the leader key vim.g.mapleader = " " -- ============================================================================ -- TERMINAL SETTINGS -- ============================================================================ -- Exit terminal mode with Escape vim.keymap.set("t", "", [[]], { desc = "Exit terminal mode" }) -- Alternative: Exit with Alt key combinations as well vim.keymap.set("t", "", [[]], { desc = "Exit terminal mode with Alt" }) -- ============================================================================ -- CLIPBOARD (System clipboard integration) -- ============================================================================ -- Use system clipboard for yank/paste -- Requires +clipboard feature (check with: :echo has('clipboard')) if vim.fn.has("clipboard") == 1 then -- Use system clipboard for all yank/delete/paste operations vim.opt.clipboard = "unnamedplus" end