chezmoi.lua 1.2 KB

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