-- Control cursorline option -- This function allows the easy creation of autocommands that configure cursorline for one buffer -- either based on events or filetypes local auGroupCursorLine = vim.api.nvim_create_augroup("CursorLine", { clear = true }) local set_cursorline = function(event, value, pattern) vim.api.nvim_create_autocmd(event, { group = auGroupCursorLine, pattern = pattern, callback = function() vim.opt_local.cursorline = value end, }) end set_cursorline("WinLeave", false) set_cursorline("WinEnter", true) set_cursorline("FileType", false, "TelescopePrompt") -- Wrangle formatoptions -- Format options is local to the buffer -- This autocommand fixes formatoptions for all buffers at load local auGroupFormatOptions = vim.api.nvim_create_augroup("FormatOptions", { clear = true }) vim.api.nvim_create_autocmd("FileType", { group = auGroupFormatOptions, pattern = "*", callback = function() vim.opt.formatoptions = vim.opt.formatoptions -- take the default - "r" -- remove auto commenting - "o" -- and for newlines end, })