A tiny project search menu for LazyVim / Neovim.
Turn repeated searches like queryKey, className, hooks/use-*, or service/*.ts into reusable project presets.
Press one key, pick a search, done.
Most projects have a few searches you run again and again.
For example, in a React project you may often search for:
queryKeyclassName- custom hooks
- route definitions
- service layer files
- TODO / FIXME
- environment variable usage
This plugin lets you save those searches as project-local presets and open them from one fast picker.
Rules are stored outside your source repository:
~/.local/share/nvim/project-search/rules/
So your project stays clean.
Create:
~/.config/nvim/lua/plugins/lazy-project-search.lua
return {
{
"CoderLambert/lazy-project-search.nvim",
main = "project_search",
dependencies = {
"folke/snacks.nvim",
},
cmd = {
"ProjectSearch",
},
keys = {
{
"<C-p>",
"<cmd>ProjectSearch<cr>",
desc = "Project Search",
},
},
opts = {
keymap = false,
},
},
}Then run:
:Lazy syncLazyVim users should enable Snacks Picker:
:LazyExtrasEnable:
editor.snacks_picker
Install ripgrep and fd.
Ubuntu / Linux Mint:
sudo apt update
sudo apt install -y ripgrep fd-find
mkdir -p ~/.local/bin
ln -sf "$(command -v fdfind)" ~/.local/bin/fdArch Linux:
sudo pacman -S ripgrep fdmacOS:
brew install ripgrep fdOpen a project and run:
:ProjectSearchOr press:
<C-p>
On first use, the plugin creates a rules file for the current project.
Edit that JSON file, save it, then open :ProjectSearch again.
:ProjectSearch
:ProjectSearch edit
:ProjectSearch validate
:ProjectSearch reload
:ProjectSearch reset
:ProjectSearch path
:ProjectSearch healthSearch queryKey in React files:
{
"id": "react.query_key",
"name": "React: queryKey",
"type": "grep",
"search": "queryKey",
"dirs": ["src", "app"],
"glob": ["*.ts", "*.tsx"]
}Find hook files like hooks/use-user-panel.ts:
{
"id": "react.hooks",
"name": "Hooks: use-* files",
"type": "files_regex",
"regex": "(^|/)hooks/use-[a-z0-9-]+\\.(ts|tsx|js|jsx)$",
"dirs": ["src", "app", "packages"]
}Open files under src:
{
"id": "files.src",
"name": "Files: src",
"type": "files",
"cwd": "src"
}| Type | Use for |
|---|---|
files |
Open a file picker in a directory |
grep |
Search text in files |
files_regex |
Find files by path pattern |
Run:
:ProjectSearch healthOr:
:checkhealth project_searchCommon checks:
| Problem | Check |
|---|---|
grep result is empty |
Make sure ripgrep is installed |
files_regex result is empty |
Make sure fd is installed |
| First use opens a JSON file | This is expected. Edit and save it |
| Keymap does nothing | Check :verbose nmap <C-p> |
Usable for daily LazyVim / Neovim workflows.
The rule format may still change before v1.0.0.
