Giter Club home page Giter Club logo

Comments (12)

rmagatti avatar rmagatti commented on August 22, 2024

Hey @jlesquembre, are you calling goto_preview_implementation or goto_preview_definition? The manual call to the LSP snippet you show calling the implementation one, does that also not work with goto-preview or is it just the definition call that doesn't?

from goto-preview.

jlesquembre avatar jlesquembre commented on August 22, 2024

I'm calling goto_preview_definition. I tested goto_preview_implementation, which doesn't show any error, but does nothing.

The LSP snippet I posted, I think it is what goto-preview is calling internally. That snippet works fine, it's only goto-preview not working. I'm confused by that, since the LSP seems to return a valid value.

from goto-preview.

rmagatti avatar rmagatti commented on August 22, 2024

@jlesquembre So from what I can tell there are a few odd things here

  1. I think the clojure LSP doesn't seem to support textDocument/implementation, at least according to https://github.com/clojure-lsp/clojure-lsp/blob/master/docs/capabilities.md, so it is odd to me how you seem to have called that manually and got results for it. (might just be out of date docs idk)
  2. There is a thing called a legacy_handler I added a while back, this was to conform to the new way Neovim sends the data through from the LSP call to the registered handler - it might be that that logic is not working well enough when in conjunction with clojure-lsp. What I mean by that is the only real way data could be nil is if this line local data = result[1] returned nil, which could happen depending on what came back from the lsp call.

I have created this PR which should help with identifying what is wrong through improved logging.
#40

Would you mind updating goto-preview to the newest version, enabling debug, require'goto-preview'.setup{debug=true} and then showing me what you get?

from goto-preview.

jlesquembre avatar jlesquembre commented on August 22, 2024

@rmagatti thanks for your help, with the latest version, that is the debug message I get:

goto-preview: calling new handler
goto-preview: nil
Error executing vim.schedule lua callback: ...ack/home-manager/start/goto-preview/lua/goto-preview.lua:15: attempt to index local 'data' (a nil value)

I'll try to do some debugging on my own

from goto-preview.

jlesquembre avatar jlesquembre commented on August 22, 2024

found something, the result value is something like

{
  range = {
    end = {
      character = 18,
      line = 36
    },
    start = {
      character = 6,
      line = 36
    }
  },
  uri = "file:///.../utils.cljc"
}

it is not an array, because of that, result[1] is nil.

Not sure if what clojure lsp returns is valid according to the lsp spec

from goto-preview.

jlesquembre avatar jlesquembre commented on August 22, 2024

I was looking to the LSP specification, looks like returning a single Location is a valid response:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition

Maybe we could do something like local data = result[1] or result ?

from goto-preview.

rmagatti avatar rmagatti commented on August 22, 2024

Yeah that should work! I did not realize a single location was a thing. I'll see if I can get to this soon, if not happy to review a PR for it too.

from goto-preview.

jlesquembre avatar jlesquembre commented on August 22, 2024

here you go: #41

I took a deeper look, and I think that's the only required changed

from goto-preview.

rmagatti avatar rmagatti commented on August 22, 2024

Nice, thanks @jlesquembre!

from goto-preview.

lougreenwood avatar lougreenwood commented on August 22, 2024

I also see this error when trying to goto_preview_definition() in a ts file. I see the error and the preview window is successful shown.

I'm new to vim and not quite sure how to help with a reproduction etc...

from goto-preview.

lougreenwood avatar lougreenwood commented on August 22, 2024

I also get the same error with the ember language server if a definition does not exist.

from goto-preview.

rmagatti avatar rmagatti commented on August 22, 2024

@lougreenwood got a video or something showing what you mean? I can't reproduce this with tsserver.

from goto-preview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.