mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
add configuration-editing extension that proposes commands in keybindings.json, #7185
This commit is contained in:
parent
a25c0caae0
commit
9afa1307d4
9
extensions/configuration-editing/OSSREADME.json
Normal file
9
extensions/configuration-editing/OSSREADME.json
Normal 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"
|
||||
}]
|
25
extensions/configuration-editing/package.json
Normal file
25
extensions/configuration-editing/package.json
Normal 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"
|
||||
}
|
||||
}
|
33
extensions/configuration-editing/src/extension.ts
Normal file
33
extensions/configuration-editing/src/extension.ts
Normal 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);
|
||||
}
|
10
extensions/configuration-editing/src/typings/ref.d.ts
vendored
Normal file
10
extensions/configuration-editing/src/typings/ref.d.ts
vendored
Normal 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'/>
|
Loading…
Reference in a new issue