Skip to content

Commit 43609c6

Browse files
committed
feat: Add extended capabilities to LSP clients
Add a broad set of capability mixins to Pyrefly, Pyright and Typescript clients (notifications, requests, server_requests and additional server_notification handlers). Use --stdio for PyrightLocalServer and add explicit typing for initialization options.
1 parent 3824175 commit 43609c6

File tree

3 files changed

+101
-9
lines changed

3 files changed

+101
-9
lines changed

src/lsp_client/clients/pyrefly.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,32 @@
99
from attrs import define
1010
from loguru import logger
1111

12-
from lsp_client.capability.request import WithRequestDefinition, WithRequestReferences
13-
from lsp_client.capability.server_notification import WithReceiveLogMessage
12+
from lsp_client.capability.notification import (
13+
WithNotifyDidChangeConfiguration,
14+
)
15+
from lsp_client.capability.request import (
16+
WithRequestCallHierarchy,
17+
WithRequestDeclaration,
18+
WithRequestDefinition,
19+
WithRequestDocumentSymbol,
20+
WithRequestHover,
21+
WithRequestImplementation,
22+
WithRequestReferences,
23+
WithRequestTypeDefinition,
24+
WithRequestWorkspaceSymbol,
25+
)
26+
from lsp_client.capability.server_notification import (
27+
WithReceiveLogMessage,
28+
WithReceiveLogTrace,
29+
WithReceivePublishDiagnostics,
30+
WithReceiveShowMessage,
31+
)
32+
from lsp_client.capability.server_request import (
33+
WithRespondConfigurationRequest,
34+
WithRespondShowDocumentRequest,
35+
WithRespondShowMessageRequest,
36+
WithRespondWorkspaceFoldersRequest,
37+
)
1438
from lsp_client.client.abc import LSPClient
1539
from lsp_client.server.local import LocalServer
1640
from lsp_client.utils.types import lsp_type
@@ -21,9 +45,24 @@
2145
@define
2246
class PyreflyClient(
2347
LSPClient,
24-
WithRequestReferences,
48+
WithNotifyDidChangeConfiguration,
49+
WithRequestCallHierarchy,
50+
WithRequestDeclaration,
2551
WithRequestDefinition,
52+
WithRequestDocumentSymbol,
53+
WithRequestHover,
54+
WithRequestImplementation,
55+
WithRequestReferences,
56+
WithRequestTypeDefinition,
57+
WithRequestWorkspaceSymbol,
2658
WithReceiveLogMessage,
59+
WithReceiveLogTrace,
60+
WithReceivePublishDiagnostics,
61+
WithReceiveShowMessage,
62+
WithRespondConfigurationRequest,
63+
WithRespondShowDocumentRequest,
64+
WithRespondShowMessageRequest,
65+
WithRespondWorkspaceFoldersRequest,
2766
):
2867
"""
2968
- Language: Python
@@ -45,7 +84,7 @@ def get_language_id(self) -> lsp_type.LanguageKind:
4584

4685
@override
4786
def create_initialization_options(self) -> dict[str, Any]:
48-
options = {}
87+
options: dict[str, Any] = {}
4988

5089
options["trace"] = {"server": self.trace_server}
5190
options["diagnostic_mode"] = self.diagnostic_mode

src/lsp_client/clients/pyright.py

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,37 @@
99
from attrs import define
1010
from loguru import logger
1111

12-
from lsp_client.capability.request import WithRequestDefinition, WithRequestReferences
13-
from lsp_client.capability.server_notification import WithReceivePublishDiagnostics
14-
from lsp_client.capability.server_notification.log_message import WithReceiveLogMessage
12+
from lsp_client.capability.notification import (
13+
WithNotifyDidChangeConfiguration,
14+
)
15+
from lsp_client.capability.request import (
16+
WithRequestCallHierarchy,
17+
WithRequestDeclaration,
18+
WithRequestDefinition,
19+
WithRequestDocumentSymbol,
20+
WithRequestHover,
21+
WithRequestReferences,
22+
WithRequestTypeDefinition,
23+
WithRequestWorkspaceSymbol,
24+
)
25+
from lsp_client.capability.server_notification import (
26+
WithReceiveLogMessage,
27+
WithReceiveLogTrace,
28+
WithReceivePublishDiagnostics,
29+
WithReceiveShowMessage,
30+
)
31+
from lsp_client.capability.server_request import (
32+
WithRespondConfigurationRequest,
33+
WithRespondShowDocumentRequest,
34+
WithRespondShowMessageRequest,
35+
WithRespondWorkspaceFoldersRequest,
36+
)
1537
from lsp_client.client.abc import LSPClient
1638
from lsp_client.server.docker import DockerServer
1739
from lsp_client.server.local import LocalServer
1840
from lsp_client.utils.types import lsp_type
1941

20-
PyrightLocalServer = partial(LocalServer, command=["pyright-langserver"])
42+
PyrightLocalServer = partial(LocalServer, command=["pyright-langserver", "--stdio"])
2143
PyrightDockerServer = partial(
2244
DockerServer, image="docker.io/lspcontainers/pyright-langserver"
2345
)
@@ -26,10 +48,23 @@
2648
@define
2749
class PyrightClient(
2850
LSPClient,
29-
WithRequestReferences,
51+
WithNotifyDidChangeConfiguration,
52+
WithRequestCallHierarchy,
53+
WithRequestDeclaration,
3054
WithRequestDefinition,
55+
WithRequestDocumentSymbol,
56+
WithRequestHover,
57+
WithRequestReferences,
58+
WithRequestTypeDefinition,
59+
WithRequestWorkspaceSymbol,
3160
WithReceiveLogMessage,
61+
WithReceiveLogTrace,
3262
WithReceivePublishDiagnostics,
63+
WithReceiveShowMessage,
64+
WithRespondConfigurationRequest,
65+
WithRespondShowDocumentRequest,
66+
WithRespondShowMessageRequest,
67+
WithRespondWorkspaceFoldersRequest,
3368
):
3469
"""
3570
- Language: Python

src/lsp_client/clients/typescript.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from attrs import define
1010
from loguru import logger
1111

12+
from lsp_client.capability.notification import (
13+
WithNotifyDidChangeConfiguration,
14+
)
1215
from lsp_client.capability.request import (
1316
WithRequestDefinition,
1417
WithRequestDocumentSymbol,
@@ -19,9 +22,17 @@
1922
WithRequestWorkspaceSymbol,
2023
)
2124
from lsp_client.capability.server_notification import (
25+
WithReceiveLogTrace,
2226
WithReceivePublishDiagnostics,
27+
WithReceiveShowMessage,
2328
)
2429
from lsp_client.capability.server_notification.log_message import WithReceiveLogMessage
30+
from lsp_client.capability.server_request import (
31+
WithRespondConfigurationRequest,
32+
WithRespondShowDocumentRequest,
33+
WithRespondShowMessageRequest,
34+
WithRespondWorkspaceFoldersRequest,
35+
)
2536
from lsp_client.client.abc import LSPClient
2637
from lsp_client.server.docker import DockerServer
2738
from lsp_client.server.local import LocalServer
@@ -36,6 +47,7 @@
3647
@define
3748
class TypescriptClient(
3849
LSPClient,
50+
WithNotifyDidChangeConfiguration,
3951
WithRequestHover,
4052
WithRequestDefinition,
4153
WithRequestReferences,
@@ -44,7 +56,13 @@ class TypescriptClient(
4456
WithRequestDocumentSymbol,
4557
WithRequestWorkspaceSymbol,
4658
WithReceiveLogMessage,
59+
WithReceiveLogTrace,
4760
WithReceivePublishDiagnostics,
61+
WithReceiveShowMessage,
62+
WithRespondConfigurationRequest,
63+
WithRespondShowDocumentRequest,
64+
WithRespondShowMessageRequest,
65+
WithRespondWorkspaceFoldersRequest,
4866
):
4967
"""
5068
- Language: TypeScript, JavaScript

0 commit comments

Comments
 (0)