Description
Description
When using ruby-lsp
for a project of mine, I need to pass in paths to ruby farms for indexing relative to my project root. For example, I might pass a path like ../../some-directory/some-sub-directory/**/*.rb
to ruby-lsp
for indexing some project dependancies. When the builtin lsp_definitions
method in telescope returns multiple potential method definitions, I've noticed that though the resulting picker is able to display file previews as expected, if i try to select one to jump to it will ignore the initial parent directory jumps and instead attempt to navigate to the rest of the file path from the current working directory. For example if the workspace is rooted at /project-a
and the picker is previewing a potential method definition at ../../project-b/file.rb
when I try to select that item in the picker, it will attempt to navigate to /project-a/project-b/file.rb
which doesn't exist, even though it was able to properly preview the file. Additionally, when lsp_definitions
only finds one possible definition (and jumps straight to it without the picker), it is able to succeed no matter if the relative path to the reference begins with one or more parent directory jumps. This is probably because these lines in the list_or_jump method are able to understand where to go when given a path like ../../some-directory/some-sub-directory/some-file.rb
, but there must be some logic in the picker that can't handle the ../..
.
Given that the picker preview works fine for all items in the picker, I would expect that it would easily be able to jump to any of these item as well.
Neovim version
NVIM v0.11.1
Build type: Release
LuaJIT 2.1.1744318430
Operating system and version
macOS 15.5
Telescope version / branch / rev
telescope 0.11
checkhealth telescope
==============================================================================
telescope: health#telescope#check
Checking for required plugins ~
- ✅ OK plenary installed.
- ✅ OK nvim-treesitter installed.
Checking external dependencies ~
- ✅ OK rg: found ripgrep 12.1.1
- ✅ OK fd: found fd 10.2.0
===== Installed extensions ===== ~
Telescope Extension: `ui-select` ~
- No healthcheck provided
Steps to reproduce
This is probably very difficult to reproduce, but to do so you would need to do the following:
- Configure an LSP to index files at some path beginning with any number of parent directory jumps like "../../" relative to the lsp root directory
- Define two methods with the same name in some file that gets indexed from the above path
- call this method from some file in the workspace that the LSP
- run the builtin lsp_definitions command on this function call. It should open up the picker window since there would now be two methods with the same name. The picker window should be able to preview each definition fine, but should fail upon the user attempting to select one.
When it comes down to it, there must be some logic downstream in the picker window code that handles jumping to the reference differently than this from above which works no problem.
Expected behavior
I would expect to be able to open a possible symbol definition at a file path beginning with "../../" relative to the workspace root no matter what, especially given that the picker preview is able to preview such files.
Actual behavior
See description.
Minimal config
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
vim.fn.system {
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
}
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
require("telescope").setup {}
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})