vim.o.expandtab = true
-- local guifont = { "Iosevka Custom" }
-- if vim.loop.os_uname().sysname == "Darwin" then
-- 	table.insert(guifont, "Apple Color Emoji")
-- else
-- 	table.insert(guifont, "Noto Color Emoji")
-- end
-- vim.o.guifont = table.concat(guifont, ",") .. ":14"
vim.o.hidden = true
vim.o.ignorecase = true
vim.o.inccommand = "split"
vim.o.list = true
vim.o.listchars = "tab:→ ,eol:¬,trail:•,extends:❯,precedes:❮,space:‣"
vim.o.mouse = "a"
vim.o.number = true
vim.o.relativenumber = true
vim.o.sessionoptions = "blank,curdir,folds,help,tabpages,winsize"
vim.o.shiftwidth = 4
vim.o.showbreak = "↪"
vim.o.showtabline = 1
vim.o.signcolumn = "yes"
vim.o.smartcase = true
vim.o.smarttab = true
vim.o.splitbelow = true
vim.o.splitright = true
vim.o.tabstop = 4
vim.o.termguicolors = true
vim.o.timeoutlen = 500
vim.o.title = true
vim.o.updatetime = 500
vim.o.wildmenu = true
vim.o.wildmode = "list:longest,full"
vim.g.skip_ts_context_commentstring_module = true

-- `page` config
vim.g.page_icon_pipe = "|"
vim.g.page_icon_redirect = ">"
vim.g.page_icon_instance = "$"

vim.api.nvim_create_autocmd("TextYankPost", {
	callback = function()
		vim.highlight.on_yank()
	end,
})

require("gitlinker").setup()
require("nvim-biscuits").setup()
require("overseer").setup()
require("officer").setup({ create_mappings = true })

local cmp = require("cmp")

cmp.setup({
	snippet = {
		expand = function(args)
			vim.snippet.expand(args.body)
		end,
	},
	cmdline,
})

cmp.setup.cmdline(":", {
	mapping = cmp.mapping.preset.cmdline(),
	sources = cmp.config.sources({
		{ name = "path" },
	}, {
		{ name = "cmdline" },
	}),
	matching = { disallow_symbol_nonprefix_matching = false },
})

do
	function setup()
		require("ufo").setup({
			provider_selector = function(bufnr, filetype, buftype)
				return { "treesitter", "indent" }
			end,
		})

		require("ufo").setup({})
		vim.o.foldcolumn = "1" -- '0' is not bad
		vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
		vim.o.foldlevelstart = 99
		vim.o.foldenable = true
	end

	success, output = pcall(setup) -- execute 'setup()' and catch any errors
	if not success then
		print("Error on setup for plugin: ufo")
		print(output)
	end
end