extensions/markdown-language-features/server/src/server.ts/registerDocumentHighlightSupport
function registerDocumentHighlightSupport(
	connection: Connection,
	documents: TextDocuments<md.ITextDocument>,
	mdLs: md.IMdLanguageService,
	configurationManager: ConfigurationManager
) {
	connection.onDocumentHighlight(async (params, token) => {
		const settings = configurationManager.getSettings();
		if (!settings?.markdown.occurrencesHighlight.enabled) {
			return undefined;
		}

		const document = documents.get(params.textDocument.uri);
		if (!document) {
			return undefined;
		}

		return mdLs!.getDocumentHighlights(document, params.position, token);
	});

	return registerDynamicClientFeature(configurationManager, (settings) => !!settings?.markdown.occurrencesHighlight.enabled, () => {
		const registrationOptions: DocumentHighlightRegistrationOptions = {
			documentSelector: null,
		};
		return connection.client.register(DocumentHighlightRequest.type, registrationOptions);
	});
}