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

Mon, 14 Aug 2023 22:04:03 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 14 Aug 2023 22:04:03 -0400
changeset 1127
a120f1d3d932
parent 1101
40419d8e3cbb
permissions
-rw-r--r--

tmux: update DBUS_SESSION_BUS_ADDRESS to fix gpg pinentry

1085
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 local util = require("config.util")
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 local safe_filter_file = util.safe_filter_file
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 local g = vim.api.nvim_create_augroup("encrypted", { clear = true })
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 local filepattern = { "*.gpg", "*.gpg.*" }
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 local function autocmd(event, opts)
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 util.autocmd(g, event, filepattern, opts)
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 end
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 autocmd({ "BufReadPre", "FileReadPre" }, {
1101
40419d8e3cbb cleanup
Meredith Howard <mhoward@roomag.org>
parents: 1085
diff changeset
13 command = [[ setl noswapfile noundofile nobackup viminfo= ]],
1085
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14 })
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 autocmd("BufReadPost", function(_)
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 safe_filter_file("gpg -d")
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 end)
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 autocmd("BufWritePre", function(_)
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 safe_filter_file("gpg -se -a --default-recipient-self")
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 end)
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23
c2d11f022cf0 Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 autocmd("BufWritePost", { command = [[ silent undo ]] })

mercurial