Skip to content

Commit

Permalink
add completion details
Browse files Browse the repository at this point in the history
  • Loading branch information
PgBiel committed Jan 26, 2025
1 parent 15fd448 commit 2a40ffa
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 63 deletions.
23 changes: 20 additions & 3 deletions server/internal/lsp/search/search_completion_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ func GetCompletableDocComment(s symbols.Indexable) any {
}
}

func GetCompletionDetail(s symbols.Indexable) *string {
detail := s.GetCompletionDetail()
if detail == "" {
return nil
} else {
return &detail
}
}

// Returns: []CompletionItem | CompletionList | nil
func (s *Search) BuildCompletionList(
ctx context.CursorContext,
Expand Down Expand Up @@ -240,6 +249,8 @@ func (s *Search) BuildCompletionList(

// At this moment, struct members cannot receive documentation
Documentation: nil,

Detail: GetCompletionDetail(member),
})
}
}
Expand Down Expand Up @@ -271,6 +282,7 @@ func (s *Search) BuildCompletionList(
Range: replacementRange,
},
Documentation: GetCompletableDocComment(fn),
Detail: GetCompletionDetail(fn),
})
}

Expand All @@ -284,6 +296,8 @@ func (s *Search) BuildCompletionList(

// No documentation for enumerators at this time
Documentation: nil,

Detail: GetCompletionDetail(enumerator),
})
}
}
Expand All @@ -298,6 +312,8 @@ func (s *Search) BuildCompletionList(

// No documentation for fault constants at this time
Documentation: nil,

Detail: GetCompletionDetail(constant),
})
}
}
Expand Down Expand Up @@ -328,20 +344,21 @@ func (s *Search) BuildCompletionList(
editRange := symbolInPosition.FullTextRange().ToLSP()

items = append(items, protocol.CompletionItem{
Label: storedIdentifier.GetName(),
Kind: cast.ToPtr(storedIdentifier.GetKind()),
Detail: cast.ToPtr("Module"),
Label: storedIdentifier.GetName(),
Kind: cast.ToPtr(storedIdentifier.GetKind()),
TextEdit: protocol.TextEdit{
NewText: storedIdentifier.GetName(),
Range: editRange,
},
Documentation: GetCompletableDocComment(storedIdentifier),
Detail: GetCompletionDetail(storedIdentifier),
})
} else {
items = append(items, protocol.CompletionItem{
Label: storedIdentifier.GetName(),
Kind: cast.ToPtr(storedIdentifier.GetKind()),
Documentation: GetCompletableDocComment(storedIdentifier),
Detail: GetCompletionDetail(storedIdentifier),
})
}
}
Expand Down
Loading

0 comments on commit 2a40ffa

Please sign in to comment.