Skip to main content

🗂️ Built-in searches

The plugin uses fd for the built-in searches. Its possible to set the option fd_binary_name if your binary has a different name on your system, but the plugin attempts to find and use common names like fdfind or fd_find automatically.

Built-in searches

📝 Poetry~/.cache/pypoetry/virtualenvs
🐍 Pyenv~/.pyenv/versions
🔧 Pipenv~/.local/share/virtualenvs
📦 Pipx~/.local/share/pipx/venvs, ~/.local/pipx/venvs
🥚 Hatch~/.local/share/hatch
🐍 Vanilla python venvs~/.virtualenvs
🐍 Anaconda Base/opt/anaconda/bin
🐍 Anaconda Environments~/.conda/envs
🐍 Miniconda Base~/miniconda3/bin
🐍 Miniconda Environments~/miniconda3/envs
📁 cwdcurrent working dir
🔧 workspacelsp workspace dirs
📄 fileactive file dir

Disabling built-in searches

This is useful if you have virtual environments in the default locations but you dont want them to show up in the plugin.

How to disable searches

To turn off all built-in searches:

opts = {
options = {
enable_default_searches = false -- disable all built-in searches
}
}

To turn off only some searches, create a new search with the same name and set it to false:

opts = {
search = {
hatch = false,
pipx = false
}
}

Overriding built-in searches

You can override any built-in search by creating a new search with the same name as the built-in one:

opts = {
search = {
anaconda = {
command = "$FD '/python$' /opt/anaconda/bin --full-path --color never"
type = "anaconda" -- This needs to be set for anaconda and miniconda environments ONLY
}
}
}
Overriding searches

The built-in searches look different for different operating systems.

Look in the plugin code here to see how the built-in searches are written for your operating system.

The $FD variable gets replaced with your fd binary.

Its a good idea to test the search you are creating outside of neovim first. It needs to return only python interpreters with absolute paths, like this:

$ fd '/python$' /opt/anaconda/bin --full-path --color never
/opt/anaconda/bin/python

This is similar to overriding an built-in search. You just give it your own name.

opts = {
search = {
my_projects = {
command = "$FD '/python$' ~/Code/PythonProjects --full-path --color never"
}
}
}

Otherwise the same ideas from Overriding built-in searches applies here too.

Setting the type for a search

Set the type to anaconda both for anaconda and miniconda searches.

The plugin uses this information to set the correct environment variables in the terminal.

Dont set the type at all for other venv managers.

Testing your searches

Testing from inside VenvSelector

When creating your own search, you can test the command from inside VenvSelector like this:

:VenvSelect fd 'python$' ~/Code --full-path -IH -a

Replace the paths with somewhere your venvs live and you should get results of type interactive like this:

Screenshot

Once it works, you can add the search to your config.

Testing in a terminal

Test the command in a terminal like this (replacing the paths to suit your system)

fd 'python$' ~/Code --full-path -IH -a

These can be used in your searches to target specific paths that neovim knows about.

VariableDescription
$CWDCurrent working directory. The directory where you start neovim.
$WORKSPACE_PATHThe workspace directories found by your LSP when you have an opened python file.
$FILE_DIRThe directory of the file in the neovim buffer.