local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
  vim
    .system({
      "git",
      "clone",
      "--filter=blob:none",
      "https://github.com/folke/lazy.nvim.git",
      "--branch=stable", -- latest stable release
      lazypath,
    })
    :wait()
end

vim.opt.rtp:prepend(lazypath)

vim.g.maplocalleader = ","

if vim.fn.has("mac") and vim.env.TMUX ~= "" and vim.fn.executable("tmux") and vim.env.SSH_TTY ~= "" then
  local copy = { "tmux", "load-buffer", "-w", "-" }
  local paste = { "tmux", "save-buffer", "-" }
  vim.g.clipboard = {
    name = "tmux",
    copy = {
      ["+"] = copy,
      ["*"] = copy,
    },
    paste = {
      ["+"] = paste,
      ["*"] = paste,
    },
    cache_enabled = 1,
  }
end

local motchvim_exists = vim.fn.isdirectory(vim.fn.expand("~/src/motchvim/")) == 1

require("lazy").setup {
  spec = {
    { dev = motchvim_exists, "mhanberg/motchvim", import = "motchvim.plugins" },
  },
  concurrency = 30,
  dev = { path = "~/src" },
  install = {
    missing = true,
  },
  performance = {
    rtp = {
      -- disable some rtp plugins
      disabled_plugins = {
        "gzip",
        -- "matchit",
        -- "matchparen",
        "netrwPlugin",
        "tarPlugin",
        "tohtml",
        "tutor",
        "zipPlugin",
      },
    },
  },
}
