Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Handle hover on local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Jan 10, 2024
1 parent d7bccbc commit 5bc9be4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/lsp/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ func (s *server) Hover(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2
if !ok {
return reply(ctx, nil, nil)
}
if i.Obj != nil { // its a var
if offset >= int(i.Pos())-1 && offset < int(i.End())-1 {
return reply(ctx, protocol.Hover{
Contents: protocol.MarkupContent{
Kind: protocol.Markdown,
Value: fmt.Sprintf("```gno\n%s %s\n```", i.Obj.Kind, i.Obj.Name),
},
Range: posToRange(
int(params.Position.Line),
[]int{int(i.Pos()), int(i.End())},
),
}, nil)
}
return reply(ctx, nil, nil)
}
if offset >= int(i.Pos())-1 && offset < int(i.End())-1 { // X
for _, spec := range pgf.File.Imports {
// remove leading and trailing `"`
Expand Down

0 comments on commit 5bc9be4

Please sign in to comment.