local q=require("\095\046\117\116\105\108\115")q.set_indent(4,vim.bo)vim.bo.expandtab=true vim.api.nvim_create_autocmd("\066\117\102\087\114\105\116\101\080\114\101",{pattern={"\042\046\103\111"};group=vim.api.nvim_create_augroup("\071\111\108\097\110\103",{}),callback=function()if vim.g._go_auto_organize_imports then vim.lsp.buf.code_action({context={only={"\115\111\117\114\099\101\046\111\114\103\097\110\105\122\101\073\109\112\111\114\116\115"}},apply=true})end if vim.g._go_auto_format then vim.lsp.buf.format()vim.fn.feedkeys("\060\099\114\062")end end})
local utils = require("_.utils")

utils.set_indent(4, vim.bo)
vim.bo.expandtab = true

-- autosave and autoimports
-- vim.g._go_auto_organize_imports = true for automatic imports organize
-- vim.g._go_auto_format = true for automatic formatting
vim.api.nvim_create_autocmd("BufWritePre", {
  pattern = { "*.go" },
  group = vim.api.nvim_create_augroup("Golang", {}),
  callback = function()
    if vim.g._go_auto_organize_imports then
      vim.lsp.buf.code_action({
        context = {
          only = {
            "source.organizeImports",
          },
        },
        apply = true,
      })
    end

    if vim.g._go_auto_format then
      vim.lsp.buf.format()
      -- this is required to avoid a message that formatting is done
      vim.fn.feedkeys("<cr>")
    end
  end,
})
