[!IMPORTANT]
A bit library is needed which requires that either neovim has been compiled with luajit or you are using v0.9.0+ which provides a bit library.
Requires at least neovim v0.8.0.
Plug 'MisanthropicBit/decipher.nvim'
use 'MisanthropicBit/decipher.nvim'
Setup decipher using decipher.setup
unless you are content with the defaults.
The options below are the default values. Refer to the
docs for more help.
require("decipher").setup({
float = { -- Floating window options
padding = 0, -- Zero padding (does not apply to title if any)
border = { -- Floating window border
{ "╭", "FloatBorder" },
{ "─", "FloatBorder" },
{ "╮", "FloatBorder" },
{ "│", "FloatBorder" },
{ "╯", "FloatBorder" },
{ "─", "FloatBorder" },
{ "╰", "FloatBorder" },
{ "│", "FloatBorder" },
},
mappings = {
close = "q", -- Key to press to close the floating window
apply = "a", -- Key to press to apply the encoding/decoding
jsonpp = "J", -- Key to prettily format contents as json if possbile
help = "?", -- Toggle help
},
title = true, -- Display a title with the codec name
title_pos = "left", -- Position of the title
autoclose = true, -- Autoclose floating window if insert
-- mode is activated or the cursor is moved
enter = false, -- Automatically enter the floating window if
-- opened
options = {}, -- Options to apply to the floating window contents
},
})
There are several ways in which you can invoke decipher
. Check out the
docs for more info. Below are some examples:
-- Encode visually selected text as base64. If invoked from normal mode it will
-- try to use the last visual selection
vim.keymap.set({ "n", "v" }, "<mykeymap>", function()
require("decipher").encode_selection("base64")
end)
-- Decode encoded text using a motion, selecting a codec and previewing the result
vim.keymap.set("n", "<mykeymap>", function()
require("decipher").decode_motion_prompt({ preview = true })
end)
Example: "this is encoded" => "ORUGS4ZANFZSAZLOMNXWIZLE"
Example "light work." => "bGlnaHQgd29yay4="
Url-safe version of base64 with optional padding used in json web tokens.
Example "light work." => "bGlnaHQgd29yay4"
(base64 would have added a single '='
at the end)
Url-safe version of base64 that uses a different encoding table to avoid use of url-unsafe characters. This is basically base64url with mandatory padding.
Example "🔑_🏧⛳🈹" => "8J-UkV_wn4-n4puz8J-IuQ=="
Url-safe version of base64 with url percent-encoding.
Example "🔑_🏧⛳🈹" => "8J%2bUkV%2fwn4%2bn4puz8J%2bIuQ%3d%3d"
Variant of base32 which excludes 'I', 'L', 'O', and 'U' to avoid confusion with digits.
Example: "this is encoded" => "EHM6JWS0D5SJ0SBECDQP8SB4"
Also known as percent-encoding.
Example th<is is encod!ed> => th%3cis+is+encod%21ed%3e
A more human-readable version of base32.
Example: "this is encoded" => "qtwg1h3ypf31y3mqcpzse3mr"