vim.g.mapleader = " " local o = vim.o o.number = true o.relativenumber = true o.tabstop = 4 o.shiftwidth = 4 o.expandtab = true o.signcolumn = "yes" o.swapfile = false o.winborder = "single" o.termguicolors = true o.autoread = true -- Folding: native treesitter folds (function/class/block-aware), no plugin needed. -- `foldmethod=diff` (used automatically in :diffthis / fugitive / diffview windows) -- takes over on its own and isn't affected by this. o.foldmethod = "expr" o.foldexpr = "v:lua.vim.treesitter.foldexpr()" o.foldlevel = 99 -- start with everything open o.foldlevelstart = 99 vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, { command = "if mode() != 'c' | checktime | endif", }) -- `git show`/`git diff`/`git log -p` piped into nvim (e.g. `git show | nvim -`) -- arrive as stdin with no filename, so normal filetype detection never fires -- and folding/highlighting silently stay off. Sniff the content instead. vim.api.nvim_create_autocmd("StdinReadPost", { callback = function() local first = vim.fn.getline(1) if first:match("^commit %x+") or first:match("^diff %-%-git ") or first:match("^From %x+") then vim.bo.filetype = "diff" end end, }) vim.filetype.add({ extension = { asm = "asm", s = "asm", S = "asm" } }) vim.api.nvim_create_autocmd("FileType", { pattern = "asm", callback = function() vim.bo.tabstop = 8 vim.bo.shiftwidth = 8 vim.bo.softtabstop = 8 vim.bo.expandtab = false end, }) vim.diagnostic.config({ virtual_text = false, virtual_lines = { current_line = true }, severity_sort = true, })