From 0d50eb723fb14b8e309e28b926b7c3a5b6374c49 Mon Sep 17 00:00:00 2001 From: jdhao Date: Tue, 1 Nov 2022 22:00:30 +0800 Subject: chore: add notification for packer compile Also move the autocmd location. --- lua/plugins.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lua/plugins.lua') diff --git a/lua/plugins.lua b/lua/plugins.lua index f814000..e6722da 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,6 +1,8 @@ -local utils = require("utils") +local api = vim.api local fn = vim.fn +local utils = require("utils") + -- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory. vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer" @@ -389,3 +391,15 @@ else vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" }) end end + +-- Auto-generate packer_compiled.lua file +api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = "*/nvim/lua/plugins.lua", + group = api.nvim_create_augroup("packer_auto_compile", { clear = true }), + callback = function(ctx) + local cmd = "source " .. ctx.file + vim.cmd(cmd) + vim.cmd("PackerCompile") + vim.notify("PackerCompile done!", vim.log.levels.INFO, { title = "Nvim-config" }) + end, +}) -- cgit v1.2.3