-
Notifications
You must be signed in to change notification settings - Fork 0
Add default configuration maps for LSP clients to enable extra features #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
observerw
merged 6 commits into
main
from
copilot/add-default-values-to-configuration-map
Dec 28, 2025
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
44782bd
Initial plan
Copilot 0308624
Add default configuration_map for all clients with extra features ena…
Copilot 9afd8aa
Add comprehensive tests and documentation for default configurations
Copilot 3bf000c
Address code review comments: add public API and improve documentation
Copilot cac1a54
Add example demonstrating default configuration usage
Copilot 661ad01
Add test coverage for TyClient and PyreflyClient, improve example doc…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| """ | ||
| Example demonstrating default configurations for LSP clients. | ||
|
|
||
| This example shows how the new default configurations work: | ||
| 1. All clients automatically have sensible defaults | ||
| 2. Inlay hints and other features are enabled out of the box | ||
| 3. Users can still override defaults if needed | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from lsp_client.clients.pyright import PyrightClient | ||
| from lsp_client.clients.rust_analyzer import RustAnalyzerClient | ||
| from lsp_client.utils.config import ConfigurationMap | ||
|
|
||
|
|
||
| def example_using_defaults(): | ||
| """Example: Using default configuration (no setup required)""" | ||
| print("Example 1: Using Default Configuration") | ||
| print("-" * 50) | ||
|
|
||
| # Create a client - it automatically has default configuration | ||
| client = PyrightClient() | ||
|
|
||
| # Get the default configuration that was created | ||
| config_map = client.create_default_configuration_map() | ||
|
|
||
| if config_map: | ||
| print("✓ Default configuration is available!") | ||
|
|
||
| # Check what inlay hints are enabled | ||
| inlay_hints = config_map.get(None, "python.analysis.inlayHints") | ||
| print(f" Inlay hints configuration: {inlay_hints}") | ||
|
|
||
| # Check type checking mode | ||
| type_checking = config_map.get(None, "python.analysis.typeCheckingMode") | ||
| print(f" Type checking mode: {type_checking}") | ||
|
|
||
| # Check auto-import completions | ||
| auto_imports = config_map.get(None, "python.analysis.autoImportCompletions") | ||
| print(f" Auto-import completions: {auto_imports}") | ||
|
|
||
| print() | ||
|
|
||
|
|
||
| def example_with_custom_override(): | ||
| """Example: Overriding default configuration""" | ||
| print("Example 2: Overriding Default Configuration") | ||
| print("-" * 50) | ||
|
|
||
| # Create a client | ||
| client = RustAnalyzerClient() | ||
|
|
||
| # Get defaults - demonstrating that defaults exist | ||
| _ = client.create_default_configuration_map() | ||
| print("✓ Default configuration created") | ||
|
|
||
| # Create custom configuration that overrides some defaults | ||
| custom_config = ConfigurationMap() | ||
| custom_config.update_global( | ||
| { | ||
| "rust-analyzer": { | ||
| "inlayHints": { | ||
| "enable": False, # Disable inlay hints | ||
| }, | ||
| "checkOnSave": {"enable": False}, # Disable check on save | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| print("✓ Custom configuration created") | ||
| print(" - Inlay hints: disabled") | ||
| print(" - Check on save: disabled") | ||
|
|
||
| # You would set this on the client: | ||
| # client.configuration_map = custom_config | ||
|
|
||
| print() | ||
|
|
||
|
|
||
| def example_inspecting_defaults(): | ||
| """Example: Inspecting default configurations for all clients""" | ||
| print("Example 3: Inspecting Default Configurations") | ||
| print("-" * 50) | ||
|
|
||
| from lsp_client.clients import clients | ||
|
|
||
| for client_cls in clients: | ||
| client = client_cls() | ||
| config_map = client.create_default_configuration_map() | ||
|
|
||
| if config_map and config_map.has_global_config(): | ||
| print(f"✓ {client_cls.__name__} has default configuration") | ||
|
|
||
| # Try to find inlay hints config | ||
| for section in [ | ||
| "rust-analyzer.inlayHints", | ||
| "gopls.hints", | ||
| "python.analysis.inlayHints", | ||
| "typescript.inlayHints", | ||
| "deno.inlayHints", | ||
| "pyrefly.inlayHints", | ||
| ]: | ||
| value = config_map.get(None, section) | ||
| if value is not None: | ||
| print(f" → {section} is configured") | ||
| break | ||
|
|
||
| print() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| print("LSP Client Default Configuration Examples") | ||
| print("=" * 50) | ||
| print() | ||
|
|
||
| example_using_defaults() | ||
| example_with_custom_override() | ||
| example_inspecting_defaults() | ||
|
|
||
| print("=" * 50) | ||
| print("All examples completed successfully!") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inlay hints section list in the example is missing "ty.inlayHints". However, upon checking the ty.py implementation, TyClient does not configure inlayHints - it only configures diagnostics and completion. While this is technically correct, it would be helpful to add a comment or include "ty.diagnostics" or "ty.completion" in the list to demonstrate that TyClient is also being checked, so it's clear to readers that all clients are covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added "ty.diagnostics" to the configuration list with a comment explaining that TyClient uses diagnostics instead of inlay hints. This makes it clear all clients are covered. (661ad01)