Skip to content

Commit

Permalink
add configuration-editing extension that proposes commands in keybind…
Browse files Browse the repository at this point in the history
…ings.json, #7185
  • Loading branch information
jrieken authored and aeschli committed Jun 6, 2016
1 parent 0fe5631 commit 390db42
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
9 changes: 9 additions & 0 deletions extensions/configuration-editing/OSSREADME.json
Original file line number Diff line number Diff line change
@@ -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"
}]
25 changes: 25 additions & 0 deletions extensions/configuration-editing/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
33 changes: 33 additions & 0 deletions extensions/configuration-editing/src/extension.ts
Original file line number Diff line number Diff line change
@@ -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);
}
10 changes: 10 additions & 0 deletions extensions/configuration-editing/src/typings/ref.d.ts
Original file line number Diff line number Diff line change
@@ -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'/>

0 comments on commit 390db42

Please sign in to comment.