Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit da15990

Browse files
Copilotobserverw
andauthored
Enhance server start command with language support validation (#6)
* Initial plan * Add lsp server test command and tests Co-authored-by: observerw <20661574+observerw@users.noreply.github.com> * Fix linting issues in server test command Co-authored-by: observerw <20661574+observerw@users.noreply.github.com> * Address code review feedback - use BaseLSPTest and dynamic language list Co-authored-by: observerw <20661574+observerw@users.noreply.github.com> * Use pytest tmp_path fixture for cleaner test implementation Co-authored-by: observerw <20661574+observerw@users.noreply.github.com> * Merge test command features into server start command - Remove separate 'lsp server test' command - Enhance 'lsp server start' with better error messages - Add path existence check before attempting to start server - Show friendly error with supported languages list when language not supported - Remove tests for standalone test command Co-authored-by: observerw <20661574+observerw@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: observerw <20661574+observerw@users.noreply.github.com>
1 parent 8610f54 commit da15990

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/lsp_cli/server.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from pathlib import Path
22

33
import typer
4+
from lsp_client.clients.lang import lang_clients
45

6+
from lsp_cli.client import find_client
57
from lsp_cli.manager import (
68
CreateClientRequest,
79
CreateClientResponse,
@@ -56,6 +58,36 @@ def start_server(
5658
),
5759
):
5860
"""Start a background LSP server for the project containing the specified path."""
61+
# Check if the path exists
62+
if not path.exists():
63+
print(f"Error: Path does not exist: {path.absolute()}")
64+
raise typer.Exit(1)
65+
66+
# Try to find a language client for this path
67+
target = find_client(path)
68+
69+
if target is None:
70+
# No language support found - generate list of supported languages dynamically
71+
supported_langs = sorted(
72+
{
73+
client_cls.get_language_config().kind.value
74+
for client_cls in lang_clients.values()
75+
}
76+
)
77+
supported_langs_str = ", ".join(supported_langs)
78+
79+
print(f"Error: Language not supported for path: {path.absolute()}")
80+
print()
81+
print("The CLI cannot analyze code files in this language.")
82+
print(f"Supported languages: {supported_langs_str}")
83+
print()
84+
print("Please check:")
85+
print(" - The file extension matches a supported language")
86+
print(
87+
" - The project has the required language markers (e.g., go.mod, Cargo.toml)"
88+
)
89+
raise typer.Exit(1)
90+
5991
with get_manager_client() as client:
6092
resp = client.post(
6193
"/create", CreateClientResponse, json=CreateClientRequest(path=path)

0 commit comments

Comments
 (0)