diff options
| author | David Elentok <3david@gmail.com> | 2025-05-06 22:04:23 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-06 22:04:23 +0300 |
| commit | 363e1d924c6235ae4e9170b1e2ebab50a2e26c07 (patch) | |
| tree | bf21093fa70c8ed8014e70f4841714d622ec651e /lua/encrypt/setup-buffer.lua | |
| parent | 09d7f6ee9ee1d728449131dff4e750e5339f7968 (diff) | |
| parent | a9e7d700eb546800e3d341bc53667964ac821a38 (diff) | |
| download | encrypt.nvim-363e1d924c6235ae4e9170b1e2ebab50a2e26c07.tar.gz | |
Merge pull request #2 from kongjun18/main
Some Improvement
Diffstat (limited to 'lua/encrypt/setup-buffer.lua')
| -rw-r--r-- | lua/encrypt/setup-buffer.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lua/encrypt/setup-buffer.lua b/lua/encrypt/setup-buffer.lua index 8b950ec..e03f71c 100644 --- a/lua/encrypt/setup-buffer.lua +++ b/lua/encrypt/setup-buffer.lua @@ -1,4 +1,5 @@ local encrypt = require("encrypt.encrypt") +local helpers = require("encrypt.helpers") local function createWriteAutoCmd() if vim.b["encryptionAutoCmd"] ~= nil then @@ -18,12 +19,18 @@ local function createWriteAutoCmd() }) end -local function setupBuffer() +---@param buftype buftype +local function setupBuffer(buftype) -- buftype="acwrite" means save using the BufWriteCmd command vim.bo.buftype = "acwrite" vim.bo.swapfile = false vim.bo.undofile = false vim.b["encrypted"] = true + -- Lock the encrypted file to read-only mode to avoid corruption + -- caused by unintended modifications. + if buftype == helpers.BUFTYPE.encrypted then + vim.bo.modifiable = false + end createWriteAutoCmd() end |
