diff options
| author | David Elentok <3david@gmail.com> | 2024-05-14 18:15:13 +0300 |
|---|---|---|
| committer | David Elentok <3david@gmail.com> | 2024-05-14 18:17:09 +0300 |
| commit | a805d34f123bc8add01bd44ad28f0baf57710083 (patch) | |
| tree | b868cef404823eaf4b7c78316459cf8b2a3fd013 /lua/encrypt/init.lua | |
| download | encrypt.nvim-a805d34f123bc8add01bd44ad28f0baf57710083.tar.gz | |
Initial commit
Diffstat (limited to 'lua/encrypt/init.lua')
| -rw-r--r-- | lua/encrypt/init.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lua/encrypt/init.lua b/lua/encrypt/init.lua new file mode 100644 index 0000000..53fc259 --- /dev/null +++ b/lua/encrypt/init.lua @@ -0,0 +1,23 @@ +local setupBuffer = require("encrypt.setup-buffer") +local encrypt = require("encrypt.encrypt") +local decrypt = require("encrypt.decrypt") +local helpers = require("encrypt.helpers") + +local function setup() + vim.api.nvim_create_user_command("X", function() + setupBuffer() + encrypt() + end, {}) + + vim.api.nvim_create_autocmd({ "BufReadPost" }, { + callback = function() + local first_line = vim.api.nvim_buf_get_lines(0, 0, 1, false)[1] + if first_line == helpers.ENCRYPTED_PREFIX then + setupBuffer() + decrypt() + end + end, + }) +end + +return { setup = setup } |
