autocmd.lua 513 B

1234567891011121314151617
  1. local myAutoGroup = vim.api.nvim_create_augroup("myAutoGroup", {
  2. clear = true,
  3. })
  4. local autocmd = vim.api.nvim_create_autocmd
  5. -- 修改lua/plugins.lua 自动更新插件
  6. autocmd("BufWritePost", {
  7. group = myAutoGroup,
  8. -- autocmd BufWritePost plugins.lua source <afile> | PackerSync
  9. callback = function()
  10. if vim.fn.expand("<afile>") == "lua/plugins.lua" then
  11. vim.api.nvim_command("source lua/plugins.lua")
  12. vim.api.nvim_command("PackerSync")
  13. end
  14. end,
  15. })