🔥 Performance
The plugin is designed to search only in specific paths to find virtual environments.
But the cwd search can sometimes be slow. Lets use it as an example of a slow search and show what can be done about it.
The cwd search as an example
If you open neovim in your $HOME folder, the plugin's cwd search will search your entire $HOME directory.
The default cwd search looks like this on linux (other operating systems here)
search = {
cwd = {
command = "$FD '/bin/python$' $CWD --full-path --color never -HI -a -L -E /proc -E .git/ -E .wine/ -E .steam/ -E Steam/ -E site-packages/"
}
}
🎯 Search Pattern & Target:
- 🔍
'/bin/python$'- Find files ending with/bin/pythonusing regex - 📁
$CWD- Search current working directory
⚙️ Output Options:
- 🛤️
--full-path- Show full absolute paths in results - 🎨
--color never- Disable colored output - 📍
-a- Show absolute paths
🔎 Search Behavior:
- 👁️
-H- Search hidden files and directories - 🚫
-I- Don't respect.gitignorefiles - 🔗
-L- Follow symbolic links
⛔ Excluded Directories:
- 🖥️
-E /proc- System process directory - 📚
-E .git/- Git repositories - 🍷
-E .wine/- Wine directories - 🎮
-E .steam/-E Steam/- Steam gaming directories - 📦
-E site-packages/- Python package installations
The plugin searches all hidden files and directories, including paths in .gitignore files, to ensure virtual environments are found without configuration. However, this can be slow on systems with many files.
⚡ Improving Performance
🚀 Option 1: Skip Hidden Files
If your virtual environments aren't hidden (no dot-prefixed names), remove the -HI flags:
search = {
cwd = {
command = "$FD '/bin/python$' $CWD --full-path --color never -a -L -E /proc -E .git/ -E .wine/ -E .steam/ -E Steam/ -E site-packages/"
}
}
✅ Much faster on most systems
❌ Won't find hidden virtual environments
🎯 Option 2: Target Specific Directories
Replace the broad cwd search with targeted project directories:
search = {
cwd = false, -- Disable built-in cwd search
my_projects = {
command = "$FD '/bin/python$' ~/Code/MyProjects --full-path --color never -HI -a -L -E /proc -E .git/ -E .wine/ -E .steam/ -E Steam/ -E site-packages/"
}
}
This approach:
- 🚫 Disables the slow
cwdsearch - 📁 Adds a focused search in
~/Code/MyProjects - 🔍 Still searches hidden files but in a limited scope
🎯 Best for most users - especially if you organize projects in specific directories. Much faster than searching your entire home directory!