nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.47k stars 288 forks source link

`peek_definition` not work for Lexical(Elixir LS) #1323

Closed scottming closed 1 year ago

scottming commented 1 year ago

Describe the bug

I just found this commit: https://github.com/nvimdev/lspsaga.nvim/commit/442e63750ddd14f22511dc509e226d71e6c36d5f# broke the peek_definition for Elixir

Is it because of these lines:

https://github.com/nvimdev/lspsaga.nvim/commit/442e63750ddd14f22511dc509e226d71e6c36d5f#diff-dc22d75dcfeb427a63be2c3167fcecf2a2493423132544dde7d88d8e87981400L229-L231

, as I reported before, according to the spec, Location is valid response to return: https://github.com/nvimdev/lspsaga.nvim/issues/934#issuecomment-1455694543

Steps to reproduce

the response for lexical LSP is:

}
[DEBUG][2023-10-15 11:09:34] .../vim/lsp/rpc.lua:387    "rpc.receive"   {
  id = 6,
  jsonrpc = "2.0",
  result = {
    range = {
      ["end"] = {
        character = 42,
        line = 0
      },
      start = {
        character = 10,
        line = 0
      }
    },
    uri = "file:///Users/scottming/Code/lexical/apps/remote_control/lib/lexical/remote_control/completion.ex"
  }
}

Expected behavior

show the peeked window.

Neovim version (nvim -v)

0.9.2

lspsaga commit

442e63750ddd14f22511dc509e226d71e6c36d5f

Terminal name/version

alacritty

glepnir commented 1 year ago
diff --git a/lua/lspsaga/definition.lua b/lua/lspsaga/definition.lua
index 2d26f48..a788e2a 100644
--- a/lua/lspsaga/definition.lua
+++ b/lua/lspsaga/definition.lua
@@ -223,10 +223,10 @@ function def:definition_request(method, handler_T, args)
   end)
 end

-function def:peek_handler(result, context, count)
+function def:peek_handler(res, context, count)
   count = count - 1
   self.pending_request = false
-  if not result or next(result) == nil then
+  if not res or next(res) == nil then
     if #self.list == 0 and count == 0 then
       vim.notify(
         '[lspsaga] response of request method ' .. context.method .. ' is empty',
@@ -235,8 +235,10 @@ function def:peek_handler(result, context, count)
     end
     return
   end
-  if result.uri then
-    result = { result }
+
+  local result = {}
+  if not vim.tbl_islist(res) then
+    result = { res }
   end

   local node = {

does this solved ?

scottming commented 1 year ago

does this solved ?

no, I opened a PR for this.