blob: a09cdfb0caf7613fa16f24366f97ad8df3cfb6e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
local encrypt = require("encrypt.encrypt")
local function createWriteAutoCmd()
if vim.b["encryptionAutoCmd"] ~= nil then
return
end
vim.b["encryptionAutoCmd"] = vim.api.nvim_create_autocmd({ "BufWriteCmd" }, {
callback = function()
if vim.b["encrypted"] ~= true then
return
end
encrypt()
end,
})
end
local function setupBuffer()
-- buftype="acwrite" means save using the BufWriteCmd command
vim.bo.buftype = "acwrite"
vim.bo.swapfile = false
vim.bo.undofile = false
vim.b["encrypted"] = true
createWriteAutoCmd()
end
return setupBuffer
|