multilspy icon indicating copy to clipboard operation
multilspy copied to clipboard

Stuck trying to launch pyright language server

Open maths-lover opened this issue 1 year ago • 7 comments

I do a simple copy of jedi-language-server, replace jedi calls to pyright, everything seems to work except the request goes to stdin (not sure if they actually do) but no response comes back.

A demo can be seen in the following asciicast

Please provide me insight if I'm doing something wrong here.

Thank you!

maths-lover avatar Oct 21 '24 15:10 maths-lover

Ah, and I forgot to mention that with jedi it worked fine without any issue.

maths-lover avatar Oct 21 '24 17:10 maths-lover

#10 I think this solves your problem 💪

DanCip00 avatar Oct 23 '24 21:10 DanCip00

@DanCip00 I don't see much difference, it still gets stuck for me when I try to make some request to the lsp server.

I did notice the following,

                if self.language_id != "python":
                    await self.completions_available.wait()

But while I was debugging it never got stuck there, it gets stuck when I make a "request/defintion" and such.

For one use case (it happens in possibly all other) I've pinpointed to the following position,

        with self.open_file(relative_file_path):
            # sending request to the language server and waiting for response
            response = await self.server.send.definition(
                {
                    LSPConstants.TEXT_DOCUMENT: {
                        LSPConstants.URI: pathlib.Path(
                            str(PurePath(self.repository_root_path, relative_file_path))
                        ).as_uri()
                    },
                    LSPConstants.POSITION: {
                        LSPConstants.LINE: line,
                        LSPConstants.CHARACTER: column,
                    },
                }
            )
            print("Stuck here?")

that print("Stuck here") which I added, was never called in

    async def request_definition(
        self, relative_file_path: str, line: int, column: int
    ) -> List[multilspy_types.Location]:

method in language_server.py

maths-lover avatar Nov 04 '24 12:11 maths-lover

For some reason, the asyncio.Condition() doesn't get released.

maths-lover avatar Nov 04 '24 14:11 maths-lover

Hi @maths-lover and @DanCip00,

I apologize for getting back so late on this. @maths-lover could you please confirm if @DanCip00's fix works now? If yes, could you please contribute a unittest for your specific situation, and I will merge both the unittest and solution PRs?

LakshyAAAgrawal avatar Dec 12 '24 22:12 LakshyAAAgrawal

I don't think @DanCip00's fix resolved the issue. Pyright is still hanging after initialization.

cotttho avatar Mar 11 '25 20:03 cotttho

The problem is with the initialization sequence. Pyright expects expects a more advanced handshake with the client to initialize properly.

cotttho avatar Mar 12 '25 18:03 cotttho