extensions/markdown-language-features/server/src/server.ts/registerCompletionsSupport
function registerCompletionsSupport(
	connection: Connection,
	documents: TextDocuments<md.ITextDocument>,
	ls: md.IMdLanguageService,
	config: ConfigurationManager,
): IDisposable {
	connection.onCompletion(async (params, token): Promise<lsp.CompletionItem[]> => {
		const settings = config.getSettings();
		if (!settings?.markdown.suggest.paths.enabled) {
			return [];
		}

		const document = documents.get(params.textDocument.uri);
		if (document) {
			return ls.getCompletionItems(document, params.position, params.context!, token);
		}
		return [];
	});

	return registerDynamicClientFeature(config, (settings) => !!settings?.markdown.suggest.paths.enabled, () => {
		const registrationOptions: CompletionRegistrationOptions = {
			documentSelector: null,
			triggerCharacters: ['.', '/', '#'],
		};
		return connection.client.register(CompletionRequest.type, registrationOptions);
	});
}