Skip to content

Commit

Permalink
More builtins, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
biozz committed Mar 3, 2024
1 parent a852f00 commit 66591ea
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 11 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# Changelog

## Unreleased
## 2024-03-03 - v1.1.0

- Add `opts` table to telescope extension to be able to customize the picker
- Minor changes related to typing and linting
- Add `.luacheckrc`, `.neoconf.json` and `.stylua.toml`
- Add more builin commands:
- PowerShell escape characters to Unix
- Change single quotes to double quotes
- Change double quotes to single quotes
- snake_case to CamelCase (python)
- CamelCase to snake_case (python)
- snake_case to kebab-case (python)
- kebab-case to snake_case (python)
- To UPPER case (python)
- To lower case (python)
- Base32 Encode (python)
- Base32 Decode (python)

## 2024-01-17 - v1.0.1

Expand Down
8 changes: 0 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ Here is a list of ideas for builtin commands:
- Count characters (view only)
- Count words (view only)
- Shuffle lines
- Change cURL format from Windows to Unix
- JSON to Query String
- JSON to YAML
- Lorem ipsum
- HEX to RGB
- RGB to HEX
- JSON to CSV
- CSV to JSON
- Lower Case
- Camel Case
- Snake Case
- Upper Case
- Kebab Case
- Replace single quotes with double quotes
- Replace double quotes with single quotes
- Wrap with single quotes
- Wrap with double quotes

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ Here is a demo:

[![asciicast](https://asciinema.org/a/wsJSeLEqNaHT8f3V6JH4NQRFr.svg)](https://asciinema.org/a/wsJSeLEqNaHT8f3V6JH4NQRFr)

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 vaule)
- and more (see [`builtin.lua`](./lua/whop/builtin.lua))

## Installation

- install `biozz/whop.nvim` with your favourite package manager
Expand Down
4 changes: 2 additions & 2 deletions doc/whop.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
================================================================================
WHOP *whop*

This is a NeoVim tribute to the amazing Mac app - Boop
(https://boop.okat.best/).
This is a NeoVim tribute to the amazing Mac app -
[Boop](https://boop.okat.best/).

This plugin uses [Telescope](https://github.com/nvim-telescope/telescope.nvim)
or `vim.ui.select()` to pick commands. Then it uses entire buffer content as an
Expand Down
47 changes: 47 additions & 0 deletions lua/whop/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ M.commands = {
name = "[builtin] Base64 Decode (base64)",
cmd = [[%!base64 -d]],
},
{
name = "[builtin] Base32 Encode (python)",
cmd = [[%!python -c 'import sys; import base64; print(base64.b32encode(sys.stdin.read()[:-1].encode()).decode())']],
},
{
name = "[builtin] Base32 Decode (python)",
cmd = [[%!python -c 'import sys; import base64; print(base64.b32decode(sys.stdin.read()[:-1]).decode())']],
},
{
name = "[builtin] Format JSON (jq)",
cmd = [[%!jq]],
Expand Down Expand Up @@ -131,6 +139,45 @@ M.commands = {
name = "[builtin] Ansible Vault Decrypt (ansible-vault)",
cmd = [[%!ansible-vault decrypt]],
},
{
name = "[builtin] PowerShell escape characters to Unix",
cmd = function()
vim.cmd([[%s/\^$/\\/]])
vim.cmd([[%s/\^\\\^/\\/g]])
end,
},
{
name = "[builtin] Change single quotes to double quotes",
cmd = [[%s/'/"/g]],
},
{
name = "[builtin] Change double quotes to single quotes",
cmd = [[%s/"/'/g]],
},
{
name = "[builtin] snake_case to CamelCase (python)",
cmd = [[%!python -c 'import sys; print("".join(map(lambda x: x[0].upper() + x[1:], sys.stdin.read()[:-1].split("_"))))']],
},
{
name = "[builtin] CamelCase to snake_case (python)",
cmd = [[%!python -c 'import sys; print("".join(map(lambda y: f"_{y.lower()}" if y.isupper() else y, [ z for z in sys.stdin.read()[:-1] ]))[1:])']],
},
{
name = "[builtin] snake_case to kebab-case (python)",
cmd = [[%!python -c 'import sys; print(sys.stdin.read()[:-1].replace("_", "-"))']],
},
{
name = "[builtin] kebab-case to snake_case (python)",
cmd = [[%!python -c 'import sys; print(sys.stdin.read()[:-1].replace("-", "_"))']],
},
{
name = "[builtin] To UPPER case (python)",
cmd = [[%!python -c 'import sys; print(sys.stdin.read()[:-1].upper())']],
},
{
name = "[builtin] To lower case (python)",
cmd = [[%!python -c 'import sys; print(sys.stdin.read()[:-1].lower())']],
},
}

return M

0 comments on commit 66591ea

Please sign in to comment.