chezmoi.lua 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. return {
  2. "xvzc/chezmoi.nvim",
  3. dependencies = { "nvim-lua/plenary.nvim" },
  4. config = function()
  5. require("chezmoi").setup({
  6. -- your configurations
  7. edit = {
  8. watch = true, -- Set true to automatically apply on save.
  9. force = true, -- Set true to force apply. Works only when watch = true.
  10. },
  11. notification = {
  12. on_open = true, -- vim.notify when start editing chezmoi-managed file.
  13. on_apply = true, -- vim.notify on apply.
  14. },
  15. })
  16. vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
  17. pattern = { os.getenv("HOME") .. "/.local/share/chezmoi/*" },
  18. callback = function()
  19. -- invoke with vim.schedule() for better startup time
  20. vim.schedule(require("chezmoi.commands.__edit").watch)
  21. end,
  22. })
  23. -- Auto-apply chezmoi changes
  24. vim.api.nvim_create_autocmd("BufWritePost", {
  25. pattern = { os.getenv("HOME") .. "/.local/share/chezmoi/*" },
  26. command = [[silent! !chezmoi apply --source-path "%"]],
  27. })
  28. end,
  29. }