Skip to content

Commit cba23b8

Browse files
nlopesclaude
andcommitted
feat(lsp): add inlay hints for resolved attributes and xref titles
Show resolved document attribute values and cross-reference section titles as inline ghost text via textDocument/inlayHint. Attribute references like {product-name} display their value; xrefs like <<setup>> show the target section title. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b9d5867 commit cba23b8

File tree

5 files changed

+670
-7
lines changed

5 files changed

+670
-7
lines changed

acdc-lsp/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- **Inlay hints** — show resolved attribute values and cross-reference titles as
13+
ghost text inline (`textDocument/inlayHint`). Attribute references like
14+
`{product-name}` display their resolved value; xrefs like `<<setup>>` show the
15+
target section title.
1216
- **Selection range** — smart expand/shrink selection based on AST structure
1317
(`textDocument/selectionRange`). Progressively selects larger syntactic units:
1418
word → inline markup → block → section → document.

acdc-lsp/src/backend.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};
2121
use tower_lsp::{Client, LanguageServer};
2222

2323
use 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
};
2727
use 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

Comments
 (0)