From 386231e6b746206147fc62d0243f09904a0a2f1f Mon Sep 17 00:00:00 2001 From: Michele Sorcinelli Date: Sun, 31 Aug 2025 01:50:16 +0100 Subject: 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 --- lsp/basedpyright.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lsp/basedpyright.lua') 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', }) -- cgit v1.2.3-70-g09d2