Skip to content
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

Null on Hover result #141

Closed
UnrealKonnord opened this issue Mar 14, 2019 · 0 comments · Fixed by #148
Closed

Null on Hover result #141

UnrealKonnord opened this issue Mar 14, 2019 · 0 comments · Fixed by #148

Comments

@UnrealKonnord
Copy link

Hello.

Currently i'm trying to create a lsp cli client for my student project. I'm dialoging with the clang language server clangd. I'm trying using your lsp types libraries but when i'm trying to get a hover result from the language server. I'm getting a null value but the language server give a result.

{
  "id":4,
  "jsonrpc":"2.0",
  "result":{
      "contents":{
          "kind":"plaintext",
          "value":"Declared in global namespace\n\nint square(int x)"
      }
   }
}

I found the result given by clangd on my request and i found out the data Hover doesn't match the case where contents is MarkupContent.

interface Hover {
	contents: MarkedString | MarkedString[] | MarkupContent;
	range?: Range;
}

I create an edited hover data type to match this case.

data Hover = Hover {
        _contents :: Either (List MarkedString) MarkupContent,
        _range    :: Maybe Range
    } deriving (Read, Show, Eq)

instance FromJSON Hover where
    parseJSON = withObject "object" $ \o -> do
        Hover <$> ( (Left  <$>  o .:  "contents") <|>
                            (Right <$> o .:  "contents") )
    
              <*>   o .:? "range"

I want to know if it's the right way to make it ?
Thank you.

alanz added a commit that referenced this issue Apr 16, 2019
And deprecate the old MarkedString as per the LSP spec.

Closes #141

Addresses some of #134
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant