local indent = 4

vim.opt.shiftwidth  = indent
vim.opt.tabstop     = indent
vim.opt.softtabstop = indent
vim.opt.scrolloff   = indent
vim.opt.wildmode    = 'list:longest,list:full'
vim.opt.expandtab   = true
vim.opt.smartindent = true
vim.opt.hidden      = true
vim.opt.ignorecase  = true
vim.opt.shiftround  = true
vim.opt.smartcase   = true
vim.opt.splitbelow  = true
vim.opt.splitright  = true
vim.opt.number      = true
vim.opt.clipboard = 'unnamed,unnamedplus'

vim.opt.autoindent = false
vim.opt.smartindent = false
vim.opt.errorformat:prepend('%f|%l col %c|%m')
vim.opt.fileformat = 'unix'
vim.opt.undofile = true

vim.opt.background = 'dark'

-- Enable vimrc files per project and disable unsafe commands in project vimrc
vim.opt.exrc = true
vim.opt.secure = true

vim.api.nvim_create_autocmd('InsertEnter', {
  callback = function()
    vim.cmd.hi('clear RedundantSpaces')
  end,
  pattern = '*',
})
vim.api.nvim_create_autocmd({'InsertLeave', 'BufEnter'}, {
  callback = function()
    vim.cmd.hi('RedundantSpaces ctermbg=red guibg=red')
  end,
  pattern = '*',
})

vim.cmd([[
    set title
    set noautoread
    autocmd CursorHold * checktime
    autocmd TextYankPost * lua vim.highlight.on_yank {on_visual = false}
    autocmd BufRead,BufNewFile *.bu,*.yml.example,*.yaml.example set filetype=yaml
    autocmd BufRead,BufNewFile *.ign set filetype=json
    match RedundantSpaces /\s\+$/
]])
