mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
add configuration-editing extension that proposes commands in keybindings.json, #7185
This commit is contained in:
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'/>
|
||||
Reference in New Issue
Block a user