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.
-
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.
- Simple RegExp explanation
- Simple error handling techniques
- CommandLine live explanation
- Language support for LUA, PHP
- 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 (
(?:<name>)
) - non-capturing group (
(?:)
) - look-around (
(?=)
,(?!)
,(?<=)
,(?<!)
)
- named capturing group (
- selecting
- select RegExp then enter command
:Hypersonic
- select RegExp then enter command
- command
- enter command:
:Hypersonic your-regex
- enter command:
- command-line search
- in cmd search
/your-regex
or?your-regex
- in cmd search
Using vim-plug
Plug 'tomiis4/Hypersonic.nvim'
Using packer
use 'tomiis4/Hypersonic.nvim'
Using lazy
{
'tomiis4/Hypersonic.nvim',
event = "CmdlineEnter",
cmd = "Hypersonic",
config = function()
require('hypersonic').setup({
-- config
})
end
},
require('hypersonic').setup()
Default configuration
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
})
| 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
- Take regex from current line.
- Spit to specified format.
- Explain that regex.
- Merge it for better readability.
- Return result in floating window.
input
gr[ae]y
output
{
{
type = "character",
value = "g"
},
{
type = "character",
value = "r"
},
{
type = "class",
value = "ae"
},
{
type = "character",
value = "y"
}
}
meta characters table
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
{
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
- add future char to
[
- get closing
]
- add content between
[]
tomain
- skip to closing
]
- get closing
(
- get closing
)
- add split content between
()
tochildren
- skip to closing
)
- get closing
?
|+
|*
- add char to previous
Node.quantifiers
- add char to previous
- other
- create Node with that char
input
{
{
type = "character",
value = "g"
},
{
type = "character",
value = "r"
},
{
type = "class",
value = "ae"
},
{
type = "character",
value = "y"
}
}
output
{
{
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
- call
type == group
- call
explain
- call
input
{
{
explanation = "Match g",
value = "g"
},
{
explanation = "Match r",
value = "r"
},
{
children = { "a", "e" },
explanation = "Match either",
value = "[ae]"
},
{
explanation = "Match y",
value = "y"
}
}
output
{
{
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 |
+--------------------------------------+
tomiis4 founder |
NormTurtle command-line preview idea |
leekool spelling specialist |