[!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. Please check the docs.
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 the full api. 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)
decipher.codec.base32"this is encoded" => "ORUGS4ZANFZSAZLOMNXWIZLE"decipher.codec.base64"light work." => "bGlnaHQgd29yay4="Url-safe version of base64 with optional padding used in json web tokens.
decipher.codec.base64_url"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.
decipher.codec.base64_url_safe"🔑_🏧⛳🈹" => "8J-UkV_wn4-n4puz8J-IuQ=="Url-safe version of base64 with url percent-encoding.
decipher.codec.base64_url_encoded"🔑_🏧⛳🈹" => "8J%2bUkV%2fwn4%2bn4puz8J%2bIuQ%3d%3d"Encoding and decoding of C-style strings, backslashes escape control characters,
quotation marks, and backslashes. Ported from
vim-unimpaired.
decipher.codec.c_escape"line1\nline2" => "line1\\nline2"Variant of base32 which excludes 'I', 'L', 'O', and 'U' to avoid confusion with digits.
decipher.codec.crockford
Example: "this is encoded" => "EHM6JWS0D5SJ0SBECDQP8SB4"Also known as percent-encoding.
decipher.codec.urlth<is is encod!ed> => th%3cis+is+encod%21ed%3eUrl/percent-encoding but usually used for the mime type
application/x-www-urlencoded which represents spaces by + instead of %20.
decipher.codec.url_plusth<is is encod!ed> => th%3cis%20is%20encod%21ed%3eEncodes/decodes xml components. Also decodes html entities. Ported from
vim-unimpaired.
decipher.codec.xml"<tag>value</tag> => <tag>value</tag>A more human-readable version of base32.
decipher.codec.zbase32"this is encoded" => "qtwg1h3ypf31y3mqcpzse3mr"