aboutsummaryrefslogtreecommitdiffstats
path: root/lsp
diff options
context:
space:
mode:
authorMichele Sorcinelli <michelesr@users.noreply.github.com>2025-08-31 01:50:16 +0100
committerGitHub <noreply@github.com>2025-08-30 17:50:16 -0700
commit386231e6b746206147fc62d0243f09904a0a2f1f (patch)
treed5ea308c3231eadadcc9e8409e654241e9180d6c /lsp
parentdocs: update configs.md (diff)
downloadnvim-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')
-rw-r--r--lsp/basedpyright.lua9
-rw-r--r--lsp/pyright.lua9
2 files changed, 14 insertions, 4 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',
})
diff --git a/lsp/pyright.lua b/lsp/pyright.lua
index 2df4a173..1a966304 100644
--- a/lsp/pyright.lua
+++ b/lsp/pyright.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 = 'pyright.organizeimports',
arguments = { vim.uri_from_bufnr(bufnr) },
- })
+ }
+
+ -- Using client.request() directly because "pyright.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',
})