-
-
Notifications
You must be signed in to change notification settings - Fork 847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lsp_definitions
doesn't work for builtins and deps in Deno LSP
#2768
Comments
I've done some investigation and I believe I know the cause of the issue as well. Note that in every case, the file being loaded has a "virtual" name like Following the definition of function M.definition(options)
local params = util.make_position_params()
request_with_options('textDocument/definition', params, options)
end
local function request_with_options(name, params, options)
local req_handler
if options then
req_handler = function(err, result, ctx, config)
local client = vim.lsp.get_client_by_id(ctx.client_id)
local handler = client.handlers[name] or vim.lsp.handlers[name]
handler(err, result, ctx, vim.tbl_extend('force', config or {}, options))
end
end
request(name, params, req_handler)
end I noticed that it calls Then this calls into here: Notably, this checks for the I don't think telescope's |
(Worth noting that this can also affect |
It is probably interesting to note that trouble.nvim appears to have the same kind of bug (not invoking client-specific LSP handlers, and thus failing to handle Deno in the same way), so I opened a discussion. |
Thanks for the report and investigative findings. Really helps a lot. I think I can put together a fix for this. Luckily there's a |
I created a PR #2770 |
This is still broken. I don't know if it is of any help, but after running Screen recording: Screen.Recording.2024-06-03.at.14.25.38.mov |
Hi, I have the same issue for angular project, Is there some way to implement fallback to go to native |
@yavorski check that this isn't a |
Trying to take another look at this. The trouble is, these LSPs with custom handlers can theoretically do anything and I don't think there's a reliable way for plugin authors to account for the results of these handlers. The other option is allowing users to write custom handlers specifically for telescope but I don't realistically see 99% of people managing that. And telescope is certainly not in a place to maintain telescope specific nvim-lspconfig type handlers. |
I think the best approach would be to flip the current telescope lsp implementations around a bit. Many of the Going with this approach would significantly simplify telescope's current lsp related pickers as well. |
Only problem is, I believe |
I've implemented this #3335 But unfortunately, looks like neovim's lsp functions currently on nightly don't use client/global handlers either neovim/neovim#30908 (comment) |
type MapNever<T, U> = { [K in Exclude<keyof T, keyof U>]?: never }
type XOR<T, U> = (MapNever<T, U> & U) | (MapNever<U, T> & T)
export {}
but Screen.Recording.2024-11-15.at.08.44.08.mov
|
Description
Using
require("telescope.builtin").lsp_definitions()
fails even whenvim.lsp.buf.definition()
works in the Deno LSP for a dependency or builtin (likeconsole.log
). See recordings in expected/actual sections.Neovim version
Operating system and version
nixos-unstable (Linux 6.1.60)
Telescope version / branch / rev
telescope 4522d7e
checkhealth telescope
Steps to reproduce
minimal.lua
and the following.touch deno.json
(so the LSP sees this as a project root).echo 'console.log("hello world")' > foo.ts
nvim -nu minimal.lua
:e foo.ts
:Telescope lsp_definitions
(onconsole
orlog
).Alternately, to see the successful outcome, replace step 7 with
:lua vim.lsp.buf.definition()
, but not during the same execution becausevim.lsp.buf.definition
andlsp_definitions
change each other's outcomes if run in succession in the same Neovim session.Expected behavior
When I use
vim.lsp.buf.definition()
for a dependency or builtin (likeconsole.log
), it works correctly: asciinemaActual behavior
But when I use
require("telescope.builtin").lsp_definitions()
, it fails: asciinemaMinimal config
The text was updated successfully, but these errors were encountered: