Open Python package documentation from Neovim.
Place cursor on any third-party symbol (function, class, module) and run :PydocOpen or press <leader>pd. The plugin uses the LSP to resolve which package the symbol belongs to, then opens its documentation URL in your browser.
- LSP-aware — queries
textDocument/definitionto find the package even when cursor is on a member (e.g.requests.get()) - Falls back to
<cword>— works without an LSP client - Resolves import-name mismatches — handles cases like
PIL→pillow,dateutil→python-dateutil - Command completion —
:PydocOpen <Tab>lists installed packages - Customizable Python — configure the Python interpreter via
setup()
:PydocOpen Open docs for symbol under cursor
:PydocOpen requests Open docs for a specific package
<leader>pd Normal mode mapping (same as :PydocOpen)
- Neovim ≥ 0.7 (for
nvim_create_user_command) - Python ≥ 3.8 (for
importlib.metadata) - LSP client for Python (optional, for LSP-based resolution)
{
dir = '/path/to/pydoc.nvim',
config = function()
require('pydoc').setup({ python_cmd = 'python3' })
end,
}require('pydoc').setup({
python_cmd = 'python3', -- Python interpreter command
fallback = true, -- fall back to Home-page if no Project-URL
})- Resolve the package name (LSP definition path → site-packages directory → top-level name)
- Query Python's
importlib.metadataforProject-URL: Documentation - Fall back to
Home-pageif no Documentation URL is found - Open the URL with
vim.ui.openorxdg-open
This plugin was generated by AI (Anthropic Claude).