Skip to content

Commit 0c187a3

Browse files
committed
feat: change completion markup
1 parent 6b8239b commit 0c187a3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,20 @@ impl LanguageServer for Backend {
500500
Some(format!("{type_}(\"{relation}\", …)"))
501501
}
502502
};
503-
if let Some(help) = &field.help {
504-
completion.documentation = Some(Documentation::String(help.to_string().into_owned()));
505-
}
503+
let module = self
504+
.module_index
505+
.module_of_path(Path::new(field.location.path.as_str()))
506+
.unwrap();
507+
let module = self.module_index.interner.resolve(&module);
508+
let text = if let Some(help) = &field.help {
509+
format!("*Defined in:* `{module}`\n\n{}", help.to_string())
510+
} else {
511+
format!("*Defined in:* `{module}`")
512+
};
513+
completion.documentation = Some(Documentation::MarkupContent(MarkupContent {
514+
kind: MarkupKind::Markdown,
515+
value: text,
516+
}));
506517
}
507518
}
508519
_ => {}

src/python.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn parse_help<'text>(node: &Node, contents: &'text [u8]) -> Cow<'text, str> {
7171
content.extend(children);
7272
}
7373
}
74-
Cow::from(content.join(""))
74+
Cow::from(content.join(" "))
7575
}
7676
_ => unreachable!(),
7777
}

0 commit comments

Comments
 (0)