mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-13 08:27:17 +00:00
feat: Implement inlay hint tooltips
This commit is contained in:
parent
12d5343993
commit
91833f1974
3 changed files with 22 additions and 2 deletions
|
@ -4,7 +4,8 @@ use lsp_types::{
|
|||
CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DeclarationCapability,
|
||||
DocumentOnTypeFormattingOptions, FileOperationFilter, FileOperationPattern,
|
||||
FileOperationPatternKind, FileOperationRegistrationOptions, FoldingRangeProviderCapability,
|
||||
HoverProviderCapability, ImplementationProviderCapability, OneOf, RenameOptions, SaveOptions,
|
||||
HoverProviderCapability, ImplementationProviderCapability, InlayHintOptions,
|
||||
InlayHintServerCapabilities, OneOf, RenameOptions, SaveOptions,
|
||||
SelectionRangeProviderCapability, SemanticTokensFullOptions, SemanticTokensLegend,
|
||||
SemanticTokensOptions, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability,
|
||||
TextDocumentSyncKind, TextDocumentSyncOptions, TypeDefinitionProviderCapability,
|
||||
|
@ -112,7 +113,12 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
|
|||
.into(),
|
||||
),
|
||||
moniker_provider: None,
|
||||
inlay_hint_provider: Some(OneOf::Left(true)),
|
||||
inlay_hint_provider: Some(OneOf::Right(InlayHintServerCapabilities::Options(
|
||||
InlayHintOptions {
|
||||
work_done_progress_options: Default::default(),
|
||||
resolve_provider: Some(true),
|
||||
},
|
||||
))),
|
||||
experimental: Some(json!({
|
||||
"externalDocs": true,
|
||||
"hoverRange": true,
|
||||
|
|
|
@ -1348,6 +1348,19 @@ pub(crate) fn handle_inlay_hints(
|
|||
))
|
||||
}
|
||||
|
||||
pub(crate) fn handle_inlay_hints_resolve(
|
||||
_snap: GlobalStateSnapshot,
|
||||
mut hint: InlayHint,
|
||||
) -> Result<InlayHint> {
|
||||
if let lsp_types::InlayHintLabel::String(s) = &hint.label {
|
||||
hint.tooltip = Some(lsp_types::InlayHintTooltip::MarkupContent(lsp_types::MarkupContent {
|
||||
kind: lsp_types::MarkupKind::PlainText,
|
||||
value: s.clone(),
|
||||
}));
|
||||
}
|
||||
Ok(hint)
|
||||
}
|
||||
|
||||
pub(crate) fn handle_call_hierarchy_prepare(
|
||||
snap: GlobalStateSnapshot,
|
||||
params: CallHierarchyPrepareParams,
|
||||
|
|
|
@ -612,6 +612,7 @@ impl GlobalState {
|
|||
.on::<lsp_types::request::GotoImplementation>(handlers::handle_goto_implementation)
|
||||
.on::<lsp_types::request::GotoTypeDefinition>(handlers::handle_goto_type_definition)
|
||||
.on::<lsp_types::request::InlayHintRequest>(handlers::handle_inlay_hints)
|
||||
.on::<lsp_types::request::InlayHintResolveRequest>(handlers::handle_inlay_hints_resolve)
|
||||
.on::<lsp_types::request::Completion>(handlers::handle_completion)
|
||||
.on::<lsp_types::request::ResolveCompletionItem>(handlers::handle_completion_resolve)
|
||||
.on::<lsp_types::request::CodeLensRequest>(handlers::handle_code_lens)
|
||||
|
|
Loading…
Reference in a new issue