Skip to main content

Workspace symbols, inlay hints, call/type hierarchy, document links and colors for python-lsp-server via Jedi

Project description

pylsp-workspace-symbols

CI PyPI PyPI - Python Version Downloads License: MIT

A python-lsp-server plugin that adds workspace symbol search, inlay hints, call/type hierarchy, document links and document colors via Jedi.

Why? pylsp does not implement several LSP features natively. This plugin fills those gaps — enabling "Go to Symbol in Workspace", rich type inference hints, call/type hierarchy navigation, clickable import links, and inline color previews in any LSP client — including CudaText, Neovim, Emacs, and others — with broad client compatibility out of the box.


✨ Features

  • 🔍 Workspace-wide symbol search — find functions, classes, and modules across all files in the project
  • 💡 Inlay hints — inline type annotations inferred by Jedi for assignments, return types, raised exceptions, and parameter names at call sites
  • 🌳 Call hierarchy — navigate callers and callees of any function via callHierarchy/incomingCalls and callHierarchy/outgoingCalls
  • 🧬 Type hierarchy — explore supertypes and subtypes of any class via typeHierarchy/supertypes and typeHierarchy/subtypes
  • 🔗 Document links — clickable links for URLs in comments/strings and import statements (resolves to stdlib source when available)
  • 🎨 Document colors — inline color previews for CSS/hex/RGB/HSL color literals in source files
  • 🔌 Broad client compatibility — capabilities announced via proper LSP channel (works with Neovim, eglot, and any client that does not support experimental capabilities), with automatic fallback to the experimental channel
  • Fast — results in ~130ms after the first call (Jedi cache warm)
  • 🔤 Case-insensitive substring matcharea finds calculate_area, Cal finds Calculator
  • 📁 Smart folder exclusion — automatically skips .git, __pycache__, node_modules, .venv, dist, build, and more
  • ⚙️ Configurable — tune all options via pylsp settings
  • 🐍 Python 3.8+ — compatible with all modern Python versions

📦 Installation

pip install pylsp-workspace-symbols

The plugin is discovered automatically by pylsp via its entry point — no manual configuration needed.

⚙️ Configuration

Add to your LSP client's pylsp settings (e.g. in settings.json or equivalent):

{
  "pylsp": {
    "plugins": {
      "jedi_workspace_symbols": {
        "enabled": true,
        "max_symbols": 500,
        "ignore_folders": []
      },
      "inlay_hints": {
        "enabled": true,
        "show_assign_types": true,
        "show_return_types": true,
        "show_raises": true,
        "show_parameter_hints": true,
        "max_hints_per_file": 200
      },
      "call_hierarchy": {
        "enabled": true
      },
      "type_hierarchy": {
        "enabled": true
      },
      "document_links": {
        "enabled": true
      },
      "document_colors": {
        "enabled": true
      }
    }
  }
}

Workspace symbol options

Option Type Default Description
enabled bool true Enable/disable workspace symbol search
max_symbols int 500 Maximum symbols returned. 0 means no limit
ignore_folders list [] Extra folder names to skip (merged with built-in list)

Inlay hint options

Option Type Default Description
enabled bool true Enable/disable all inlay hints
show_assign_types bool true Show inferred types for unannotated assignments (x = 42: int)
show_return_types bool true Show inferred return types for unannotated functions (def f():-> str)
show_raises bool true Show raised exception types (raise ValueError(...)Raises: ValueError)
show_parameter_hints bool true Show parameter names at call sites (f(1, 2)a=1, b=2)
max_hints_per_file int 200 Maximum hints per file. 0 means no limit

Call hierarchy options

Option Type Default Description
enabled bool true Enable/disable call hierarchy (callHierarchy/incomingCalls, callHierarchy/outgoingCalls)

Type hierarchy options

Option Type Default Description
enabled bool true Enable/disable type hierarchy (typeHierarchy/supertypes, typeHierarchy/subtypes)

Document links options

Option Type Default Description
enabled bool true Enable/disable document links (URLs in comments/strings and import resolution)

Document colors options

Option Type Default Description
enabled bool true Enable/disable document color previews (hex, RGB, HSL, CSS named colors)

Built-in ignored folders

.git, .hg, .svn, __pycache__, .mypy_cache, .ruff_cache, .pytest_cache, node_modules, .venv, venv, .env, env, dist, build, .eggs, egg-info

🚀 Usage

Workspace symbol search

Once installed, your LSP client will receive workspaceSymbolProvider: true in the server capabilities. Use your client's "Go to Symbol in Workspace" command (typically Ctrl+T or # in the symbol picker).

Inlay hints

Your LSP client will receive inlayHintProvider: true in the server capabilities. Hints are rendered inline by the client automatically. The following hint types are supported:

  • Assignment hints — unannotated variable assignments, including self.attr in __init__
  • Return hints — unannotated def and async def functions, inferred from the first return statement
  • Raise hintsraise ExceptionType(...) statements
  • Parameter hints — positional argument names at call sites (keyword args are skipped as self-documenting)

Inlay hints respect type annotations already present in the source — annotated functions and variables are never hinted twice.

Call hierarchy

Your LSP client will receive callHierarchyProvider: true. Place the cursor on any function name and invoke "Show Call Hierarchy" to see incoming callers and outgoing callees. Supported servers: rust-analyzer, clangd, and any server that uses standard callHierarchy/* requests.

Type hierarchy

Your LSP client will receive typeHierarchyProvider: true. Place the cursor on any class name and invoke "Show Type Hierarchy" to explore supertypes and subtypes. Supported servers: rust-analyzer, clangd, and any server that uses standard typeHierarchy/* requests.

Document links

Your LSP client will receive documentLinkProvider: true. URLs in comments and strings become clickable links. Import statements are resolved to the corresponding source file in the system Python's Lib/ directory (when Python is installed and available on PATH). Modules without a .py source (C extensions, frozen modules, embedded-only .pyc) are silently skipped.

Document colors

Your LSP client will receive colorProvider: true. Inline color swatches are shown for: hex (#rgb, #rrggbb, #rrggbbaa), rgb()/rgba(), hsl()/hsla(), and CSS named colors.

🔍 How it works

Workspace symbols

pylsp does not define a pylsp_workspace_symbols hookspec, so this plugin uses a two-pronged approach:

  1. Capability injection (preferred) — at import time, monkey-patches PythonLSPServer.capabilities() to insert workspaceSymbolProvider: true and inlayHintProvider directly into the proper LSP capabilities dict. This makes the plugin work out-of-the-box with clients that require proper capabilities, such as Neovim and eglot.
  2. Experimental fallback — if the injection fails (e.g. pylsp changes its internal API), capabilities are announced via pylsp_experimental_capabilities instead. Clients that honour the experimental channel (CudaText, VSCode with pylsp, etc.) will still work.
  3. pylsp_dispatchers — registers a custom JSON-RPC handler for workspace/symbol that calls Jedi's project.complete_search() and filters results client-side by case-insensitive substring match.

Note: workspace/symbol returns module-level definitions (functions, classes, modules). Local variables inside functions are not indexed — this is standard LSP behaviour, consistent with pyright and other Python language servers.

Inlay hints

The plugin handles the textDocument/inlayHint request using a hybrid approach:

  1. Regex scan — fast pass over the source to locate def, assignment, raise, and call patterns.
  2. _literal_type fast-path — resolves common literals ("str", 42, True, [...], etc.) without calling Jedi.
  3. Jedi inference — for non-literal expressions, script.infer() and script.get_signatures() are used to resolve types.
  4. Signature fallback — for self.attr = param assignments, the enclosing def signature is inspected for type annotations or default values.

Call hierarchy

Handled via callHierarchy/prepare, callHierarchy/incomingCalls and callHierarchy/outgoingCalls dispatchers. Uses Jedi's script.goto() and script.get_references() to resolve callers and callees, building LSP-compliant CallHierarchyItem structures with correct range information.

Type hierarchy

Handled via typeHierarchy/prepare, typeHierarchy/supertypes and typeHierarchy/subtypes dispatchers. Uses Jedi's script.goto() and class MRO inspection to build the type tree, restricted to an allowlist of servers known to support the feature correctly (rust-analyzer, clangd, etc.).

Document links

Two-pass collection over the source:

  1. URL pass — regex scan for http:// and https:// URLs in comments, docstrings, and string literals.
  2. Import pass — AST parse to find all import and from ... import statements; resolves each module name to a .py file by querying the system Python's sys.prefix via a single cached subprocess call.

Modules without a .py source (C extensions, frozen modules, .pyc-only embedded builds) are silently skipped.

Document colors

Regex-based scan over the source for color literals: hex (#rgb, #rrggbb, #rrggbbaa), rgb()/rgba(), hsl()/hsla(), and the full set of CSS named colors. Each match is returned as an LSP ColorInformation with normalised [0.0, 1.0] RGBA components.

🧪 Tests

pip install -e ".[dev]"
pytest

🤝 Contributing

Issues and pull requests are welcome! Please open an issue before submitting a large change.

📚 References

👤 Author

Bruno Eduardo — github.com/Hanatarou

📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylsp_workspace_symbols-0.3.0.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylsp_workspace_symbols-0.3.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file pylsp_workspace_symbols-0.3.0.tar.gz.

File metadata

  • Download URL: pylsp_workspace_symbols-0.3.0.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pylsp_workspace_symbols-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cd38e4b406f3bb01ed3b215bccdcefa2bff06dea672029ac24be36441095eee4
MD5 102054e5b0c1024932e916e2d5fd4b35
BLAKE2b-256 42b022d477bfb1be3431e7e21973b8ec870d7cb3d699bf4ab117421d2fb1809a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylsp_workspace_symbols-0.3.0.tar.gz:

Publisher: publish.yml on Hanatarou/pylsp-workspace-symbols

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pylsp_workspace_symbols-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pylsp_workspace_symbols-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3733f2aca6001f3c0201428a9e0d36bd2a35938d4e9cd9c9bf04e09d0653464
MD5 47707617a7e66302aad1fac434fcde1c
BLAKE2b-256 d37dbcf8a82a0367ca8e0b270c4eab53445fc527409c058a09a320f4df533089

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylsp_workspace_symbols-0.3.0-py3-none-any.whl:

Publisher: publish.yml on Hanatarou/pylsp-workspace-symbols

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page