33 lines
673 B
Go
33 lines
673 B
Go
// lsp_hover — Type signature and documentation for symbol at position.
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"ollie/tools/lsp/internal/cmdutil"
|
|
)
|
|
|
|
func main() {
|
|
cmdutil.Run("hover", func(result json.RawMessage) {
|
|
var hover struct {
|
|
Contents struct {
|
|
Kind string `json:"kind"`
|
|
Value string `json:"value"`
|
|
} `json:"contents"`
|
|
}
|
|
if err := json.Unmarshal(result, &hover); err != nil {
|
|
var plain struct {
|
|
Contents string `json:"contents"`
|
|
}
|
|
if json.Unmarshal(result, &plain) == nil {
|
|
fmt.Println(plain.Contents)
|
|
return
|
|
}
|
|
fmt.Println("(no hover information)")
|
|
return
|
|
}
|
|
fmt.Println(hover.Contents.Value)
|
|
})
|
|
}
|