nVim/lua/core/autocommands.lua
Robert Morrison 736ff3bef4 feat: initial NEAR functional commit
This commit is enough to make nvim start and bootstrap lazy
to actually use this commit as a base for your own config
- Add the directory 'lua/plugins/spec'
- Place plugin specs there
- Edit configuration as needed
2025-09-14 02:33:21 +01:00

31 lines
1.0 KiB
Lua

-- 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,
})