add configuration-editing extension that proposes commands in keybindings.json, #7185

This commit is contained in:
Johannes Rieken 2016-06-03 15:40:36 +02:00
parent a25c0caae0
commit 9afa1307d4
4 changed files with 77 additions and 0 deletions

View file

@ -0,0 +1,9 @@
// ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS:
[{
"name": "Microsoft/node-jsonc-parser",
"version": "0.0.0",
"license": "MIT",
"isProd": true,
"repositoryURL": "https://github.com/Microsoft/node-jsonc-parser"
}]

View file

@ -0,0 +1,25 @@
{
"name": "configuration-editing",
"version": "0.0.1",
"publisher": "vscode",
"engines": {
"vscode": "^1.0.0"
},
"categories": [
"Languages", "Other"
],
"activationEvents": [
"onLanguage:json"
],
"main": "./out/extension",
"scripts": {
"compile": "gulp compile-extension:configuration-editing",
"watch": "gulp watch-extension:configuration-editing"
},
"devDependencies": {
"vscode": "^0.11.0"
},
"dependencies": {
"jsonc-parser": "^0.2.1"
}
}

View file

@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as vscode from 'vscode';
import {getLocation} from 'jsonc-parser';
export function activate(context) {
const commands = vscode.commands.getCommands(true);
//keybindings.json command-suggestions
const disposable = vscode.languages.registerCompletionItemProvider({ pattern: '**/keybindings.json' }, {
provideCompletionItems(document, position, token) {
const location = getLocation(document.getText(), document.offsetAt(position));
if (location.path[1] === 'command') {
return commands.then(ids => {
return ids.map(id => {
let item = new vscode.CompletionItem(id);
item.kind = vscode.CompletionItemKind.Value;
return item;
});
});
}
}
});
context.subscriptions.push(disposable);
}

View file

@ -0,0 +1,10 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../extensions/node.d.ts'/>
/// <reference path='../../../../extensions/lib.core.d.ts'/>
/// <reference path='../../../../extensions/declares.d.ts'/>