From 0112e1f77983141e1453bd37d124302f1c876c46 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 20 Jun 2025 15:07:25 +0200 Subject: fix: some `on_attach` callbacks may act on the wrong buffer #3916 Problem: If a server is attached to a non-current buffer by `vim.lsp.buf_attach_client`, then the Language Server-related commands may be created in the current (wrong) buffer. Solution: Always use the `bufnr` arg provided to `on_attach`. --- lsp/basedpyright.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lsp/basedpyright.lua') diff --git a/lsp/basedpyright.lua b/lsp/basedpyright.lua index 8872ea14..2ec59448 100644 --- a/lsp/basedpyright.lua +++ b/lsp/basedpyright.lua @@ -50,7 +50,7 @@ return { desc = 'Organize Imports', }) - vim.api.nvim_buf_create_user_command(0, 'LspPyrightSetPythonPath', set_python_path, { + vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightSetPythonPath', set_python_path, { desc = 'Reconfigure basedpyright with the provided python path', nargs = 1, complete = 'file', -- cgit v1.2.3-70-g09d2