require("tsousa.set")
require("tsousa.remap")
require("tsousa.lazy")

local augroup = vim.api.nvim_create_augroup
local TsousaGroup = augroup('TsousaGroup', {})

local autocmd = vim.api.nvim_create_autocmd
local yank_group = augroup('HighlightYank', {})

autocmd('BufWinEnter',{
    group= TsousaGroup,
    pattern = '*',
    callback = function()
        vim.opt.formatoptions:remove('o')
    end
})

autocmd('TextYankPost', {
    group = yank_group,
    pattern = '*',
    callback = function()
        vim.highlight.on_yank({
            higroup = 'IncSearch',
            timeout = 40,
        })
    end,
})

autocmd({ "BufWritePre" }, {
    group = TsousaGroup,
    pattern = "*",
    callback = function ()
        local cursor_pos = vim.fn.getpos('.')
        vim.cmd([[%s/\s\+$//e]])
        vim.fn.setpos('.', cursor_pos)
    end
})

vim.g.netrw_browse_split = 0
vim.g.netrw_banner = 0
vim.g.netrw_winsize = 25
