-- Plugin definitions and loading
local cmd = vim.cmd

-- Rerun packer install when this file changes
cmd([[
  augroup packer_user_config
    autocmd!
    autocmd BufWritePost plugins.lua source <afile> | PackerCompile
  augroup end
]])

-- Load packer
cmd([[packadd packer.nvim]])

-- Get plugins
return require("packer").startup(function(use)
  -- Dogfood packer
  use({"wbthomason/packer.nvim", opt = true})

  -- Dependencies
  use "nvim-lua/plenary.nvim"

  -- LSP stuff
  use({"neovim/nvim-lspconfig", config = function() require("plugins.lsp") end})
  use({"simrat39/rust-tools.nvim", config = function()
    require("rust-tools").setup({})
  end})
  use({"j-hui/fidget.nvim", config = function()
    require("fidget").setup({})
  end})

  -- Completion
  use "hrsh7th/cmp-nvim-lsp"
  use "hrsh7th/cmp-buffer"
  use "hrsh7th/cmp-path"
  use "hrsh7th/cmp-cmdline"
  use({"hrsh7th/nvim-cmp", config = function() require("plugins.completion") end})

  -- Text editing
  use "tpope/vim-surround"
  use "Raimondi/delimitMate"
  use "rlane/pounce.nvim"

  -- Fancy UI stuff
  use "RRethy/nvim-base16"
  use "stevearc/dressing.nvim"
  use({"lewis6991/gitsigns.nvim", config = function() require("gitsigns").setup() end})
  use({"nvim-lualine/lualine.nvim", config = function()
    require("lualine").setup({
      options = {
        icons_enabled = false,
      },
      sections = {
        lualine_x = {"filetype"},
      },
    })
  end})
  use({"kdheepak/tabline.nvim", config = function()
    require("tabline").setup({
      options = {
        show_devicons = false,
        modified_icon = "#",
      },
    })
  end})

  -- Keybinds
  use({
    "AckslD/nvim-whichkey-setup.lua",
    requires = {"liuchengxu/vim-which-key"}
  })

  -- File interaction
  use({"nvim-telescope/telescope.nvim", config = function () end})
  use({"TimUntersberger/neogit", config = function () require("neogit").setup({}) end})

  -- Lang support
  use({"khaveesh/vim-fish-syntax"})
end)

