Skip to content

Commit ee1f195

Browse files
committed
doc: update README
1 parent 95c6d1c commit ee1f195

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ uv add lsp-client
3030
from pathlib import Path
3131
import anyio
3232
from lsp_client import Position
33-
from lsp_client.clients.pyright import PyrightClient
33+
from lsp_client.clients.pyright import PyrightClient, PyrightLocalServer
3434

3535
async def main():
36-
# Use current directory as workspace
37-
async with PyrightClient(workspace=Path.cwd()) as client:
36+
workspace = Path.cwd()
37+
async with PyrightClient(
38+
workspace=workspace,
39+
server=PyrightLocalServer(),
40+
) as client:
3841
# Find definition of something at line 11, character 28 in a file
3942
refs = await client.request_definition_locations(
4043
file_path="src/main.py",
@@ -46,7 +49,7 @@ async def main():
4649
return
4750

4851
for ref in refs:
49-
print(f"Found definition at: {ref.uri}")
52+
print(f"Found definition at: {ref.uri} - Range: {ref.range}")
5053

5154
if __name__ == "__main__":
5255
anyio.run(main)
@@ -57,15 +60,14 @@ if __name__ == "__main__":
5760
```python
5861
from pathlib import Path
5962
import anyio
60-
from lsp_client.clients.pyright import PyrightClient, PyrightServer, PyrightDockerRuntime
63+
from lsp_client import Position
64+
from lsp_client.clients.pyright import PyrightClient, PyrightDockerServer
6165

6266
async def main():
6367
workspace = Path.cwd()
6468
async with PyrightClient(
6569
workspace=workspace,
66-
server=PyrightServer(
67-
runtime=PyrightDockerRuntime(mounts=[workspace]),
68-
),
70+
server=PyrightDockerServer(mounts=[workspace]),
6971
) as client:
7072
# Find definition of something at line 11, character 28 in a file
7173
refs = await client.request_definition_locations(
@@ -78,7 +80,7 @@ async def main():
7880
return
7981

8082
for ref in refs:
81-
print(f"Found definition at: {ref.uri}")
83+
print(f"Found definition at: {ref.uri} - Range: {ref.range}")
8284

8385
if __name__ == "__main__":
8486
anyio.run(main)

0 commit comments

Comments
 (0)