doctorfree / nvim-lazyman

Neovim configuration manager and Lazy/Lua/Mason based Neovim config. Manage multiple Neovim configurations with the lazyman command. ☕
https://lazyman.dev
MIT License
263 stars 8 forks source link

How to enable pyright? #56

Open wxguy opened 8 months ago

wxguy commented 8 months ago

I am finding increasingly difficult with pylsp which does not work if the module imports dynamically. While reading about this issue, I could feel that pyright would be better choice than for Python completion. In addition, when I looked at pylsp release stats, it was released around 2020 which I feel is very old.

I feel that you should consider including pyright for python LSP rather than pylsp for lazyman default config. Or you can have an option in configuration section to choose pylsp or pyright which would be best.

Meanwhile, is there a way to enable pyright for auto-completion instead of pylsp manually?

doctorfree commented 8 months ago

@wxguy thanks for bringing this to my attention. I am not a pyright user but maybe I should be. I will look into it.

Currently you can enable pyright and disable pylsp in Lazyman using the LSP menu (lazyman -F lsp). You may need to install the Python pyright module (e.g. pip install pyright) or the command line version (npm install -g pyright).

My understanding of the issue with following module imports was the opposite, pylsp did and pyright did not. But, that may be old news and I have not kept up with that issue. Anyway, this is an area I should improve. If you try out any of the above, let me know how it goes and how to improve the default config and ability to make this easily configurable.

wxguy commented 8 months ago

Thanks for your clarification. I did enable and checked for autocompletion as per your suggestions. Here is what my observations.

Configuration Issue

When I enabled pyright in LSP configuration windows using lazyman -F lsp command, it should have disabled pylsp (at least an idicator in config window). However, this is what I got after I enabled pyright, even after rebooting nvim:

pylsp-enable-fail

Multiple Lint Suggestions

When I only enabled pylsp, I got lint suggestions from both ruff and pyright. You can see the screenshot below.

pylsp-multi-debug

No Autocompletion for Pyright

After enabling pyrignt from lazyman config window, I did not get any autocompletion. Here is the screenshot:

pyright-no-completion

Too Many Warnings

This one I have noticed whenever I open a Python script. Many warnings I could see in the notification. This does not happen if I open any other file type.

Screenshot from 2023-12-17 20-39-34

I could have posted the actual warning but I not aware where the warning file is located.

I am sure you can look into these issues.

doctorfree commented 8 months ago

@wxguy thanks for testing and reporting issues. It really helps.

I've added a switch in the Lazyman LSP config menu to disable pyright if pylsp is enabled and vice versa. I also believe I've fixed the warnings your are seeing. However, I am unable to reproduce the issue with autocompletion or the issue with duplicate diagnostics. I will continue to look into this.

You may wish to update your Lazyman installation with lazyman -U to see if these recent fixes address some of your issues. I would recommend backing up your current configuration before updating. For example:

cp -a ~/.config/nvim-Lazyman ~/.config/nvim-Lazyman.bak
lazyman -U
wxguy commented 8 months ago

@wxguy thanks for testing and reporting issues. It really helps.

I've added a switch in the Lazyman LSP config menu to disable pyright if pylsp is enabled and vice versa. I also believe I've fixed the warnings your are seeing. However, I am unable to reproduce the issue with autocompletion or the issue with duplicate diagnostics. I will continue to look into this.

You may wish to update your Lazyman installation with lazyman -U to see if these recent fixes address some of your issues. I would recommend backing up your current configuration before updating. For example:

cp -a ~/.config/nvim-Lazyman ~/.config/nvim-Lazyman.bak
lazyman -U

Still the issue appears to exisit. I did a clean install by executing following commands:-

lazyman -R -N Lazyman
git clone https://github.com/doctorfree/nvim-lazyman $HOME/.config/nvim-Lazyman
$HOME/.config/nvim-Lazyman/lazyman.sh

Thereafter enabled only pyright from lsp config window. Howwver, it didi not disable pylsp. Screen shot is attached below:-

Screenshot from 2023-12-26 10-16-22

When I opened a simple python script, this is what I get:

Screenshot from 2023-12-26 10-22-59

There is a clear-cut repetition of diagnosis from pyright and pylsp.

Hope it helps you in debugging the issue.

doctorfree commented 8 months ago

Thanks for the additional details. I am now able to reproduce this problem. Hopefully I will be able to publish a fix this week.