Skip to content

Commit feb4954

Browse files
committed
allow passing lsp initialization params
1 parent 98442e1 commit feb4954

4 files changed

Lines changed: 54 additions & 10 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"tests"
55
],
66
"python.testing.unittestEnabled": false,
7-
"python.testing.pytestEnabled": true
7+
"python.testing.pytestEnabled": true,
8+
"makefile.configureOnOpen": false
89
}

lsp_types/session.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ async def create(
5050
base_path: Path = Path("."),
5151
initial_code: str = "",
5252
options: t.Mapping = {},
53+
initialize_params: types.InitializeParams | None = None,
5354
pool: LSPProcessPool | None = None,
5455
) -> t.Self:
5556
"""Create a new LSP session using the provided backend"""
@@ -65,14 +66,19 @@ async def create_lsp_process():
6566
await lsp_process.start()
6667

6768
# Initialize LSP connection
68-
await lsp_process.send.initialize(
69-
{
70-
"processId": None,
71-
"rootUri": f"file://{base_path}",
72-
"rootPath": base_path_str,
73-
"capabilities": backend.get_lsp_capabilities(),
74-
}
75-
)
69+
resolved_initialize_params: types.InitializeParams = {
70+
"processId": None,
71+
"rootUri": f"file://{base_path}",
72+
"rootPath": base_path_str,
73+
"capabilities": backend.get_lsp_capabilities(),
74+
}
75+
76+
if initialize_params is not None:
77+
resolved_initialize_params = (
78+
resolved_initialize_params | initialize_params
79+
)
80+
81+
await lsp_process.send.initialize(resolved_initialize_params)
7682

7783
# Send initialized notification (required by LSP spec)
7884
await lsp_process.notify.initialized({})

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dev = [
4646
"pytest-asyncio>=0.25.3",
4747
"datamodel-code-generator>=0.27.2",
4848
"httpx>=0.28.1",
49+
"rich>=14.2.0",
4950
]
5051

5152
[tool.hatch.build.targets.sdist]

uv.lock

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)