diff options
| author | Michele Sorcinelli <michelesr@users.noreply.github.com> | 2025-08-31 01:50:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-30 17:50:16 -0700 |
| commit | 386231e6b746206147fc62d0243f09904a0a2f1f (patch) | |
| tree | d5ea308c3231eadadcc9e8409e654241e9180d6c /lsp/basedpyright.lua | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-386231e6b746206147fc62d0243f09904a0a2f1f.tar nvim-lspconfig-386231e6b746206147fc62d0243f09904a0a2f1f.tar.gz nvim-lspconfig-386231e6b746206147fc62d0243f09904a0a2f1f.tar.bz2 nvim-lspconfig-386231e6b746206147fc62d0243f09904a0a2f1f.tar.lz nvim-lspconfig-386231e6b746206147fc62d0243f09904a0a2f1f.tar.xz nvim-lspconfig-386231e6b746206147fc62d0243f09904a0a2f1f.tar.zst nvim-lspconfig-386231e6b746206147fc62d0243f09904a0a2f1f.zip | |
fix(pyright): command :LspPyrightOrganizeImports fails #3971
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
Diffstat (limited to 'lsp/basedpyright.lua')
| -rw-r--r-- | lsp/basedpyright.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lsp/basedpyright.lua b/lsp/basedpyright.lua index ad3b03b7..e468b94d 100644 --- a/lsp/basedpyright.lua +++ b/lsp/basedpyright.lua @@ -43,10 +43,15 @@ return { }, on_attach = function(client, bufnr) vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function() - client:exec_cmd({ + local params = { command = 'basedpyright.organizeimports', arguments = { vim.uri_from_bufnr(bufnr) }, - }) + } + + -- Using client.request() directly because "basedpyright.organizeimports" is private + -- (not advertised via capabilities), which client:exec_cmd() refuses to call. + -- https://github.com/neovim/neovim/blob/c333d64663d3b6e0dd9aa440e433d346af4a3d81/runtime/lua/vim/lsp/client.lua#L1024-L1030 + client.request('workspace/executeCommand', params, nil, bufnr) end, { desc = 'Organize Imports', }) |
