示例#1
0
    def open(self, *args, **kwargs):
        log.info("Spawning ccls subprocess")

        # Create an instance of the language server
        proc = process.Subprocess([
            'ccls',
            '--init={"capabilities": {"foldingRangeProvider": false}, "index": {"onChange": true, "trackDependency":2}, "clang": {"resourceDir": "/home/CppLanguageServer/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/10.0.0"}}'
        ],
                                  stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE)

        # Create a writer that formats json messages with the correct LSP headers
        self.writer = streams.JsonRpcStreamWriter(proc.stdin)

        # Create a reader for consuming stdout of the language server. We need to
        # consume this in another thread
        def consume():
            # Start a tornado IOLoop for reading/writing to the process in this thread
            ioloop.IOLoop()
            reader = streams.JsonRpcStreamReader(proc.stdout)
            reader.listen(lambda msg: self.write_message(json.dumps(msg)))

        thread = threading.Thread(target=consume)
        thread.daemon = True
        thread.start()
示例#2
0
文件: main.py 项目: pipiliang/code.py
def echo_socket(ws):

    print('connect ...')

    pyls_process = subprocess.Popen(['pyls', '-v'],
                                    stdin=subprocess.PIPE,
                                    stdout=subprocess.PIPE)

    writer = streams.JsonRpcStreamWriter(pyls_process.stdin)

    def consume():
        reader = streams.JsonRpcStreamReader(pyls_process.stdout)
        reader.listen(lambda msg: ws.send(json.dumps(msg)))

    thread = threading.Thread(target=consume)
    thread.daemon = True
    thread.start()

    while not ws.closed:
        message = ws.receive()  # 接收到消息
        if message is not None:
            print("%s receive msg==> " % now, str(json.dumps(message)))
            writer.write(json.loads(message))
        else:
            print(now, "no receive")
示例#3
0
    def open(self, *args, **kwargs):
        proc = process.Subprocess(
            [
                'pyls', '-v'
            ],  # 具体的LSP实现进程,如 'pyls -v'、'ccls --init={"index": {"onChange": true}}'等
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE)
        self.writer = streams.JsonRpcStreamWriter(proc.stdin)

        def consume():
            ioloop.IOLoop()
            reader = streams.JsonRpcStreamReader(proc.stdout)
            reader.listen(lambda msg: self.write_message(json.dumps(msg)))

        thread = threading.Thread(target=consume)
        thread.daemon = True
        thread.start()
示例#4
0
    def open(self, *args, **kwargs):
        log.info("Spawning pyls subprocess")

        # Create an instance of the language server
        proc = process.Subprocess(['pyls', '-v'],
                                  stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE)

        # Create a writer that formats json messages with the correct LSP headers
        self.writer = streams.JsonRpcStreamWriter(proc.stdin)

        # Create a reader for consuming stdout of the language server. We need to
        # consume this in another thread
        def consume():
            # Start a tornado IOLoop for reading/writing to the process in this thread
            ioloop.IOLoop()
            reader = streams.JsonRpcStreamReader(proc.stdout)
            reader.listen(lambda msg: self.write_message(json.dumps(msg)))

        thread = threading.Thread(target=consume)
        thread.daemon = True
        thread.start()
示例#5
0
 def start(self, rx, tx):
     """Entry point for the server."""
     self._jsonrpc_stream_reader = streams.JsonRpcStreamReader(rx)
     self._jsonrpc_stream_writer = streams.JsonRpcStreamWriter(tx)
     self.set_endpoint(self._jsonrpc_stream_writer.write)
     self._jsonrpc_stream_reader.listen(self.endpoint.consume)
示例#6
0
 def __init__(self, ifile, ofile):
     super(StdIOServer, self).__init__()
     self._istream = streams.JsonRpcStreamReader(ifile)
     self._ostream = streams.JsonRpcStreamWriter(ofile)
     self.endpoint = endpoint.Endpoint(self, self._ostream.write)