Skip to content

feat: set default config for pylsp.#770

Merged
ayamir merged 5 commits intomainfrom
feat/config-for-pylsp
May 30, 2023
Merged

feat: set default config for pylsp.#770
ayamir merged 5 commits intomainfrom
feat/config-for-pylsp

Conversation

@ayamir
Copy link
Owner

@ayamir ayamir commented May 26, 2023

I set the default config for pylsp and solved the problem in #767 by enable ruff to do lint.

Main config:

  1. Use python-lsp-ruff to provide lint function due to its high performance.
  2. Use pylsp-rope to provide code refactor function in code action's way as mentioned in Should we change default python lsp from `pyright` to `pylsp`? #708 (reply in thread).
  3. Use python-lsp-black to provide format function.
  4. Remove black config in null-ls.
  5. Users no need to install or update these plugins manually after pylsp installed or updated.

The result:
image

@ayamir ayamir changed the title Feat/config for pylsp feat: set default config for pylsp. May 26, 2023
@ayamir
Copy link
Owner Author

ayamir commented May 26, 2023

@fecet @CharlesChiuGit

@ayamir ayamir marked this pull request as ready for review May 26, 2023 18:03
@ayamir ayamir linked an issue May 26, 2023 that may be closed by this pull request
2 tasks
@fecet
Copy link
Contributor

fecet commented May 26, 2023

I just started learning about Python's linter and formatter today, so I may not be able to provide any assistance beyond testing.
What could be the reasons for neodim not supporting it? Ruff support both format and lint. How about using ruff provided by ruff-lsp or null-ls? I've seen https://github.com/CharlesChiuGit/nvimdots.lua/blob/df6576052e3d72f8a76e59457c0101203c634d42/lua/core/settings.lua#L109
configure it that way, if I understand correctly.

Edit: I just realized ruff format in null-ls is simply call ruff with --fix option, so we still need black.

@ayamir
Copy link
Owner Author

ayamir commented May 27, 2023

I tend to use ruff as plugin of pylsp because the dependency is linear.

@ayamir ayamir requested a review from charliie-dev May 27, 2023 06:56
@fecet
Copy link
Contributor

fecet commented May 27, 2023

I have tried this PR and everything works fine! Except I notice two things:

  • python-lsp-ruff lint seems too strict, sources like "import but unused" or "line too long" would be considered as "Error".
  • ruff's code action "Ruff organize import" will randomly move character:
    image
    (note position of first "i" and "l" in the last line)
    Of course all of them are upstream issues.

@ayamir
Copy link
Owner Author

ayamir commented May 27, 2023

  1. I added F401 and E501 to ignore.
  2. Disable isort because ruff can do the same thing.

@fecet
Copy link
Contributor

fecet commented May 28, 2023

I think it's better not to include any ignore as default, if anyone found this was annoyed, they could add that in ther pyproject.toml or set diagnostics_virtual_text as false (I did this). As there is hope for this issue to be resolved quickly per python-lsp/python-lsp-ruff#36

@ayamir
Copy link
Owner Author

ayamir commented May 28, 2023

OK,we can wait for this.

@charliie-dev
Copy link
Collaborator

Agree with @fecet , we can just comment out the ignore table.

@ayamir ayamir merged commit 22f5083 into main May 30, 2023
@ayamir ayamir deleted the feat/config-for-pylsp branch May 30, 2023 02:45
leavers pushed a commit to leavers/nvimdots that referenced this pull request May 31, 2023
* feat: add default config for pylsp.

Signed-off-by: ayamir <lgt986452565@gmail.com>

* clean old config of black in null-ls.

* feat: install pylsp plugins automatically.

* perf: remove isort for pylsp, add E501 and F401 to ignore.

* perf: remove E501 and F401 from ignore list.

---------

Signed-off-by: ayamir <lgt986452565@gmail.com>
ostarJoy pushed a commit to ostarJoy/nvimdots that referenced this pull request Jun 4, 2023
* feat: add default config for pylsp.

Signed-off-by: ayamir <lgt986452565@gmail.com>

* clean old config of black in null-ls.

* feat: install pylsp plugins automatically.

* perf: remove isort for pylsp, add E501 and F401 to ignore.

* perf: remove E501 and F401 from ignore list.

---------

Signed-off-by: ayamir <lgt986452565@gmail.com>
bleedingfight pushed a commit to bleedingfight/nvimdots that referenced this pull request Jun 22, 2023
* feat: add default config for pylsp.

Signed-off-by: ayamir <lgt986452565@gmail.com>

* clean old config of black in null-ls.

* feat: install pylsp plugins automatically.

* perf: remove isort for pylsp, add E501 and F401 to ignore.

* perf: remove E501 and F401 from ignore list.

---------

Signed-off-by: ayamir <lgt986452565@gmail.com>
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.

Neodim not work for pylsp

3 participants