.config/nvim/plugin/gpg-encrypted.lua

Mon, 20 Jan 2025 01:01:48 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 20 Jan 2025 01:01:48 -0600
changeset 1180
308dce5084af
parent 1166
34bf03fa07e4
permissions
-rw-r--r--

start switching to mise-en-place

local util = require("config.util")

local safe_filter_file = util.safe_filter_file

local g = vim.api.nvim_create_augroup("encrypted", { clear = true })
local filepattern = { "*.gpg", "*.gpg.*" }

local function autocmd(event, opts)
  util.autocmd(g, event, filepattern, opts)
end

autocmd({ "BufReadPre", "FileReadPre" }, [[ setl noswapfile noundofile nobackup shada= ]])

autocmd("BufReadPost", function(_)
  safe_filter_file("gpg -d")
end)

autocmd("BufWritePre", function(_)
  safe_filter_file("gpg -se -a --default-recipient-self")
end)

autocmd("BufWritePost", [[ silent undo ]])

mercurial