How to use the vscode-languageserver-types.CompletionItem.create function in vscode-languageserver-types

To help you get started, we’ve selected a few vscode-languageserver-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / vscode-emmet-helper / src / emmetHelper.ts View on Github external
|| (!/^[a-z,A-Z,\d]*$/.test(abbreviation) && !abbreviation.endsWith('.'))
			|| markupSnippetKeys.indexOf(abbreviation) > -1
			|| commonlyUsedTags.indexOf(abbreviation) > -1) {
			try {
				expandedText = expand(abbreviation, expandOptions);
				// Skip cases when abc -> abc: ; as this is noise
				if (isStyleSheet(syntax) && expandedText === `${abbreviation}: \${1};`) {
					expandedText = '';
				}
			} catch (e) {

			}
		}

		if (expandedText) {
			expandedAbbr = CompletionItem.create(abbreviation);
			expandedAbbr.textEdit = TextEdit.replace(abbreviationRange, expandedText);
			expandedAbbr.documentation = removeTabStops(expandedText);
			expandedAbbr.insertTextFormat = InsertTextFormat.Snippet;
			expandedAbbr.detail = 'Emmet Abbreviation';
			if (filters.indexOf('bem') > -1) {
				expandedAbbr.label = abbreviation + filterDelimitor + bemFilterSuffix;
			}
			if (isStyleSheet(syntax)) {
				// See https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902
				// Due to this we set filterText, sortText and label to expanded abbreviation
				// - Label makes it clear to the user what their choice is 
				// - FilterText fixes the issue when user types in propertyname and emmet uses it to match with abbreviations
				// - SortText will sort the choice in a way that is intutive to the user
				expandedAbbr.filterText = expandedAbbr.documentation;
				expandedAbbr.sortText = expandedAbbr.documentation;
				expandedAbbr.label = expandedAbbr.documentation;
github vuejs / vetur / server / src / modes / style / stylus / completion-item.ts View on Github external
function _functionSymbol(node: StylusNode, text: string[]): CompletionItem {
  const name = node.name;

  const completionItem = CompletionItem.create(name);
  completionItem.kind = CompletionItemKind.Function;

  return completionItem;
}
github vuejs / vetur / server / src / modes / style / stylus / completion-item.ts View on Github external
function _selectorSymbol(node: StylusNode, text: string[], currentWord: string): CompletionItem {
  const firstSegment = node.segments[0];
  const name = firstSegment.string
    ? node.segments!.map(s => s.string).join('')
    : firstSegment.nodes!.map(s => s.name).join('');

  const completionItem = CompletionItem.create(name);
  completionItem.kind = CompletionItemKind.Class;

  return completionItem;
}
github vuejs / vetur / server / src / modes / style / stylus / completion-item.ts View on Github external
return data.atDirectives.map(property => {
    const completionItem = CompletionItem.create(property.name);

    completionItem.detail = property.description;
    completionItem.kind = CompletionItemKind.Keyword;

    return completionItem;
  });
}
github vuejs / vetur / server / src / modes / style / stylus / completion-item.ts View on Github external
return data.properties.map(property => {
    const completionItem = CompletionItem.create(property.name);

    completionItem.insertText = property.name + (useSeparator ? ': ' : ' ');
    completionItem.detail = property.description;
    completionItem.kind = CompletionItemKind.Property;

    return completionItem;
  });
}
github microsoft / vscode-emmet-helper / src / emmetHelper.ts View on Github external
const createExpandedAbbr = (abbr) => {

		try {
			expandedText = expand(abbr, expandOptions);
		} catch (e) {
		}

		if (expandedText && isExpandedTextNoise(syntax, abbr, expandedText)) {
			expandedText = '';
		}

		if (expandedText) {
			expandedAbbr = CompletionItem.create(abbr);
			expandedAbbr.textEdit = TextEdit.replace(abbreviationRange, escapeNonTabStopDollar(addFinalTabStop(expandedText)));
			expandedAbbr.documentation = replaceTabStopsWithCursors(expandedText);
			expandedAbbr.insertTextFormat = InsertTextFormat.Snippet;
			expandedAbbr.detail = 'Emmet Abbreviation';
			expandedAbbr.label = abbreviation;
			expandedAbbr.label += filter ? '|' + filter.replace(',', '|') : "";
			completionItems = [expandedAbbr];
		}
	}
github microsoft / vscode-emmet-helper / src / emmetHelper.ts View on Github external
if (!snippetKey.startsWith(prefix.toLowerCase()) || (skipFullMatch && snippetKey === prefix.toLowerCase())) {
			return;
		}

		let currentAbbr = abbreviation + snippetKey.substr(prefix.length);
		let expandedAbbr;
		try {
			expandedAbbr = expand(currentAbbr, expandOptions);
		} catch (e) {

		}
		if (!expandedAbbr) {
			return;
		}

		let item = CompletionItem.create(prefix + snippetKey.substr(prefix.length));
		item.documentation = replaceTabStopsWithCursors(expandedAbbr);
		item.detail = snippetDetail;
		item.textEdit = TextEdit.replace(abbreviationRange, escapeNonTabStopDollar(addFinalTabStop(expandedAbbr)));
		item.insertTextFormat = InsertTextFormat.Snippet;

		snippetCompletions.push(item);
	});
	return snippetCompletions;
github vuejs / vetur / server / src / modes / style / stylus / completion-item.ts View on Github external
function _variableSymbol(node: StylusNode, text: string[], currentWord: string): CompletionItem {
  const name = node.name;
  const lineno = Number(node.val!.lineno!) - 1;

  const completionItem = CompletionItem.create(name);
  completionItem.detail = text[lineno].trim();
  completionItem.kind = CompletionItemKind.Variable;

  return completionItem;
}
github vuejs / vetur / server / src / modes / style / stylus / built-in.ts View on Github external
export default builtIn.map((item) => {
  const completionItem = CompletionItem.create(item.insertText);
  completionItem.detail = item.name;
  completionItem.insertText = item.insertText;
  completionItem.documentation = item.desc;
  completionItem.kind = CompletionItemKind.Function;

  return completionItem;
});