How to use the vscode-languageserver.CompletionItemKind.Variable function in vscode-languageserver

To help you get started, we’ve selected a few vscode-languageserver 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 GameMakerDiscord / gml-tools-langserver / src / completion.ts View on Github external
const getAll = ourWords[1] == undefined;
        const rx = new RegExp('^' + ourWords[1]);

        // Idiotic Macros
        if (this.reference.macroExists(ourWords[0])) {
            const macroVal = this.reference.macroGetMacroValue(ourWords[0]);
            if (macroVal) ourWords[0] = macroVal;
        }

        // Variables
        const variableList = this.reference.instGetAllInsts(ourWords[0]);
        for (const thisVar of variableList) {
            if (rx.test(thisVar) || getAll) {
                workingArray.push({
                    label: thisVar,
                    kind: CompletionItemKind.Variable,
                    textEdit: {
                        newText: thisVar,
                        range: Range.create(params.position, params.position)
                    }
                });
            }
        }

        // Enums
        const enumMembers = this.reference.enumGetMemberNames(ourWords[0]);
        if (enumMembers) {
            for (const enumMember of enumMembers) {
                if (rx.test(enumMember) || getAll) {
                    workingArray.push({
                        label: enumMember,
                        kind: CompletionItemKind.EnumMember,
github HvyIndustries / crane / server / src / suggestionBuilder.ts View on Github external
// Find out which trait we're in
            for (var i = 0, l = this.currentFileNode.traits.length; i < l; i++) {
                let traitNode = this.currentFileNode.traits[i];

                funcs = funcs.concat(traitNode.methods.filter(item => {
                    return this.withinBlock(item);
                }));
            }

            if (funcs.length > 0) {
                if (options.localVariables) {
                    for (var i = 0, l:number = funcs[0].scopeVariables.length; i < l; i++) {
                        let item = funcs[0].scopeVariables[i];

                        toReturn.push({ label: item.name, kind: CompletionItemKind.Variable, detail: `(variable) : ${item.type}` });
                    }
                }

                if (options.parameters) {
                    for (var i = 0, l:number = funcs[0].params.length; i < l; i++) {
                        let item = funcs[0].params[i];

                        toReturn.push({ label: item.name, kind: CompletionItemKind.Property, detail: `(parameter) : ${item.type}` });
                    }
                }

                if (options.globalVariables) {
                    for (var i = 0, l:number = funcs[0].globalVariables.length; i < l; i++) {
                        let item = funcs[0].globalVariables[i];

                        // TODO -- look up original variable to find the type
github rcjsuen / dockerfile-language-server-nodejs / src / dockerAssist.ts View on Github external
private createVariableCompletionItem(text: string, prefixLength: number, offset: number, brace: boolean, documentation: string): CompletionItem {
		text = brace ? "${" + text + '}' : '$' + text
		return {
			textEdit: this.createTextEdit(prefixLength, offset, text),
			label: text,
			kind: CompletionItemKind.Variable,
			insertTextFormat: InsertTextFormat.PlainText,
			documentation: documentation
		};
	}
github microsoft / pyright / server / src / languageService / completionProvider.ts View on Github external
argNameMap.forEach(argName => {
            const similarity = StringUtils.computeCompletionSimilarity(priorWord, argName);

            if (similarity > similarityLimit) {
                const completionItem = CompletionItem.create(argName);
                completionItem.kind = CompletionItemKind.Variable;

                const completionItemData: CompletionItemData = {
                    workspacePath: this._workspacePath,
                    filePath: this._filePath,
                    position: this._position
                };
                completionItem.data = completionItemData;
                completionItem.sortText = this._makeSortText(SortCategory.NamedParameter, argName);

                completionList.items.push(completionItem);
            }
        });
    }
github iamcco / vim-language-server / src / server / buffer.ts View on Github external
.map((name) => {
        const list: IIdentifier[] = items[name];
        return {
          label: name,
          kind: CompletionItemKind.Variable,
          sortText,
          documentation: "User defined variable",
          insertText: name,
          insertTextFormat: InsertTextFormat.PlainText,
          data: list || [],
        };
      });
  }
github mikrovvelle / mlxprs / server / serverTools.ts View on Github external
}

function buildFullFunctionSignature(docObject: MarkLogicFnDocsObject): string {
    let neededParams: MarkLogicParamsObject[] = docObject.params.filter(p => {return p.optional !== true});
    let optionParams: MarkLogicParamsObject[] = docObject.params.filter(p => {return p.optional === true});
    let neededParamsString = neededParams.map(p => {return  '$'+p.name+' as '+p.type    }).join(",\n\t");
    let optionParamsString = optionParams.map(p => {return '[$'+p.name+' as '+p.type+']'}).join(",\n\t");
    let middleComma = ''; if (neededParams.length > 0 && optionParams.length > 0) middleComma = ",\n\t";
    let nothing: string = docObject.params.length ? "\n\t" : "";
    return `${docObject.prefix}:${docObject.name}(${nothing}${neededParamsString}${middleComma}${optionParamsString})
    as ${docObject.return}`
}

let xqToVscCompletions: {[key:string]: CompletionItemKind} = {
    "function": CompletionItemKind.Function,
    "Let binding": CompletionItemKind.Variable,
    "Window variable": CompletionItemKind.Variable,
    "Local variable": CompletionItemKind.Variable,
    "Function parameter": CompletionItemKind.Variable,
    "prefix": CompletionItemKind.Class
}

export {
    allMlFunctions, allMlNamespaces
}
github Dreae / sourcepawn-vscode / server / src / completions.ts View on Github external
detail: this.description
        };
    }

    get_signature(): SignatureInformation {
        return {
            label: this.detail,
            documentation: this.description,
            parameters: this.params
        };
    }
}

export class DefineCompletion implements Completion {
    name: string;
    kind = CompletionItemKind.Variable;

    constructor(name: string) {
        this.name = name;
    }

    to_completion_item(): CompletionItem {
        return {
            label: this.name,
            kind: this.kind,
        };
    }

    get_signature(): SignatureInformation {
        return undefined;
    }
}
github marko-js / language-server / server / src / util-old / javascript.ts View on Github external
function convertKind(kind: ts.ScriptElementKind): CompletionItemKind {
  switch (kind) {
    case "primitive type":
    case "keyword":
      return CompletionItemKind.Keyword;
    case "var":
    case "local var":
      return CompletionItemKind.Variable;
    case "property":
    case "getter":
    case "setter":
      return CompletionItemKind.Field;
    case "function":
    case "method":
    case "construct":
    case "call":
    case "index":
      return CompletionItemKind.Function;
    case "enum":
      return CompletionItemKind.Enum;
    case "module":
      return CompletionItemKind.Module;
    case "class":
      return CompletionItemKind.Class;
github mikrovvelle / mlxprs / server / serverTools.ts View on Github external
function buildFullFunctionSignature(docObject: MarkLogicFnDocsObject): string {
    let neededParams: MarkLogicParamsObject[] = docObject.params.filter(p => {return p.optional !== true});
    let optionParams: MarkLogicParamsObject[] = docObject.params.filter(p => {return p.optional === true});
    let neededParamsString = neededParams.map(p => {return  '$'+p.name+' as '+p.type    }).join(",\n\t");
    let optionParamsString = optionParams.map(p => {return '[$'+p.name+' as '+p.type+']'}).join(",\n\t");
    let middleComma = ''; if (neededParams.length > 0 && optionParams.length > 0) middleComma = ",\n\t";
    let nothing: string = docObject.params.length ? "\n\t" : "";
    return `${docObject.prefix}:${docObject.name}(${nothing}${neededParamsString}${middleComma}${optionParamsString})
    as ${docObject.return}`
}

let xqToVscCompletions: {[key:string]: CompletionItemKind} = {
    "function": CompletionItemKind.Function,
    "Let binding": CompletionItemKind.Variable,
    "Window variable": CompletionItemKind.Variable,
    "Local variable": CompletionItemKind.Variable,
    "Function parameter": CompletionItemKind.Variable,
    "prefix": CompletionItemKind.Class
}

export {
    allMlFunctions, allMlNamespaces
}
github kube / vscode-clang-complete / server / src / ClangCompletionItem.ts View on Github external
private getItemKind(type: string): CompletionItemKind {
    if (type.match(/.*\(.*\)/)) {
      return CompletionItemKind.Function
    }
    else if (type.match(/^enum /)) {
      return CompletionItemKind.Enum
    }
    else if (type.match(/^[^ ()*]+$/)) {
      return CompletionItemKind.Keyword
    }
    else {
      return CompletionItemKind.Variable
    }
  }