documentHighlight function
Extension
documentHighlight(
- DocumentHighlightSource source, [
- DocumentHighlightOptions options = const DocumentHighlightOptions()
Set up document highlight support.
The source callback is called when the cursor moves to highlight
all occurrences of the symbol at the cursor position.
Example:
documentHighlight((state, pos) async {
final highlights = await lspClient.documentHighlight(state.doc, pos);
if (highlights == null) return null;
return DocumentHighlightResult(highlights.map((h) => DocumentHighlight(
from: h.range.start,
to: h.range.end,
kind: h.kind == 2 ? HighlightKind.read
: h.kind == 3 ? HighlightKind.write
: HighlightKind.text,
)).toList());
})
Implementation
Extension documentHighlight(
DocumentHighlightSource source, [
DocumentHighlightOptions options = const DocumentHighlightOptions(),
]) {
ensureDocumentHighlightInitialized();
final config = DocumentHighlightConfig(
source: source,
options: options,
);
return ExtensionList([
documentHighlightFacet.of(config),
_highlightState,
decorationsFacet.of((EditorViewState view) {
final field = view.state.field(_highlightState, false);
return field?.decorations ?? Decoration.none;
}),
]);
}