How to use the vscode-languageserver-protocol.CompletionItemKind.Function function in vscode-languageserver-protocol

To help you get started, we’ve selected a few vscode-languageserver-protocol 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 neoclide / coc.nvim / src / extensions / tsserver / utils / completionItem.ts View on Github external
let sortText = tsEntry.sortText
  if (tsEntry.isRecommended) {
    // Make sure isRecommended property always comes first
    // https://github.com/Microsoft/vscode/issues/40325
    sortText = '\0' + sortText
  } else if (tsEntry.source) {
    // De-prioritze auto-imports
    // https://github.com/Microsoft/vscode/issues/40311
    sortText = '\uffff' + sortText
  } else {
    sortText = tsEntry.sortText
  }
  let kind = convertKind(tsEntry.kind)
  let insertTextFormat = (
    useCodeSnippetsOnMethodSuggest &&
    (kind === CompletionItemKind.Function ||
      kind === CompletionItemKind.Method)
  ) ? InsertTextFormat.Snippet : InsertTextFormat.PlainText

  let textEdit: TextEdit = null
  let insertText = tsEntry.insertText
  if (insertText) {
    let document = workspace.getDocument(uri)
    textEdit = {
      range: document.getWordRangeAtPosition(position),
      newText: insertText
    }
    insertText = null
  }
  let optional = tsEntry.kindModifiers && tsEntry.kindModifiers.match(/\boptional\b/)
  return {
    label,
github neoclide / coc-tsserver / src / server / utils / completionItem.ts View on Github external
let sortText = tsEntry.sortText
  if (tsEntry.isRecommended) {
    // Make sure isRecommended property always comes first
    // https://github.com/Microsoft/vscode/issues/40325
    sortText = '\0' + sortText
  } else if (tsEntry.source) {
    // De-prioritze auto-imports
    // https://github.com/Microsoft/vscode/issues/40311
    sortText = '\uffff' + sortText
  } else {
    sortText = tsEntry.sortText
  }
  let kind = convertKind(tsEntry.kind)
  let insertTextFormat = (
    useCodeSnippetsOnMethodSuggest &&
    (kind === CompletionItemKind.Function ||
      kind === CompletionItemKind.Method)
  ) ? InsertTextFormat.Snippet : InsertTextFormat.PlainText

  let insertText = tsEntry.insertText
  let document = workspace.getDocument(uri)
  let preText = document.getline(position.line).slice(0, position.character)
  const isInValidCommitCharacterContext = preText.match(/(^|[a-z_$\(\)\[\]\{\}]|[^.]\.)\s*$/ig) !== null

  let commitCharacters = getCommitCharacters(tsEntry, { isNewIdentifierLocation, isInValidCommitCharacterContext, useCodeSnippetsOnMethodSuggest })
  let optional = tsEntry.kindModifiers && tsEntry.kindModifiers.match(/\boptional\b/)
  let textEdit: TextEdit | null = null
  if (tsEntry.replacementSpan) {
    let { start, end } = tsEntry.replacementSpan
    if (start.line == end.line) {
      textEdit = {
        range: Range.create(start.line - 1, start.offset - 1, end.line - 1, end.offset - 1),
github neoclide / coc-tsserver / src / server / utils / completionItem.ts View on Github external
case PConst.Kind.primitiveType:
    case PConst.Kind.keyword:
      return CompletionItemKind.Keyword
    case PConst.Kind.const:
      return CompletionItemKind.Constant
    case PConst.Kind.let:
    case PConst.Kind.variable:
    case PConst.Kind.localVariable:
    case PConst.Kind.alias:
      return CompletionItemKind.Variable
    case PConst.Kind.memberVariable:
    case PConst.Kind.memberGetAccessor:
    case PConst.Kind.memberSetAccessor:
      return CompletionItemKind.Field
    case PConst.Kind.function:
      return CompletionItemKind.Function
    case PConst.Kind.memberFunction:
    case PConst.Kind.constructSignature:
    case PConst.Kind.callSignature:
    case PConst.Kind.indexSignature:
      return CompletionItemKind.Method
    case PConst.Kind.enum:
      return CompletionItemKind.Enum
    case PConst.Kind.module:
    case PConst.Kind.externalModuleName:
      return CompletionItemKind.Module
    case PConst.Kind.class:
    case PConst.Kind.type:
      return CompletionItemKind.Class
    case PConst.Kind.interface:
      return CompletionItemKind.Interface
    case PConst.Kind.warning:
github neoclide / coc.nvim / src / languages.ts View on Github external
private loadCompleteConfig(): void {
    let config = workspace.getConfiguration('coc.preferences')
    let suggest = workspace.getConfiguration('suggest')
    function getConfig(key, defaultValue: T): T {
      return config.get(key, suggest.get(key, defaultValue))
    }
    let labels = suggest.get<{ [key: string]: string }>('completionItemKindLabels', {})
    this.completionItemKindMap = new Map([
      [CompletionItemKind.Text, labels['text'] || 'v'],
      [CompletionItemKind.Method, labels['method'] || 'f'],
      [CompletionItemKind.Function, labels['function'] || 'f'],
      [CompletionItemKind.Constructor, typeof labels['constructor'] == 'function' ? 'f' : labels['con' + 'structor']],
      [CompletionItemKind.Field, labels['field'] || 'm'],
      [CompletionItemKind.Variable, labels['variable'] || 'v'],
      [CompletionItemKind.Class, labels['class'] || 'C'],
      [CompletionItemKind.Interface, labels['interface'] || 'I'],
      [CompletionItemKind.Module, labels['module'] || 'M'],
      [CompletionItemKind.Property, labels['property'] || 'm'],
      [CompletionItemKind.Unit, labels['unit'] || 'U'],
      [CompletionItemKind.Value, labels['value'] || 'v'],
      [CompletionItemKind.Enum, labels['enum'] || 'E'],
      [CompletionItemKind.Keyword, labels['keyword'] || 'k'],
      [CompletionItemKind.Snippet, labels['snippet'] || 'S'],
      [CompletionItemKind.Color, labels['color'] || 'v'],
      [CompletionItemKind.File, labels['file'] || 'F'],
      [CompletionItemKind.Reference, labels['reference'] || 'r'],
      [CompletionItemKind.Folder, labels['folder'] || 'F'],
github neoclide / coc.nvim / src / extensions / tsserver / utils / completionItem.ts View on Github external
case PConst.Kind.primitiveType:
    case PConst.Kind.keyword:
      return CompletionItemKind.Keyword
    case PConst.Kind.const:
      return CompletionItemKind.Constant
    case PConst.Kind.let:
    case PConst.Kind.variable:
    case PConst.Kind.localVariable:
    case PConst.Kind.alias:
      return CompletionItemKind.Variable
    case PConst.Kind.memberVariable:
    case PConst.Kind.memberGetAccessor:
    case PConst.Kind.memberSetAccessor:
      return CompletionItemKind.Field
    case PConst.Kind.function:
      return CompletionItemKind.Function
    case PConst.Kind.memberFunction:
    case PConst.Kind.constructSignature:
    case PConst.Kind.callSignature:
    case PConst.Kind.indexSignature:
      return CompletionItemKind.Method
    case PConst.Kind.enum:
      return CompletionItemKind.Enum
    case PConst.Kind.module:
    case PConst.Kind.externalModuleName:
      return CompletionItemKind.Module
    case PConst.Kind.class:
    case PConst.Kind.type:
      return CompletionItemKind.Class
    case PConst.Kind.interface:
      return CompletionItemKind.Interface
    case PConst.Kind.warning: