From 2f34bfac9fb49c7bbd08070587f31ea28da24d34 Mon Sep 17 00:00:00 2001 From: Erik Westrup Date: Sat, 11 Mar 2023 19:15:49 +0100 Subject: [PATCH] README: add Lua example code for auto-running PackerCompile Many users come to Packer because they can migrate to a complete Lua-based config for NeoVim. Thus it makes sense to have a code example not only in Vimscript for auto-running PackerCompile on changes to `plugins.lua` but also an example in Lua. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e1a3c412f..48acbd1e2 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,16 @@ vim.cmd([[ ]]) ``` +or using the equivalent Lua code: +```lua +local augroup_packer = vim.api.nvim_create_augroup("packer_user_config", { clear = true }) +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = "plugins.lua", + group = augroup_packer, + command = "source | PackerCompile", +}) +``` + ## Bootstrapping If you want to automatically install and set up `packer.nvim` on any machine you clone your configuration to,