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 ]] }) |
|