RLovelett/langserver-swift

LanguageServer does not work for me in Visual Studio Code

oderwat opened this issue ยท 8 comments

(๐Ÿ‘ for you work btw!)

I got the LanguageServer and sourcekitten compiled and moved both to /usr/local/bin. Using Visual Studio Code and hover over "anything" I now get:

[Error - 8:35:43 PM] Request textDocument/hover failed.
  Message: There was an error communicating with SourceKit.
  Code: -32097 

I also get hovers which look like this:

image

Any Ideas?

Well it doesn't seem like its anything since you can see the hover value in the screenshot you provided! ๐Ÿ™ƒ

I think I can explain both behaviors though.

The easy one to explain is the screenshot. That is the raw value provided back by Swift (read: SourceKit). Obviously it is XML and I don't do any translation of it. The reason is pretty straight forward. Unfortunately, the structure of the XML is not documented anywhere (that I know of) so I'd have to reverse engineer it to figure out how to display it. It would be awesome if SourceKit returned the Markdown instead of XML. Alas it does not.

The error your seeing is less easy to explain but is actually the one that I am working actively to solve. In short, you are likely experiencing those because you didn't save 1 or more documents before hovering. The hover commands, as currently written, do not support interacting with non-saved documents.

I meant any symbol with "anything". I get the error on some (keywords, types, parameter names) and the xml on others (functions, variables mostly). The files are all saved.

P.S.: I was of the impression that it is supposed to work in vsc already. From what you write it seems that this is WIP and just not expected to work already?

Could you attach a small sample project that shows the issue? Because I've not experienced that in my tests locally.

Not sure what you mean. This happens for me with every file. I don't have a project.

func dumpThem(_ all: Any...) {
  for elem in all {
    switch elem {
      case let i as Int:
        print("Number: \(i)")
        break

      case let s as String:
        print("String: " + s)
        break

      default:
        print("Other: \(elem)")
    }
  }
}

dumpThem(1 as Any, 2.0 as Any, "3" as Any)

Thank you for that code snippet. That was the first time I had encountered those specific problems.

I've pushed up a change onto master that should resolve those issues.

Again thank you for the report!

I am having same problem with Visual Studio Code using the latest HIE.

@razvan-panda can you provide a code snippet?

Also, what is HIE?

HIE is Haskell IDE Engine https://github.com/haskell/haskell-ide-engine
can you provide a code snippet? I can but not sure if relevant for this ticket at all, the errors was not specific to any code from what I seen. I just cloned built and opened: https://github.com/snowdriftcoop/snowdrift and the error was thrown in the console