Skip to content

ruby-lsp integration broken, can't use experimental/goToRelevantFile method #229

Closed

Description

@dagi3d

I use the method experimental/goToRelevantFile exposed in the ruby-lsp to alternate between the implementation and test files in ruby.
It has been working fine until I decided to start using Copilot in nvim. Now, when I try to navigate using this method, I get the following error:

RPC[ERROR] code_name= MethodNotFound, message = "Method not found: experimental/goToRelevantFile"

tried to call the command Copilot disable right before the lsp request, but it didn't help either.

Activity

  1. tpope commented on Oct 27, 2025

    @tpope
    Collaborator

    Using it how, exactly? You'll need to make sure to request that method from the correct language server.

  2. dagi3d commented on Oct 29, 2025

    @dagi3d
    Author

    Using it how, exactly? You'll need to make sure to request that method from the correct language server.

    Without copilot.vim it works fine (pardon my lua):

    local M = {}
    function M.lsp_go_to_relevant_file()
      local filetype = vim.bo.filetype
      if filetype ~= "ruby" then
        return
      end
    
      local uri = vim.uri_from_bufnr(0)
      local params = { textDocument = { uri = uri } }
    
      vim.lsp.buf_request_all(0, "experimental/goToRelevantFile", params, function(results)
        for _, result_or_error in pairs(results) do
          local error, result = result_or_error.error, result_or_error.result
          if error then
            print(error)
            return
          end
    
          for _, v in pairs(result) do
            for _, v1 in pairs(v) do
              vim.cmd(string.format("edit %s", v1))
            end
          end
        end
      end)
    end
    
    return M
    
    local lsp_ext = require("lsp_ext")
    vim.keymap.set('n', '<D-A-o>', lsp_ext.lsp_go_to_relevant_file)
    

    my guess is that the plugin intercepts all lsp calls and if the given method is not included in some "hardcoded" list or is unable to find it from the server capabilities, it just blocks the requests. If that'd be case, I think the plugin should allow to bypass the request

  3. tpope commented on Oct 29, 2025

    @tpope
    Collaborator
      vim.lsp.buf_request_all(0, "experimental/goToRelevantFile", params, function(results)
    

    Here, the request is sent all attached language servers, that's what the all means. This includes the Copilot language server.

          if error then
            print(error)
            return
          end
    

    And this prints any error that results and exits the loop prematurely.

    So in short, this code is both causing the error and printing the error and short circuiting before the result you're actually looking for is processed.

    my guess is that the plugin intercepts all lsp calls

    There's nothing like this in Copilot.vim.

  4. dagi3d commented on Oct 29, 2025

    @dagi3d
    Author

    Thanks a lot for the clarification, did not know that Copilot launched its own lsp, now that makes absolutely sense.
    Changing the implementation to something like this, to ensure request is sent only to the ruby-lsp, make it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions