This is a NeoVim tribute to the amazing Mac app - Boop.
This plugin uses Telescope or vim.ui.select()
to pick commands.
Then it uses entire buffer content as an input to the chosen command.
After running the command, the buffer content is replaced with the result of the command.
Here is a demo:
Here is what this plugin can do:
- Encode and decode base64, base32, url params, html
- Format and minify json
- Hashing (md5, sha1, sha256, sha512)
- Common strings manipulation (rever, remove whitespace, case change)
- Large files manipulation (join lines, wrap each line with single and double quotes, remove duplicate lines)
- Encryption (ansible value)
- and more (see BUILTINS.md and
builtin.lua
)
- install
biozz/whop.nvim
with your favourite package manager - configure with
require('whop').setup({})
(see Custom commands below)
Now you have three options to start using it:
- Telescope extension
vim.ui.select()
:Whop
command
- load Telescope extension
telescope.load_extension("whop")
- use
:Telescope whop
to open the commands picker
Here is an all-in-one example using Lazy:
{
"nvim-telescope/telescope.nvim",
dependencies = {
{
"biozz/whop.nvim",
config = function()
require("whop").setup({})
end
}
},
config = function()
telescope.load_extension("whop")
vim.keymap.set("n", "<leader>tw", ":Telescope whop<CR>", { noremap = true, desc = "whop.nvim (telescope)" })
end
}
The select function is available in require('whop').select()
.
{
"biozz/whop.nvim",
config = function()
local whop = require("whop")
whop.setup({})
vim.keymap.set("n", "<leader>ww", function()
whop.select()
end, { noremap = true, desc = "whop.nvim" })
end
}
The setup
function has commands
option, which is a list of objects, containing name
and cmd
.
cmd
can be either string or Lua function.
If it is a string, it will be passed to vim.cmd
and executed as if you typed :
(colon), the value of the cmd
and hit enter.
If it is a function, it will be called when picked. Functions have an additional benefit – arguments. You can specify the inputs
and they will be passed into the function for further customization. This can be useful for transformations, which require additional parameters, ex. Caesar Cipher offset.
Here is a full example:
{
"biozz/whop.nvim",
config = function()
require("whop").setup({
commands = {
{
name = "My command",
cmd = [[%!my_command]],
},
{
name = "My other command",
inputs = { { prompt = "Arg1:", dest = "arg1" } }
cmd = function(args)
-- args['arg1']
vim.cmd('%s/ //g')
end,
}
}
})
end,
}