Skip to content

Commit 1ec99a0

Browse files
committed
fix(pyright): pyright.organizeimports command fails
Language server `pyright` does not support command `pyright.organizeimports`. This command may require a client extension.
1 parent f47cd68 commit 1ec99a0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lsp/basedpyright.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ return {
4242
},
4343
on_attach = function(client, bufnr)
4444
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
45-
client:exec_cmd({
45+
local params = {
4646
command = 'basedpyright.organizeimports',
4747
arguments = { vim.uri_from_bufnr(bufnr) },
48-
})
48+
}
49+
50+
client.request('workspace/executeCommand', params, nil, bufnr)
4951
end, {
5052
desc = 'Organize Imports',
5153
})

lsp/pyright.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ return {
4242
},
4343
on_attach = function(client, bufnr)
4444
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
45-
client:exec_cmd({
45+
local params = {
4646
command = 'pyright.organizeimports',
4747
arguments = { vim.uri_from_bufnr(bufnr) },
48-
})
48+
}
49+
50+
client.request('workspace/executeCommand', params, nil, bufnr)
4951
end, {
5052
desc = 'Organize Imports',
5153
})

0 commit comments

Comments
 (0)