MisanthropicBit/decipher.nvim

github github
utilitytext-objectplugin
stars 33
issues 1
subscribers 3
forks 1
CREATED

2022-11-28

UPDATED

3 months ago


[!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.

demo

Installing

Plug 'MisanthropicBit/decipher.nvim'
use 'MisanthropicBit/decipher.nvim'

Setup

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({
    active_codecs = "all", -- Set all codecs as active and useable
    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
    },
})

Example keymaps

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)

Supported Codecs

  • ✅ = supported
  • ❌ = not supported
  • 🗓️ = planned
Codec Encoding Decoding
base32
zbase32
crockford
base64
base64-url¹
base64-url-safe²
url

¹ Combination of base64 and url codecs.

² Base64-variant that is safe to include in urls.