local O=(require("\099\104\097\105\046\111\112\116\105\111\110\115")).makeopt return{setup=function()vim.api.nvim_create_autocmd("\086\105\109\082\101\115\105\122\101\100",{pattern="\042",command="\119\105\110\099\109\100 \061",desc="\065\117\116\111\109\097\116\105\099\097\108\108\121 \114\101\115\105\122\101 \119\105\110\100\111\119\115 \119\104\101\110 \116\104\101 \104\111\115\116 \119\105\110\100\111\119 \115\105\122\101 \099\104\097\110\103\101\115\046"})vim.api.nvim_create_autocmd("\084\101\120\116\089\097\110\107\080\111\115\116",{pattern="\042",callback=function()vim.highlight.on_yank({higroup="\073\110\099\083\101\097\114\099\104";timeout=200})end;desc="\072\105\103\104\108\105\103\104\116 \121\097\110\107\101\100 \116\101\120\116"})vim.api.nvim_create_autocmd({"\082\101\099\111\114\100\105\110\103\069\110\116\101\114","\082\101\099\111\114\100\105\110\103\076\101\097\118\101"},{callback=function(O)local V=O.event=="\082\101\099\111\114\100\105\110\103\069\110\116\101\114"and"\082\101\099\111\114\100\105\110\103 \109\097\099\114\111\046\046\046"or"\077\097\099\114\111 \114\101\099\111\114\100\101\100"vim.notify(V,vim.log.levels.INFO,{title="\077\097\099\114\111"})end;desc="\078\111\116\105\102\121 \119\104\101\110 \114\101\099\111\114\100\105\110\103 \109\097\099\114\111"})vim.api.nvim_create_autocmd("\087\105\110\069\110\116\101\114",{pattern="\116\101\114\109\058\047\047\042",callback=function(O)if vim.bo[O.buf].buftype~="\116\101\114\109\105\110\097\108"then return end vim.cmd("\115\116\097\114\116\105\110\115\101\114\116")end})vim.api.nvim_create_autocmd("\084\101\114\109\079\112\101\110",{pattern="\116\101\114\109\058\047\047\042";callback=function()vim.cmd("\115\116\097\114\116\105\110\115\101\114\116")end,desc="\115\116\097\114\116 \105\110\115\101\114\116 \109\111\100\101 \111\110 \084\101\114\109\079\112\101\110"})vim.api.nvim_create_autocmd("\084\101\114\109\079\112\101\110",{pattern="\116\101\114\109\058\047\047\042";callback=function()vim.opt_local.number=false end;desc="\114\101\109\111\118\101 \108\105\110\101 \110\117\109\098\101\114\115"})vim.api.nvim_create_autocmd("\066\117\102\087\114\105\116\101\080\114\101",{desc="\099\114\101\097\116\101 \112\097\116\104 \116\111 \102\105\108\101",callback=function()local O=vim.fn.expand("\060\097\102\105\108\101\062\058\112\058\104")if O:find("\037\108\043\058\047\047")==1 then return end if vim.fn.isdirectory(O)==0 then vim.fn.mkdir(O,"\112")end end})end}
local makeopt = require("chai.options").makeopt

return {
  setup = function()
    vim.api.nvim_create_autocmd("VimResized", {
      pattern = "*",
      command = "wincmd =",
      desc = "Automatically resize windows when the host window size changes.",
    })

    vim.api.nvim_create_autocmd("TextYankPost", {
      pattern = "*",
      callback = function()
        vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
      end,
      desc = "Highlight yanked text",
    })

    vim.api.nvim_create_autocmd({ "RecordingEnter", "RecordingLeave" }, {
      callback = function(data)
        local msg = data.event == "RecordingEnter" and "Recording macro..." or "Macro recorded"
        vim.notify(msg, vim.log.levels.INFO, { title = "Macro" })
      end,
      desc = "Notify when recording macro",
    })

    vim.api.nvim_create_autocmd("WinEnter", {
      pattern = "term://*",
      callback = function(ev)
        if vim.bo[ev.buf].buftype ~= "terminal" then
          return
        end
        vim.cmd("startinsert")
      end,
    })

    vim.api.nvim_create_autocmd("TermOpen", {
      pattern = "term://*",
      callback = function()
        vim.cmd("startinsert")
      end,
      desc = "start insert mode on TermOpen",
    })

    vim.api.nvim_create_autocmd("TermOpen", {
      pattern = "term://*",
      callback = function()
        vim.opt_local.number = false
      end,
      desc = "remove line numbers",
    })

    vim.api.nvim_create_autocmd("BufWritePre", {
      desc = "create path to file",
      callback = function()
        local dir = vim.fn.expand("<afile>:p:h")

        if dir:find("%l+://") == 1 then
          return
        end

        if vim.fn.isdirectory(dir) == 0 then
          vim.fn.mkdir(dir, "p")
        end
      end,
    })
  end,
}
