Lightweight, configurable CodeLens for Python — shows references, implementations, and scoped imports directly above each symbol.
Powered entirely by VS Code's native
DocumentSymbolProviderandReferenceProvider(Pylance / Pyright). No extra runtime dependencies.
- Reference counts above classes, methods, functions, variables, and imports.
- Implementation counts for classes (how many subclasses inherit from them).
- Scoped import lenses with fine-grained classification: project, venv, stdlib, or global.
- Smart filtering — exclude import statements, the definition itself, or self-references from the count.
- Click action — open an inline peek view or jump to a matching reference.
- Per-resource configuration — different settings per workspace folder or file.
- Performance guards — shared symbol/reference caching, configurable debounce delay, targeted symbol invalidation, and file-size limit.
- Localized UI — settings descriptions and command titles are shown in English or Brazilian Portuguese automatically based on your VS Code display language.
- VS Code
1.96.0or later. - A Python language server that provides references (e.g. Pylance or Pyright).
Without one, all counts will show0 references.
From the Marketplace:
Search for Python CodeLens Lite in the VS Code Extensions view.
From a .vsix file:
npm run package # generates python-codelens-lite-x.x.x.vsixThen: Extensions → ··· → Install from VSIX…
| Command | Description |
|---|---|
Python CodeLens Lite: Toggle CodeLens |
Enable / disable the extension globally. |
Python CodeLens Lite: Refresh Lenses |
Force-refresh all CodeLenses in the active editor. |
Access via the Command Palette (Ctrl+Shift+P / ⌘⇧P).
All settings support resource scope (per-folder or per-file overrides via .vscode/settings.json).
| Setting | Default | Description |
|---|---|---|
pythonCodeLensLite.enable |
true |
Enable or disable the extension. |
pythonCodeLensLite.files.includeInitPy |
true |
Include __init__.py files when showing CodeLens and counting references. |
pythonCodeLensLite.clickAction |
"peek" |
"peek" opens an inline peek view; "reveal" jumps to a matching reference in the editor. |
| Setting | Default | Description |
|---|---|---|
pythonCodeLensLite.targets.classes |
true |
CodeLens for class definitions. |
pythonCodeLensLite.targets.methods |
true |
CodeLens for methods (functions inside classes). |
pythonCodeLensLite.targets.functions |
true |
CodeLens for top-level functions. |
pythonCodeLensLite.targets.moduleVariables |
false |
CodeLens for module-level variables / constants. |
pythonCodeLensLite.targets.imports.project |
false |
CodeLens for imports from within the workspace. |
pythonCodeLensLite.targets.imports.venv |
false |
CodeLens for imports from virtual environments. |
pythonCodeLensLite.targets.imports.stdlib |
false |
CodeLens for standard library imports. |
pythonCodeLensLite.targets.imports.global |
false |
CodeLens for imports that cannot be classified. |
| Setting | Default | Description |
|---|---|---|
pythonCodeLensLite.references.filterImports |
true |
Exclude occurrences inside import/from statements. |
pythonCodeLensLite.references.filterDefinitions |
true |
Exclude the definition's own location from the count. |
pythonCodeLensLite.references.filterSelf |
false |
Exclude references inside the symbol's own scope. |
pythonCodeLensLite.references.minCount |
0 |
Hide lens when filtered count is below this value. |
pythonCodeLensLite.references.showZero |
true |
Hide lenses with exactly zero references when false. |
| Setting | Default | Description |
|---|---|---|
pythonCodeLensLite.lenses.showImplementations |
true |
Show a second lens with the subclass count for classes. |
| Setting | Default | Description |
|---|---|---|
pythonCodeLensLite.performance.debounceMs |
200 |
Milliseconds to wait after typing before refreshing. |
pythonCodeLensLite.performance.maxFileSizeKB |
10240 |
Skip files larger than this size (in KB). Use 0 to disable this guard. |
| Setting | Default | Description |
|---|---|---|
pythonCodeLensLite.exclude |
["**/.venv/**", ...] |
Glob patterns for files that should be skipped entirely. |
The extension automatically adapts to your VS Code display language:
- English (
en) — default. - Brazilian Portuguese (
pt-br) — settings descriptions and command titles are shown in Portuguese when VS Code is set topt-BR.
To change your VS Code display language: Configure Display Language in the Command Palette.
Hide lenses on rarely-referenced symbols
See which parts of your project import a given module
"pythonCodeLensLite.targets.imports.project": true,
"pythonCodeLensLite.references.filterImports": falseReduce CPU usage on large codebases
"pythonCodeLensLite.performance.debounceMs": 500,
"pythonCodeLensLite.performance.maxFileSizeKB": 256Ignore package initializer files
"pythonCodeLensLite.files.includeInitPy": falseExclude generated or vendored files
"pythonCodeLensLite.exclude": [
"**/.venv/**",
"**/venv/**",
"**/site-packages/**",
"**/__pycache__/**",
"**/migrations/**",
"**/vendor/**"
]- On activation, a
CodeLensProvideris registered for all Python (filescheme) documents. provideCodeLensesuses VS Code'sDocumentSymbolProviderto list eligible symbols, then emits placeholder lenses.- Symbol discovery is cached per document version, so repeated CodeLens passes do not re-read the same symbol tree.
resolveCodeLenscallsvscode.executeReferenceProvider, caches raw references per symbol position, filters results, and reuses the filtered result for repeated resolutions.- Configuration is cached per URI and invalidated whenever settings change or workspace folders are added/removed.
- Document edits are debounced, invalidate only the edited document's symbol cache, and clear reference caches globally so counts stay consistent across files.
Issues and pull requests are welcome. The project has no runtime dependencies — keep it that way.
npm install # install dev dependencies
npm run check # type-check without emitting files
npm run compile # bundle dist/extension.js
npm run watch # compile + watch
# Press F5 in VS Code to launch an Extension Development HostYou can submit a bug report or a feature suggestion via GitHub Issue Tracker.
