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,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'/>