Skip to content

Commit f62e5b5

Browse files
committed
feat: use pygls lsp server
1 parent 11628f2 commit f62e5b5

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

pylsp/__main__.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,15 @@
44
import argparse
55
import logging
66
import logging.config
7-
import sys
87
import time
98

109
try:
1110
import ujson as json
1211
except Exception:
1312
import json
1413

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
2216

2317
LOG_FORMAT = "%(asctime)s {} - %(levelname)s - %(name)s - %(message)s".format(
2418
time.localtime().tm_zone
@@ -73,25 +67,19 @@ def main() -> None:
7367
args = parser.parse_args()
7468
_configure_logger(args.verbose, args.log_config, args.log_file)
7569

70+
if args.check_parent_process:
71+
LSP_SERVER.check_parent_process()
72+
7673
if args.tcp:
77-
start_tcp_lang_server(
78-
args.host, args.port, args.check_parent_process, PythonLSPServer
74+
LSP_SERVER.start_tcp(
75+
args.host, args.port
7976
)
8077
elif args.ws:
81-
start_ws_lang_server(args.port, args.check_parent_process, PythonLSPServer)
78+
LSP_SERVER.start_ws(
79+
args.host, args.port,
80+
)
8281
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
82+
LSP_SERVER.start_io()
9583

9684

9785
def _configure_logger(verbose=0, log_config=None, log_file=None) -> None:

0 commit comments

Comments
 (0)