Conversation
✅ Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Add a test that checks that "tcp server mode" works. Server meaning that this plugin acts as the TCP server and the langserver connects as TCP client.
|
|
||
|
|
||
| async def main(tcp_port: int | None = None) -> bool: | ||
| async def main(tcp_port: int | None = None, mode: str | None = None) -> bool: |
There was a problem hiding this comment.
Can you set type for mode to Literal['client', 'server'] | None so that it self-documents allowed values?
| await server.serve_forever() | ||
| return callback.received_shutdown | ||
|
|
||
| if mode is not None and mode == "client": |
There was a problem hiding this comment.
| if mode is not None and mode == "client": | |
| if mode == "client": |
| parser = ArgumentParser(prog=__package__, description=__doc__) | ||
| parser.add_argument("-v", "--version", action="store_true", help="print version and exit") | ||
| parser.add_argument("-p", "--tcp-port", type=int) | ||
| parser.add_argument("--mode", help="one of 'client' or 'server'", default="server") |
There was a problem hiding this comment.
Can validate the argument early and then also doesn't really need a redundant help:
| parser.add_argument("--mode", help="one of 'client' or 'server'", default="server") | |
| parser.add_argument("--mode", help="one of 'client' or 'server'", default="server", choices=["client", "server"]) |
| config = ClientConfig( | ||
| name=name, | ||
| command=["python3", join("$packages", "LSP", "tests", "server.py")], | ||
| selector="text.plain", | ||
| enabled=True, | ||
| ) | ||
| config.initialization_options.assign(init_options) | ||
| return config |
There was a problem hiding this comment.
Why not pass init_options to the constructor and save lines?
| config = ClientConfig( | |
| name=name, | |
| command=["python3", join("$packages", "LSP", "tests", "server.py")], | |
| selector="text.plain", | |
| enabled=True, | |
| ) | |
| config.initialization_options.assign(init_options) | |
| return config | |
| return ClientConfig( | |
| name=name, | |
| command=["python3", join("$packages", "LSP", "tests", "server.py")], | |
| selector="text.plain", | |
| initialization_options=DottedDict(init_options), | |
| enabled=True, | |
| ) |
Same below.
| def make_stdio_test_config() -> ClientConfig: | ||
| return ClientConfig( | ||
| name="TEST", | ||
| def make_stdio_test_config(name: str, init_options: dict[str, Any]) -> ClientConfig: |
There was a problem hiding this comment.
Maybe make init_options optional since it's not always needed?
| def make_stdio_test_config(name: str, init_options: dict[str, Any]) -> ClientConfig: | |
| def make_stdio_test_config(name: str, init_options: dict[str, Any] | None = None) -> ClientConfig: |
| return ClientConfig( | ||
| name="TEST", | ||
| def make_stdio_test_config(name: str, init_options: dict[str, Any]) -> ClientConfig: | ||
| """Start the fake language server in STDIO mode.""" |
There was a problem hiding this comment.
Nitpicking but the function doesn't really start the server. It just creates a config for starting a server.
Add a test that checks that "tcp server mode" works. Server meaning that this plugin acts as the TCP server and the langserver connects as TCP client.