Skip to content

Commit 52b3eea

Browse files
committed
fix(ruby_lsp): prevent duplicate clients on second buffer
Problem: When opening multiple Ruby buffers, a second LSP client is spawned instead of reusing the first client, even though they share the same root directory. Root cause: The reuse_client function sets cmd_cwd as a side effect during reuse checks. This means the first client is created without cmd_cwd set, causing the reuse check to fail for the second buffer. Solution: Use before_init to ensure cmd_cwd is set for every client. Remove the custom reuse_client function to use Neovim's default reuse logic (compare name + root_dir). Testing: Tested with Neovim 0.11.4 by opening 3 Ruby files. All buffers now correctly reuse the first client.
1 parent ac98db2 commit 52b3eea

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lsp/ruby_lsp.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ return {
2020
init_options = {
2121
formatter = 'auto',
2222
},
23-
reuse_client = function(client, config)
23+
before_init = function(_, config)
2424
config.cmd_cwd = config.root_dir
25-
return client.config.cmd_cwd == config.cmd_cwd
2625
end,
2726
}

0 commit comments

Comments
 (0)