.config/nvim/lua/local/encrypted.lua

changeset 1160
28e64ed03c25
parent 1159
9a19621f294c
child 1161
2543467f42da
equal deleted inserted replaced
1159:9a19621f294c 1160:28e64ed03c25
1 local util = require("config.util")
2
3 local safe_filter_file = util.safe_filter_file
4
5 local g = vim.api.nvim_create_augroup("encrypted", { clear = true })
6 local filepattern = { "*.gpg", "*.gpg.*" }
7
8 local function autocmd(event, opts)
9 util.autocmd(g, event, filepattern, opts)
10 end
11
12 autocmd({ "BufReadPre", "FileReadPre" }, {
13 command = [[ setl noswapfile noundofile nobackup viminfo= ]],
14 })
15
16 autocmd("BufReadPost", function(_)
17 safe_filter_file("gpg -d")
18 end)
19
20 autocmd("BufWritePre", function(_)
21 safe_filter_file("gpg -se -a --default-recipient-self")
22 end)
23
24 autocmd("BufWritePost", { command = [[ silent undo ]] })

mercurial