Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomiis4/Hypersonic.nvim
A Neovim plugin that provides an explanation for regular expressions.
https://github.com/tomiis4/Hypersonic.nvim
awesome-neovim lua neovim regex
Last synced: 8 days ago
JSON representation
A Neovim plugin that provides an explanation for regular expressions.
- Host: GitHub
- URL: https://github.com/tomiis4/Hypersonic.nvim
- Owner: tomiis4
- License: apache-2.0
- Created: 2023-01-25T16:57:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-11T17:31:34.000Z (3 months ago)
- Last Synced: 2024-08-11T19:03:20.296Z (3 months ago)
- Topics: awesome-neovim, lua, neovim, regex
- Language: Lua
- Homepage:
- Size: 179 KB
- Stars: 208
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-neovim-pluginlist - tomiis4/Hypersonic.nvim - commit/tomiis4/Hypersonic.nvim) ![](https://img.shields.io/github/commit-activity/y/tomiis4/Hypersonic.nvim) (Coding / Regex)
README
Hypersonic - NeoVim Plugin for Regex Writing and Testing
A powerful NeoVim plugin created to increase your regular expression (RegExp) writing and testing experience.
Whether you're a newbie or professional developer, Hypersonic is here to make your life easier and boost your productivity.
Colorscheme: Rose-Pine; Font: JetBrainsMono NF
## Features
- **Interactive RegExp Testing**: Hypersonic provides an interactive testing environment right within NeoVim. You can easily write your RegExp patterns and instantly see the matches highlighted in real-time.
- **Pattern Explanation**: Understanding complex RegExp patterns can be challenging. Hypersonic comes with an integrated pattern explanation feature that provides detailed explanations for your RegExp patterns, helping you grasp their meaning and behavior.
## Currently accessible
- Simple **RegExp** *explanation*
- Simple **error** handling techniques
- **CommandLine** *live* *explanation*
- Language support for **LUA**, **PHP**## Known issues
- Does not work in `v0.8.3` (only tested one)
- Nested groups do not display correctly
- Advanced regex is not working (e.g. `(?:)`)
- [ ] named capturing group (`(?:)`)
- [ ] non-capturing group (`(?:)`)
- [ ] look-around (`(?=)`, `(?!)`, `(?<=)`, `(?
preview
2. command
- enter command: `:Hypersonic your-regex`
-
preview
3. command-line search
- in cmd search `/your-regex` or `?your-regex`
-
preview
## Installation
Using vim-plug
```vim
Plug 'tomiis4/Hypersonic.nvim'
```Using packer
```lua
use 'tomiis4/Hypersonic.nvim'
```Using lazy
```lua
{
'tomiis4/Hypersonic.nvim',
event = "CmdlineEnter",
cmd = "Hypersonic",
config = function()
require('hypersonic').setup({
-- config
})
end
},
```## Setup
```lua
require('hypersonic').setup()
```Default configuration
```lua
require('hypersonic').setup({
---@type 'none'|'single'|'double'|'rounded'|'solid'|'shadow'|table
border = 'rounded',
---@type number 0-100
winblend = 0,
---@type boolean
add_padding = true,
---@type string
hl_group = 'Keyword',
---@type string
wrapping = '"',
---@type boolean
enable_cmdline = true
})
```## File order
```
| LICENSE
| README.md
|
+---lua
| \---hypersonic
| config.lua
| explain.lua
| init.lua
| merge.lua
| split.lua
| tables.lua
| utils.lua
|
+---plugin
| hypersonic.lua
|
\---test
testing_file.txt
testing_file.lua
```How does it work
## How does it work?
### Process
- Take regex from current line.
- Spit to specified format.
- Explain that regex.
- Merge it for better readability.
- Return result in floating window.### Split
input
```
gr[ae]y
```output
```lua
{
{
type = "character",
value = "g"
},
{
type = "character",
value = "r"
},
{
type = "class",
value = "ae"
},
{
type = "character",
value = "y"
}
}
```meta characters table
```lua
local meta_table = {
['n'] = 'Newline',
['r'] = 'Carriage return',
['t'] = 'Tab',
['s'] = 'Any whitespace character',
['S'] = 'Any non-whitespace character',
['d'] = 'Any digit',
-- more in tables.lua
}
```Node
```lua
{
type = 'character'|'escaped'|'class'|'group'|'quantifier',
value = '',
children = Node|{},
quantifiers = ''
}
```- create new table `main={}` (type: _Node[]_)
- loop for each char
- `\`
- add future char to `main`
- skip that char
- `[`
- get closing `]`
- add content between `[]` to `main`
- skip to closing `]`
- `(`
- get closing `)`
- add split content between `()` to `children`
- skip to closing `)`
- `?`|`+`|`*`
- add char to previous `Node.quantifiers`
- other
- create Node with that char### Explain
input
```js
{
{
type = "character",
value = "g"
},
{
type = "character",
value = "r"
},
{
type = "class",
value = "ae"
},
{
type = "character",
value = "y"
}
}
```output
```lua
{
{
explanation = "Match g",
value = "g"
},
{
explanation = "Match r",
value = "r"
},
{
children = { "a", "e" },
explanation = "Match either",
value = "[ae]"
},
{
explanation = "Match y",
value = "y"
}
}
```- create new table `main={}` (type: _Explained[]_)
- loop for each Node
- `type == escaped | character`
- explain character
- check if is in any table
- return that value
- `type == class`
- call `explain_class`
- `type == group`
- call `explain`### Merge
input
```js
{
{
explanation = "Match g",
value = "g"
},
{
explanation = "Match r",
value = "r"
},
{
children = { "a", "e" },
explanation = "Match either",
value = "[ae]"
},
{
explanation = "Match y",
value = "y"
}
}
```output
```lua
{
{
explanation = "Match gr",
value = "gr"
},
{
explanation = "Match either",
children = { "a or e" },
value = "[ae]"
},
{
explanation = "Match y",
value = "y"
}
}
```NeoVim output
```
+-gr[ae]y------------------------------+
| "gr": Match gr |
| "[ae]": Match either |
| 1) a or e |
| "y": Match y |
+--------------------------------------+
```## Contributors
tomiis4
founder
NormTurtle
command-line preview idea
leekool
spelling specialist