From 38079d3307a1784be06e941a08d6f0e77fa1d3ba Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Mon, 8 May 2023 16:33:30 +0200 Subject: [PATCH] Add packer installer and config auto-reloading --- lua/valeth/packer.lua | 69 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/lua/valeth/packer.lua b/lua/valeth/packer.lua index a097947..9c2b279 100644 --- a/lua/valeth/packer.lua +++ b/lua/valeth/packer.lua @@ -1,6 +1,36 @@ -return require("packer").startup(function(use) +local function install_packer(path) + vim.fn.system({ + "git", "clone", "--depth", "1", + "https://github.com/wbthomason/packer.nvim", + path + }) + + vim.cmd [[packadd packer.nvim]] +end + +local function ensure_packer() + local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" + + if not vim.fn.isdirectory(install_path) then + install_packer(install_path) + return true + end + + return false +end + +local packer_bootstrap = ensure_packer() + + +-- Plugins + +local spec = function(use) use "wbthomason/packer.nvim" + if packer_bootstrap then + require("packer").sync() + end + use { "nvim-treesitter/nvim-treesitter", run = function() @@ -12,6 +42,19 @@ return require("packer").startup(function(use) use "wakatime/vim-wakatime" + -- Currently doesn't seem to have an option to make it off by default easily + use { + "andweeb/presence.nvim", + disable = true, + config = function() + local presence = require("presence") + + presence.setup({ + show_time = false, + }) + end + } + ---- LSP Stuff @@ -39,6 +82,7 @@ return require("packer").startup(function(use) use { "CantoroMC/ayu-nvim", config = function() + vim.g.ayu_mirage = true vim.cmd.colorscheme("ayu") end } @@ -108,4 +152,25 @@ return require("packer").startup(function(use) require("undotree").setup() end } -end) +end + + +-- Automatically reload packer configuration on write +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost packer.lua source | PackerCompile + augroup end +]]) + + +return require("packer").startup { + spec, + config = { + display = { + open_fn = function() + return require("packer.util").float({ border = "single" }) + end + } + } +}