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

Wed, 05 Apr 2023 03:44:38 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Wed, 05 Apr 2023 03:44:38 -0400
changeset 1098
8d479a558198
parent 1085
c2d11f022cf0
child 1101
40419d8e3cbb
permissions
-rw-r--r--

Remove long signature previews

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" }, {
  command = [[ setl noswapfile noundofile nobackup viminfo= ]]
})

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

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

autocmd("BufWritePost", { command = [[ silent undo ]] })

mercurial