require 'config.autocmds'
require 'config.mappings'
require 'config.options'
require 'config.lazy'

vim.api.nvim_create_autocmd('User', {
	pattern = 'LazyVimStarted',
	callback = function()
		vim.cmd 'colorscheme gruber-darker'
		require 'feline'
		-- require 'dressing'
		require 'NeoSwap'

		local Terminal = require('toggleterm.terminal').Terminal
		local lazygit  = Terminal:new({
			cmd = "lazygit",
			dir = "git_dir",
			direction = "float",
			float_opts = {
				border = "none",
			},
			-- function to run on opening the terminal
			on_open = function(term)
				vim.cmd("startinsert!")
				vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>",
					{ noremap = true, silent = true })
			end,
			-- function to run on closing the terminal
			on_close = function(_)
				vim.cmd("startinsert!")
			end,
		})

		function _lazygit_toggle()
			lazygit:toggle()
		end

		vim.api.nvim_set_keymap("n", "<leader>g", "<cmd>lua _lazygit_toggle()<CR>",
			{ noremap = true, silent = true })
	end,
})
