Skip to content

Commit 00a38f1

Browse files
committed
draft: reply value-doc
1 parent 8b7fc6f commit 00a38f1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

nixd/lib/Controller/Hover.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class NixpkgsHoverProvider {
5656
///
5757
/// FIXME: there are many markdown generation in language server.
5858
/// Maybe we can add structured generating first?
59-
static std::string mkMarkdown(const PackageDescription &Package) {
59+
static std::string mkPackageMarkdown(const PackageDescription &Package) {
6060
std::ostringstream OS;
6161
// Make each field a new section
6262

@@ -87,6 +87,10 @@ class NixpkgsHoverProvider {
8787
return OS.str();
8888
}
8989

90+
static std::string mkValueMarkdown(const ValueDescription &ValueDesc) {
91+
return ValueDesc.Doc;
92+
}
93+
9094
public:
9195
NixpkgsHoverProvider(AttrSetClient &NixpkgsClient)
9296
: NixpkgsClient(NixpkgsClient) {}
@@ -107,7 +111,11 @@ class NixpkgsHoverProvider {
107111
if (!Desc)
108112
return std::nullopt;
109113

110-
return mkMarkdown(Desc->PackageDesc);
114+
if (const auto ValueDesc = Desc->ValueDesc) {
115+
return ValueDesc->Doc;
116+
}
117+
118+
return mkPackageMarkdown(Desc->PackageDesc);
111119
}
112120
};
113121

0 commit comments

Comments
 (0)