Skip to content

Conversation

michelesr
Copy link
Contributor

@michelesr michelesr commented Jul 24, 2025

Problem:

The pyright.organizeimports is private, so client:exec_cmd()
fails because it refuses to run commands that are not advertised
as capabilities.

Solution:

Call client.request() to side-step the check in client:exec_cmd().
YOLO

@michelesr michelesr force-pushed the master branch 3 times, most recently from 10b9dbc to 1ec99a0 Compare July 24, 2025 00:43
@justinmk
Copy link
Member

justinmk commented Aug 30, 2025

Ok, I did not realize that exec_cmd() is actively doing a check: https://github.com/neovim/neovim/blob/c333d64663d3b6e0dd9aa440e433d346af4a3d81/runtime/lua/vim/lsp/client.lua#L1024-L1027

and that fails because "basedpyright.organizeimports" is a private command (not advertised via capabilities).

Whereas client.request() just doesn't do that check.

So, we can merge this after:

  • add a comment above client.request() with the above information
  • rebase

@michelesr
Copy link
Contributor Author

@justinmk what about the failing linting checks, is there a way to disable them for the relevant LoC?

lint.sh: Use client:exec_cmd() instead of calling request("workspace/executeCommand") directly. Example: lsp/pyright.lua

@justinmk
Copy link
Member

To pass the lint you can change this line

local exclude='eslint'

to:

local exclude='eslint\|pyright\|basedpyright'

i'll think about how to make it more granular later.

@michelesr
Copy link
Contributor Author

michelesr commented Aug 30, 2025

@justinmk rebased and added the lint exclusion.

P.S: added the comments.

Language server `pyright` does not support command `pyright.organizeimports`.
This command may require a client extension.
@justinmk justinmk changed the title fix(pyright): pyright.organizeimports command fails fix(pyright): command :LspPyrightOrganizeImports fails Aug 31, 2025
@justinmk justinmk merged commit 386231e into neovim:master Aug 31, 2025
5 of 6 checks passed
@justinmk
Copy link
Member

justinmk commented Aug 31, 2025

Thanks for your help. I updated the description to be 100% clear, please consider that next time.

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.

2 participants