Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - code completion with python servers #10

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

DanCip00
Copy link

@DanCip00 DanCip00 commented Oct 23, 2024

Removed extra await that blocks code completion for python Language Servers

Closes #9

Removed extra await that blocks code completion using Python Servers
@LakshyAAAgrawal
Copy link
Collaborator

Dear @DanCip00 ,

Thanks a lot for your PR! Have you been able to get pyright working with this change?

@DanCip00
Copy link
Author

Hi, I was trying to use your code to request completion in Python using Pyright and I ran into the same problem #10. Now it works fine for me. But now that I think about it maybe it's better to wrap the line around an if statement like this:

if self.language_id is not Language.PYTHON:
    await self.completions_available.wait()

@LakshyAAAgrawal
Copy link
Collaborator

LakshyAAAgrawal commented Oct 23, 2024

I would actually recommend creating a separate class for pyright, copying the full code for jedi, while modifying the following three lines: https://github.com/microsoft/multilspy/blob/main/src/multilspy/language_servers/jedi_language_server/jedi_server.py#L82C1-L84C49

These lines in the jedi client wait for jedi to report completions available, and sets the corresponding flag. Since it appears that this is not needed in pyright, you can directly make a call to this in start_server, before yielding.

Could you please make that change?

@LakshyAAAgrawal
Copy link
Collaborator

BTW, thanks a lot for this PR. I wasn't aware that this was the issue blocking pyright to work with multilspy. Thanks a lot for debugging this!

Please feel free to let me know iif I can help with anything on the PR.

@DanCip00
Copy link
Author

DanCip00 commented Oct 23, 2024

I am encountering the same issue of infinite waiting even when using jedi-language-server concerning the use of request_completions. I would like to ask you to verify if it works correctly for you :)

I am not an expert on the matter, but my hypothesis is that this call has not been implemented in the python-lsp-server library, on which the others are based. Is this possible?

venv/

fake_repo/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can you remove fake_repo/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a setup_runtime_dependencies function here, so that users who do not have basedpyright installed in their environment can load it seamlessly?

Please let me know if you would like any help with this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @DanCip00, Thanks a lot for the PR and I am sorry for getting back so late on this.

I believe the PR is in good shape. Would it be possible for you to just add the setup_runtime_dependencies for PyRight? If not, I could try to work on it and then immediately proceed with merging the PR.

src/multilspy/multilspy_config.py Show resolved Hide resolved
@LakshyAAAgrawal
Copy link
Collaborator

@DanCip00 can you please accept the CLA?

@DanCip00
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stuck trying to launch pyright language server
3 participants