local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/'

local function bootstrap(repo)
  local url = 'https://github.com/' .. repo
  local name = repo:gsub('.*/', '')
  local path = install_path .. name
  local bootstrapped = false
  if vim.fn.empty(vim.fn.glob(path)) > 0 then
    vim.fn.system({'git', 'clone', '--depth', '1', url, path})
    vim.cmd('packadd ' .. name)
    bootstrapped = true
  end
  return bootstrapped
end

bootstrap('lewis6991/impatient.nvim')
require('impatient')

local tangerine_bootstrapped = bootstrap('udayvir-singh/tangerine.nvim')
bootstrap('udayvir-singh/hibiscus.nvim')

if tangerine_bootstrapped then
  require('tangerine').setup({
    compiler = {
      hooks = {'oninit'}
    }
  })
  require('init')
else
  require('tangerine').setup({})
  local diagnostics = require('tangerine.vim.hooks').run()
  require('init')
  if #diagnostics > 0 then
    require('packer').sync()
  end
end
