microsoft / multilspy

multispy is a lsp client library in Python intended to be used to build applications around language servers.
https://www.microsoft.com/en-us/research/publication/guiding-language-models-of-code-with-global-context-using-monitors/
MIT License
52 stars 16 forks source link

Stuck trying to launch pyright language server #9

Open maths-lover opened 2 weeks ago

maths-lover commented 2 weeks ago

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 commented 2 weeks ago

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

DanCip00 commented 2 weeks ago

10 I think this solves your problem 💪

maths-lover commented 3 days ago

@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 commented 3 days ago

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