This is not fully baked. I've made a minimal version to validate the idea. If you experience any issues, see some improvement you think would be amazing, or just have some feedback for me , make an issue!
The format may change later if/when more advanced functionality is added.
You're working on a big codebase and write a clever search and replace pattern, but you change machines or lose track of it somehow. Darn it!
The ability to persist your patterns and access them easily with a human-readable name.
- Install using your favorite plugin manager.
use({
"MaximilianLloyd/patternvault.nvim",
branch = "main",
config = function()
require("patternvault").setup({})
end,
})
{
"MaximilianLloyd/patternvault.nvim",
event = "VeryLazy", -- Customize here as wanted
config = function()
require("patternvault").setup()
end
},
PatternVault provides a couple of options to customize the behaviour.
{
yank_register = '+',
root = vim.fn.stdpath("config"),
default_history = 'cmd',
auto_open = true, -- Feeds the pattern to the command line, so you can interact with it.
should_yank = false, -- Should the pattern be yanked to yank_register.
}
add_latest has an optional argument that specifies the history if you want to use another than the default. It defaults to the dir specified in options. I've only considered search and cmd currently. search grabs the latest, for cmnd it searches for the latest %s command.
All of your patterns are stored in a patternvault.json
file that is stored by default in your neovim config directory.
To get started try running PaternVault add_latest
and then PatternVault select
.
Adds the latest pattern from specified default_history
PatternVault add_latest
Uses vim.ui.select
to select a stored pattern. This will feed the pattern into the cmdline.
PatternVault select
Removes a pattern from your list.
PatternVault remove
Edits the name.
PatternVault edit_name
Edits the pattern.
PatternVault edit_patern