@@ -11,18 +11,18 @@ use tower_lsp::lsp_types::{
1111 DocumentLinkParams , DocumentRangeFormattingParams , DocumentSymbolParams ,
1212 DocumentSymbolResponse , FoldingRange , FoldingRangeParams , FoldingRangeProviderCapability ,
1313 GotoDefinitionParams , GotoDefinitionResponse , Hover , HoverParams , HoverProviderCapability ,
14- InitializeParams , InitializeResult , InitializedParams , OneOf , PrepareRenameResponse ,
15- ReferenceParams , RenameOptions , RenameParams , SelectionRange , SelectionRangeParams ,
16- SelectionRangeProviderCapability , SemanticTokensParams , SemanticTokensResult ,
17- ServerCapabilities , ServerInfo , SymbolInformation , TextDocumentPositionParams ,
18- TextDocumentSyncCapability , TextDocumentSyncKind , TextEdit , Url , WorkDoneProgressOptions ,
19- WorkspaceEdit , WorkspaceSymbolParams ,
14+ InitializeParams , InitializeResult , InitializedParams , InlayHint , InlayHintParams , OneOf ,
15+ PrepareRenameResponse , ReferenceParams , RenameOptions , RenameParams , SelectionRange ,
16+ SelectionRangeParams , SelectionRangeProviderCapability , SemanticTokensParams ,
17+ SemanticTokensResult , ServerCapabilities , ServerInfo , SymbolInformation ,
18+ TextDocumentPositionParams , TextDocumentSyncCapability , TextDocumentSyncKind , TextEdit , Url ,
19+ WorkDoneProgressOptions , WorkspaceEdit , WorkspaceSymbolParams ,
2020} ;
2121use tower_lsp:: { Client , LanguageServer } ;
2222
2323use crate :: capabilities:: {
2424 code_actions, code_lens, completion, definition, document_links, folding, formatting, hover,
25- references, rename, selection_range, semantic_tokens, symbols,
25+ inlay_hints , references, rename, selection_range, semantic_tokens, symbols,
2626} ;
2727use crate :: state:: Workspace ;
2828
@@ -128,6 +128,8 @@ impl LanguageServer for Backend {
128128 } ) ,
129129 // Enable smart selection expansion
130130 selection_range_provider : Some ( SelectionRangeProviderCapability :: Simple ( true ) ) ,
131+ // Enable inlay hints for resolved attributes and xref titles
132+ inlay_hint_provider : Some ( OneOf :: Left ( true ) ) ,
131133 // Enable completion for xrefs, attributes, and includes
132134 completion_provider : Some ( CompletionOptions {
133135 trigger_characters : Some ( vec ! [
@@ -429,6 +431,17 @@ impl LanguageServer for Backend {
429431 Ok ( response. filter ( |edits| !edits. is_empty ( ) ) )
430432 }
431433
434+ async fn inlay_hint ( & self , params : InlayHintParams ) -> Result < Option < Vec < InlayHint > > > {
435+ let uri = params. text_document . uri ;
436+
437+ let response = self
438+ . workspace
439+ . get_document ( & uri)
440+ . map ( |doc| inlay_hints:: compute_inlay_hints ( & doc, & params. range ) ) ;
441+
442+ Ok ( response. filter ( |hints| !hints. is_empty ( ) ) )
443+ }
444+
432445 async fn selection_range (
433446 & self ,
434447 params : SelectionRangeParams ,
0 commit comments