|
4 | 4 | import argparse |
5 | 5 | import logging |
6 | 6 | import logging.config |
7 | | -import sys |
8 | 7 | import time |
9 | 8 |
|
10 | 9 | try: |
11 | 10 | import ujson as json |
12 | 11 | except Exception: |
13 | 12 | import json |
14 | 13 |
|
15 | | -from ._version import __version__ |
16 | | -from .python_lsp import ( |
17 | | - PythonLSPServer, |
18 | | - start_io_lang_server, |
19 | | - start_tcp_lang_server, |
20 | | - start_ws_lang_server, |
21 | | -) |
| 14 | +from pylsp import __version__ |
| 15 | +from pylsp.server import LSP_SERVER |
22 | 16 |
|
23 | 17 | LOG_FORMAT = "%(asctime)s {} - %(levelname)s - %(name)s - %(message)s".format( |
24 | 18 | time.localtime().tm_zone |
@@ -73,25 +67,18 @@ def main() -> None: |
73 | 67 | args = parser.parse_args() |
74 | 68 | _configure_logger(args.verbose, args.log_config, args.log_file) |
75 | 69 |
|
| 70 | + if args.check_parent_process: |
| 71 | + LSP_SERVER.check_parent_process() |
| 72 | + |
76 | 73 | if args.tcp: |
77 | | - start_tcp_lang_server( |
78 | | - args.host, args.port, args.check_parent_process, PythonLSPServer |
79 | | - ) |
| 74 | + LSP_SERVER.start_tcp(args.host, args.port) |
80 | 75 | elif args.ws: |
81 | | - start_ws_lang_server(args.port, args.check_parent_process, PythonLSPServer) |
| 76 | + LSP_SERVER.start_ws( |
| 77 | + args.host, |
| 78 | + args.port, |
| 79 | + ) |
82 | 80 | else: |
83 | | - stdin, stdout = _binary_stdio() |
84 | | - start_io_lang_server(stdin, stdout, args.check_parent_process, PythonLSPServer) |
85 | | - |
86 | | - |
87 | | -def _binary_stdio(): |
88 | | - """Construct binary stdio streams (not text mode). |
89 | | -
|
90 | | - This seems to be different for Window/Unix Python2/3, so going by: |
91 | | - https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin |
92 | | - """ |
93 | | - stdin, stdout = sys.stdin.buffer, sys.stdout.buffer |
94 | | - return stdin, stdout |
| 81 | + LSP_SERVER.start_io() |
95 | 82 |
|
96 | 83 |
|
97 | 84 | def _configure_logger(verbose=0, log_config=None, log_file=None) -> None: |
|
0 commit comments