NilVS
NilVS

Reputation: 271

Unable to use rename in neovim with ruby lsp

I have tried this with a custom configuration and with the default LazyVim distribution. When I trigger vim.lsp.buf.rename(), for example in LazyVim with <leader>cr I get a error message stating Language Server couldn't provide rename result.

I am running ruby 3.3.6, neovim v0.11.0-dev and ruby-lsp 0.22.1 installed with Mason.

I have tried installing the lsp as a gem and I have the same result. The lsp logs print nothing new when this error is printed. I am able to use rename in other languages like java or go, so I think it has to be an issue with the lsp and not the configuration, but I am not sure what to try next.

This is what I get when I run :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
  
  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
  group :development do
    gem "ruby-lsp", require: false
  end

I am new to ruby, btw.

PS: I tried removing all other plugins and leave only the LSP stuff with the following config:

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,
    },
}

I get the same result

Upvotes: 1

Views: 252

Answers (1)

Lewis
Lewis

Reputation: 455

There might be some compatibility issues or edge cases that the Ruby LSP server hasn't fully addressed.
Test with a an older, more stable, Ruby version and see if the rename functionality works correctly. This can help isolate whether the issue is specific to your Ruby version.

I recommend you to install a Ruby version manager, If you haven't already, to easily switch between Ruby versions.
You can try these:
rbenv
RVM

Upvotes: 1

Related Questions