changeset 688:6e98364a5a28

chore: convert chezmoi autocmds to lua
author zegervdv <zegervdv@me.com>
date Wed, 05 Oct 2022 08:56:58 +0200
parents 6aabd0b8d766
children cefa2c4077ed
files .chezmoitemplates/config.vim .chezmoitemplates/init.lua
diffstat 2 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/.chezmoitemplates/config.vim	Sun Oct 02 18:43:18 2022 +0200
+++ b/.chezmoitemplates/config.vim	Wed Oct 05 08:56:58 2022 +0200
@@ -127,11 +127,3 @@
 "
 " Vinegar/NetRW
 autocmd FileType netrw setl bufhidden=delete
-"
-augroup Chezmoi
-  autocmd!
-  autocmd BufWritePost ~/.local/share/chezmoi/* silent !chezmoi apply --source-path %
-  autocmd BufWritePost ~/.local/share/chezmoi/.chezmoitemplates/init.lua silent !chezmoi apply --source-path ~/.local/share/chezmoi/dot_config/nvim/init.lua.tmpl
-  autocmd BufWritePost ~/.local/share/chezmoi/.chezmoitemplates/config.vim silent !chezmoi apply --source-path ~/.local/share/chezmoi/dot_config/nvim/plugin/config.vim.tmpl
-  autocmd BufWritePost ~/.local/share/chezmoi/dot_config/nvim/init.lua source <afile> | PackerCompile
-augroup END
--- a/.chezmoitemplates/init.lua	Sun Oct 02 18:43:18 2022 +0200
+++ b/.chezmoitemplates/init.lua	Wed Oct 05 08:56:58 2022 +0200
@@ -1007,6 +1007,16 @@
   },
 })
 
+-- Apply changes in chezmoi managed files
+au.group('chezmoi', {
+  { 'BufWritePost', os.getenv 'HOME' .. '/.local/share/chezmoi/*', 'silent !chezmoi apply --source-path %' },
+  {
+    'BufWritePost',
+    os.getenv 'HOME' .. '/.local/share/chezmoi/.chezmoitemplates/init.lua',
+    'silent !chezmoi apply --source-path $HOME/.local/share/chezmoi/dot_config/nvim/init.lua.tmpl',
+  },
+})
+
 -- Snippets
 local ls = require 'luasnip'
 -- Expand snippet or jump to next placeholder