Skip to content

feature: Add commands for easier execution, instead of running code directly in lua #20

Description

@diegobit

Did you check the docs?

  • I have read all the docs

Is your feature request related to a problem? Please describe.

The only way to use the plugin right after the install is to run it with lua, as shown in the video in the README, such as :'<,'>lua require('decipher').encode_selection("base64").

Describe the solution you would like

It would be nice to have some commands, such as :EncodeBase64, :EncodeCrockford, etc.
This would also allow to start the plugin only when needed with the 'Cmd' feature of Lazy.

Describe alternatives you have considered

Providing pre-made copy pastable mappings to put into the user config...

Additional context

Right now I set the plugin like this, to have easier access to its features:

return {
  'MisanthropicBit/decipher.nvim',
  version = '*',
  event = 'VeryLazy',
  config = function()
    local decipher = require 'decipher'
    decipher.setup {
      vim.keymap.set({ 'n', 'v' }, '<leader>ube', function()
        decipher.encode_selection 'base64'
      end, { noremap = true, silent = true, desc = '[B]ase64 [E]ncode' }),
      vim.keymap.set({ 'n', 'v' }, '<leader>ubd', function()
        decipher.decode_selection 'base64'
      end, { noremap = true, silent = true, desc = '[B]ase64 [D]ecode' }),

      vim.keymap.set({ 'n', 'v' }, '<leader>ubse', function()
        decipher.encode_selection 'base64-url-safe'
      end, { noremap = true, silent = true, desc = '[B]ase64 URL [S]afe [E]ncode' }),
      vim.keymap.set({ 'n', 'v' }, '<leader>ubsd', function()
        decipher.decode_selection 'base64-url-safe'
      end, { noremap = true, silent = true, desc = '[B]ase64 URL [S]afe [D]ecode' }),

      vim.keymap.set({ 'n', 'v' }, '<leader>uue', function()
        decipher.encode_selection 'url'
      end, { noremap = true, silent = true, desc = '[U]RL [E]ncode' }),
      vim.keymap.set({ 'n', 'v' }, '<leader>uud', function()
        decipher.decode_selection 'url'
      end, { noremap = true, silent = true, desc = '[U]RL [D]ecode' }),
    }
  end,
}

Note: For anyone wondering, the u in <leader>u... stands for Utils

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions