Neovim中Ruby LSP无法执行重命名操作的问题求助
Ruby LSP 重命名报错:
Language Server couldn't provide rename result 问题详情
在LazyVim(自定义配置/默认发行版)中触发vim.lsp.buf.rename()(快捷键<leader>cr)时,持续报错Language Server couldn't provide rename result。其他语言(Java、Go)的LSP重命名功能正常,报错时LSP日志无新增内容。
环境信息
- Ruby版本:3.3.6
- Neovim版本:v0.11.0-dev
- Ruby LSP版本:0.22.1(通过Mason或gem安装结果一致)
:LspInfo输出
lspconfig: require("lspconfig.health").check() LSP configs active in this session (globally) ~ - Configured servers: lua_ls, ruby_lsp - OK Deprecated servers: (none) LSP configs active in this buffer (bufnr: 12) ~ - Language client log: ~/.local/state/nvim/lsp.log - Detected filetype: `ruby` - 1 client(s) attached to this buffer - Client: `ruby_lsp` (id: 1, bufnr: [5, 12]) root directory: ~/Exercism/ruby/port-palermo/.ruby-lsp/ filetypes: ruby, eruby cmd: ~/.rbenv/shims/ruby-lsp version: `0.22.1` executable: true autostart: true Docs for active configs: ~ - ruby_lsp docs: >markdown 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 group :development do gem "ruby-lsp", require: false end
排查尝试
已移除其他插件,仅保留LSP相关配置,问题依旧:
return { { "williamboman/mason.nvim", lazy = false, config = function() require("mason").setup() end, }, { "williamboman/mason-lspconfig.nvim", lazy = false, opts = { auto_install = true, }, }, { "neovim/nvim-lspconfig", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "hrsh7th/nvim-cmp", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", "j-hui/fidget.nvim", }, config = function() local capabilities = require("cmp_nvim_lsp").default_capabilities() local lspconfig = require("lspconfig") lspconfig.ruby_lsp.setup({ capabilities = capabilities, }) vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, {}) end, }, }
解决方案排查方向
- 确认项目结构与依赖:确保项目根目录存在Gemfile,且已将
ruby-lsp添加到development组;Ruby LSP对单文件(非项目内)的重命名支持有限,需在项目目录内操作。 - 显式启用重命名特性:在Ruby LSP配置中明确开启rename功能,避免默认配置未启用:
lspconfig.ruby_lsp.setup({ capabilities = capabilities, settings = { rubyLsp = { enabledFeatures = { "rename" } } } }) - 检查Neovim版本兼容性:当前使用的是Neovim开发版v0.11.0-dev,可能存在LSP客户端兼容性问题,建议切换到稳定版v0.10.x测试。
- 查看Ruby LSP终端日志:手动在终端执行
ruby-lsp,再启动Neovim连接,查看终端输出的详细日志,可能获取Neovim LSP日志中未记录的错误信息。 - 验证Ruby环境一致性:通过
:!which ruby和:!ruby -v确认Neovim使用的Ruby环境与安装ruby-lsp的rbenv环境完全一致。
内容的提问来源于stack exchange,提问作者NilVS
相关产品推荐
相关产品推荐

