Skip to content

hover improvements #97

Closed
Closed
@alanz

Description

@alanz

Some observations from testing with https://github.com/alanz/haskell-language-server/tree/hls-wz1000 at alanz@ebad0a1.

I am using lsp-mode on emacs 26.3, comparing the hover output for Integer in the snippet

{-# LANGUAGE MultiParamTypeClasses #-}
module B where
--
-- TODO2 added by Example2 Plugin directly
--
--
--
foo :: Integer
foo = 4

class Foo a b where
  baz :: a -> b

haskell-ide-engine (1.3)

[Trace - 09:19:58 ] Received response 'textDocument/hover - (47)' in 27ms.
Result: {
  "range": {
    "end": {
      "character": 14,
      "line": 7
    },
    "start": {
      "character": 7,
      "line": 7
    }
  },
  "contents": {
    "value": "Invariant: `Jn#` and `Jp#` are used iff value doesn't fit in `S#`\n\nUseful properties resulting from the invariants:\n\n- \n```haskell\nabs (`S#` _) <= abs (`Jp#` _)\n```\n\n- \n```haskell\nabs (`S#` _) <  abs (`Jn#` _)\n```\n\n\n\n[Documentation](file:///home/alanz/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/share/doc/ghc-8.6.5/html/libraries/integer-gmp-1.0.2.0/GHC-Integer.html#t:Integer)\n\n[Source](file:///home/alanz/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/share/doc/ghc-8.6.5/html/libraries/integer-gmp-1.0.2.0/src/GHC-Integer-Type.html#Integer)\n\ninteger-gmp GHC.Integer.Type",
    "kind": "markdown"
  }
}

The contents of the markdown is

Invariant: `Jn#` and `Jp#` are used iff value doesn't fit in `S#`

Useful properties resulting from the invariants:

- 
```haskell
abs (`S#` _) <= abs (`Jp#` _)
```

- 
```haskell
abs (`S#` _) <  abs (`Jn#` _)
```



[Documentation](file:///home/alanz/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/share/doc/ghc-8.6.5/html/libraries/integer-gmp-1.0.2.0/GHC-Integer.html#t:Integer)

[Source](file:///home/alanz/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/share/doc/ghc-8.6.5/html/libraries/integer-gmp-1.0.2.0/src/GHC-Integer-Type.html#Integer)

integer-gmp GHC.Integer.Type

haskell-language-server as above

[Trace - 09:17:38 ] Received response 'textDocument/hover - (31)' in 12ms.
Result: {
  "range": {
    "end": {
      "character": 14,
      "line": 7
    },
    "start": {
      "character": 7,
      "line": 7
    }
  },
  "contents": {
    "value": "\n```haskell\nInteger\n```\n\n*Defined in ‘GHC.Integer.Type’*\n\n\nInvariant:  `Jn#`  and  `Jp#`  are used iff value doesn't fit in  `S#` \n\nUseful properties resulting from the invariants: \n+ ```haskell\n  abs ( `S#`  _) <= abs ( `Jp#`  _)\n  ```\n\n+ ```haskell\n  abs ( `S#`  _) <  abs ( `Jn#`  _)\n  ```\n\n\n",
    "kind": "markdown"
  }
}

The markdown is

```haskell
Integer
```

*Defined in ‘GHC.Integer.Type’*


Invariant:  `Jn#`  and  `Jp#`  are used iff value doesn't fit in  `S#` 

Useful properties resulting from the invariants: 
+ ```haskell
  abs ( `S#`  _) <= abs ( `Jp#`  _)
  ```

+ ```haskell
  abs ( `S#`  _) <  abs ( `Jn#`  _)
  ```




Emacs renders these as

HIE
hie-hover

HLS
hls-hover

The main problem seems to be that the

```haskell
markup needs to be against the left margin, which is not the case for hls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions