nvim-lspconfig/lsp/ruby_lsp.lua
Rich Grundy 903045b001
fix(ruby_lsp): set cmd_cwd to root_dir #4099
Problem: When running from a directory other than root (i.e monorepo),
ruby-lsp does not load correctly. Unsure why, previous lspconfig had
cmd_cwd set to the same as root_dir.

Solution:
Set the cmd_cwd via reuse_client(), similar to ast_grep. See #3850, #4082 for more details.
Tested both from root_dir and monorepo multi-root project.
2025-09-25 13:29:51 -07:00

28 lines
665 B
Lua

---@brief
---
--- https://shopify.github.io/ruby-lsp/
---
--- This gem is an implementation of the language server protocol specification for
--- Ruby, used to improve editor features.
---
--- Install the gem. There's no need to require it, since the server is used as a
--- standalone executable.
---
--- ```sh
--- gem install ruby-lsp
--- ```
---@type vim.lsp.Config
return {
cmd = { 'ruby-lsp' },
filetypes = { 'ruby', 'eruby' },
root_markers = { 'Gemfile', '.git' },
init_options = {
formatter = 'auto',
},
reuse_client = function(client, config)
config.cmd_cwd = config.root_dir
return client.config.cmd_cwd == config.cmd_cwd
end,
}