From 7039f3641ea1a37c7e26079680bb4286d8f14f0a Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 28 Jun 2016 23:29:37 +1000 Subject: [PATCH 1/5] replace settings variables in debugger config #8042 --- src/vs/base/common/parsers.ts | 8 ++++---- .../debug/node/debugConfigurationManager.ts | 9 +++++++++ .../parts/lib/node/settingsVariables.ts | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/vs/workbench/parts/lib/node/settingsVariables.ts diff --git a/src/vs/base/common/parsers.ts b/src/vs/base/common/parsers.ts index 9bcfa66446a..fb34ec93e7f 100644 --- a/src/vs/base/common/parsers.ts +++ b/src/vs/base/common/parsers.ts @@ -130,7 +130,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { public resolve(value: IStringDictionary>): IStringDictionary>; public resolve(value: any): any { if (Types.isString(value)) { - return this.__resolveString(value); + return this.resolveString(value); } else if (Types.isArray(value)) { return this.__resolveArray(value); } else if (Types.isObject(value)) { @@ -143,7 +143,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { resolveAny(value: T): T; resolveAny(value: any): any { if (Types.isString(value)) { - return this.__resolveString(value); + return this.resolveString(value); } else if (Types.isArray(value)) { return this.__resolveAnyArray(value); } else if (Types.isObject(value)) { @@ -153,7 +153,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { return value; } - private __resolveString(value: string): string { + protected resolveString(value: string): string { let regexp = /\$\{(.*?)\}/g; return value.replace(regexp, (match: string, name: string) => { let newValue = (this)[name]; @@ -185,7 +185,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { } private __resolveArray(value: string[]): string[] { - return value.map(s => this.__resolveString(s)); + return value.map(s => this.resolveString(s)); } private __resolveAnyArray(value: T[]): T[]; diff --git a/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts index 6d2be639db5..7ea04864882 100644 --- a/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts @@ -30,6 +30,7 @@ import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; +import { SettingsVariables } from 'vs/workbench/parts/lib/node/settingsVariables'; // debuggers extension point @@ -155,6 +156,7 @@ export class ConfigurationManager implements debug.IConfigurationManager { public configuration: debug.IConfig; private systemVariables: SystemVariables; + private settingsVariables: SettingsVariables; private adapters: Adapter[]; private allModeIdsForBreakpoints: { [key: string]: boolean }; private _onDidConfigurationChange: Emitter; @@ -171,6 +173,7 @@ export class ConfigurationManager implements debug.IConfigurationManager { ) { this._onDidConfigurationChange = new Emitter(); this.systemVariables = this.contextService.getWorkspace() ? new SystemVariables(this.editorService, this.contextService) : null; + this.settingsVariables = new SettingsVariables(this.configurationService.getConfiguration()); this.setConfiguration(configName); this.adapters = []; this.registerListeners(); @@ -326,6 +329,12 @@ export class ConfigurationManager implements debug.IConfigurationManager { this.configuration[key] = this.systemVariables.resolveAny(this.configuration[key]); }); } + // massage configuration attributes - substitute settings (from settings.json) variables. + if (this.systemVariables) { + Object.keys(this.configuration).forEach(key => { + this.configuration[key] = this.settingsVariables.resolveAny(this.configuration[key]); + }); + } } }).then(() => this._onDidConfigurationChange.fire(this.configurationName)); } diff --git a/src/vs/workbench/parts/lib/node/settingsVariables.ts b/src/vs/workbench/parts/lib/node/settingsVariables.ts new file mode 100644 index 00000000000..b593f749952 --- /dev/null +++ b/src/vs/workbench/parts/lib/node/settingsVariables.ts @@ -0,0 +1,20 @@ +/*--------------------------------------------------------------------------------------------- + * 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 { AbstractSystemVariables } from 'vs/base/common/parsers'; + +export class SettingsVariables extends AbstractSystemVariables { + constructor(private configuration: any) { + super(); + } + + protected resolveString(value: string): string { + let regexp = /\${settings.(.+)}/g; + return value.replace(regexp, (match: string, name: string) => { + return new Function('_', 'return _.' + name)(this.configuration); + }); + } +} \ No newline at end of file From 9baff519c4e818f66df90a3fdbd70008aaddcd43 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 30 Jun 2016 11:44:50 +1000 Subject: [PATCH 2/5] added ability to resolve varaibles in configuration settings (variables such as ${workspaceRoot} and ${env...} environment variables --- src/vs/workbench/api/node/extHost.api.impl.ts | 9 +++++---- src/vs/workbench/api/node/extHostConfiguration.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 22d4183a505..27b5dfe6b01 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -39,6 +39,7 @@ import vscode = require('vscode'); import * as paths from 'vs/base/common/paths'; import {ITelemetryService, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry'; import {MainContext, ExtHostContext, InstanceCollection} from './extHostProtocol'; +import {SystemVariables} from "vs/workbench/parts/lib/node/systemVariables"; /** * This class implements the API described in vscode.d.ts, @@ -93,11 +94,12 @@ export class ExtHostAPIImplementation { ) { // Addressable instances const col = new InstanceCollection(); - + const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined; const extHostDocuments = col.define(ExtHostContext.ExtHostDocuments).set(new ExtHostDocuments(threadService)); const extHostEditors = col.define(ExtHostContext.ExtHostEditors).set(new ExtHostEditors(threadService, extHostDocuments)); const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set(new ExtHostCommands(threadService, extHostEditors)); - const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set(new ExtHostConfiguration()); + let systemVariables = new SystemVariables(null, null, URI.file(workspacePath)); + const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set(new ExtHostConfiguration(systemVariables)); const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set(new ExtHostDiagnostics(threadService)); const languageFeatures = col.define(ExtHostContext.ExtHostLanguageFeatures).set(new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostDiagnostics)); const extHostFileSystemEvent = col.define(ExtHostContext.ExtHostFileSystemEventService).set(new ExtHostFileSystemEventService()); @@ -115,7 +117,6 @@ export class ExtHostAPIImplementation { const extHostMessageService = new ExtHostMessageService(threadService); const extHostStatusBar = new ExtHostStatusBar(threadService); const extHostOutputService = new ExtHostOutputService(threadService); - const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined; const extHostWorkspace = new ExtHostWorkspace(threadService, workspacePath); const languages = new ExtHostLanguages(threadService); @@ -313,7 +314,7 @@ export class ExtHostAPIImplementation { return extHostConfiguration.onDidChangeConfiguration(listener, thisArgs, disposables); }, getConfiguration: (section?: string):vscode.WorkspaceConfiguration => { - return extHostConfiguration.getConfiguration(section); + return extHostConfiguration.getConfiguration(section, true); } }); diff --git a/src/vs/workbench/api/node/extHostConfiguration.ts b/src/vs/workbench/api/node/extHostConfiguration.ts index 2f79028fc41..805e61b60b0 100644 --- a/src/vs/workbench/api/node/extHostConfiguration.ts +++ b/src/vs/workbench/api/node/extHostConfiguration.ts @@ -8,6 +8,7 @@ import {clone} from 'vs/base/common/objects'; import {illegalState} from 'vs/base/common/errors'; import Event, {Emitter} from 'vs/base/common/event'; import {WorkspaceConfiguration} from 'vscode'; +import {SystemVariables} from "vs/workbench/parts/lib/node/systemVariables"; export class ExtHostConfiguration { @@ -15,7 +16,7 @@ export class ExtHostConfiguration { private _hasConfig: boolean; private _onDidChangeConfiguration: Emitter; - constructor() { + constructor(private systemVariables: SystemVariables) { this._onDidChangeConfiguration = new Emitter(); } @@ -29,7 +30,7 @@ export class ExtHostConfiguration { this._onDidChangeConfiguration.fire(undefined); } - public getConfiguration(section?: string): WorkspaceConfiguration { + public getConfiguration(section?: string, resolve: boolean = false): WorkspaceConfiguration { if (!this._hasConfig) { throw illegalState('missing config'); } @@ -49,14 +50,15 @@ export class ExtHostConfiguration { result.has = function(key: string): boolean { return typeof ExtHostConfiguration._lookUp(key, config) !== 'undefined'; }; + let that = this; result.get = function (key: string, defaultValue?: T): T { let result = ExtHostConfiguration._lookUp(key, config); if (typeof result === 'undefined') { result = defaultValue; } - return result; + return resolve ? that.systemVariables.resolveAny(result) : result; }; - return result; + return resolve ? that.systemVariables.resolveAny(result) : result; } private static _lookUp(section: string, config: any) { From 75ac222cdfc456773c4f7026885ebce0729b8f05 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 30 Jun 2016 11:53:17 +1000 Subject: [PATCH 3/5] Revert "added ability to resolve varaibles in configuration settings (variables such as ${workspaceRoot} and ${env...} environment variables" This reverts commit 9baff519c4e818f66df90a3fdbd70008aaddcd43. --- src/vs/workbench/api/node/extHost.api.impl.ts | 9 ++++----- src/vs/workbench/api/node/extHostConfiguration.ts | 10 ++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 27b5dfe6b01..22d4183a505 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -39,7 +39,6 @@ import vscode = require('vscode'); import * as paths from 'vs/base/common/paths'; import {ITelemetryService, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry'; import {MainContext, ExtHostContext, InstanceCollection} from './extHostProtocol'; -import {SystemVariables} from "vs/workbench/parts/lib/node/systemVariables"; /** * This class implements the API described in vscode.d.ts, @@ -94,12 +93,11 @@ export class ExtHostAPIImplementation { ) { // Addressable instances const col = new InstanceCollection(); - const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined; + const extHostDocuments = col.define(ExtHostContext.ExtHostDocuments).set(new ExtHostDocuments(threadService)); const extHostEditors = col.define(ExtHostContext.ExtHostEditors).set(new ExtHostEditors(threadService, extHostDocuments)); const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set(new ExtHostCommands(threadService, extHostEditors)); - let systemVariables = new SystemVariables(null, null, URI.file(workspacePath)); - const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set(new ExtHostConfiguration(systemVariables)); + const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set(new ExtHostConfiguration()); const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set(new ExtHostDiagnostics(threadService)); const languageFeatures = col.define(ExtHostContext.ExtHostLanguageFeatures).set(new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostDiagnostics)); const extHostFileSystemEvent = col.define(ExtHostContext.ExtHostFileSystemEventService).set(new ExtHostFileSystemEventService()); @@ -117,6 +115,7 @@ export class ExtHostAPIImplementation { const extHostMessageService = new ExtHostMessageService(threadService); const extHostStatusBar = new ExtHostStatusBar(threadService); const extHostOutputService = new ExtHostOutputService(threadService); + const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined; const extHostWorkspace = new ExtHostWorkspace(threadService, workspacePath); const languages = new ExtHostLanguages(threadService); @@ -314,7 +313,7 @@ export class ExtHostAPIImplementation { return extHostConfiguration.onDidChangeConfiguration(listener, thisArgs, disposables); }, getConfiguration: (section?: string):vscode.WorkspaceConfiguration => { - return extHostConfiguration.getConfiguration(section, true); + return extHostConfiguration.getConfiguration(section); } }); diff --git a/src/vs/workbench/api/node/extHostConfiguration.ts b/src/vs/workbench/api/node/extHostConfiguration.ts index 805e61b60b0..2f79028fc41 100644 --- a/src/vs/workbench/api/node/extHostConfiguration.ts +++ b/src/vs/workbench/api/node/extHostConfiguration.ts @@ -8,7 +8,6 @@ import {clone} from 'vs/base/common/objects'; import {illegalState} from 'vs/base/common/errors'; import Event, {Emitter} from 'vs/base/common/event'; import {WorkspaceConfiguration} from 'vscode'; -import {SystemVariables} from "vs/workbench/parts/lib/node/systemVariables"; export class ExtHostConfiguration { @@ -16,7 +15,7 @@ export class ExtHostConfiguration { private _hasConfig: boolean; private _onDidChangeConfiguration: Emitter; - constructor(private systemVariables: SystemVariables) { + constructor() { this._onDidChangeConfiguration = new Emitter(); } @@ -30,7 +29,7 @@ export class ExtHostConfiguration { this._onDidChangeConfiguration.fire(undefined); } - public getConfiguration(section?: string, resolve: boolean = false): WorkspaceConfiguration { + public getConfiguration(section?: string): WorkspaceConfiguration { if (!this._hasConfig) { throw illegalState('missing config'); } @@ -50,15 +49,14 @@ export class ExtHostConfiguration { result.has = function(key: string): boolean { return typeof ExtHostConfiguration._lookUp(key, config) !== 'undefined'; }; - let that = this; result.get = function (key: string, defaultValue?: T): T { let result = ExtHostConfiguration._lookUp(key, config); if (typeof result === 'undefined') { result = defaultValue; } - return resolve ? that.systemVariables.resolveAny(result) : result; + return result; }; - return resolve ? that.systemVariables.resolveAny(result) : result; + return result; } private static _lookUp(section: string, config: any) { From fa788ba6a0a9b72b93bc2bc30cb652c53c4c957d Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 5 Jul 2016 18:01:17 +1000 Subject: [PATCH 4/5] Revert "replace settings variables in debugger config #8042" This reverts commit 7039f3641ea1a37c7e26079680bb4286d8f14f0a. --- src/vs/base/common/parsers.ts | 8 ++++---- .../debug/node/debugConfigurationManager.ts | 9 --------- .../parts/lib/node/settingsVariables.ts | 20 ------------------- 3 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 src/vs/workbench/parts/lib/node/settingsVariables.ts diff --git a/src/vs/base/common/parsers.ts b/src/vs/base/common/parsers.ts index fb34ec93e7f..9bcfa66446a 100644 --- a/src/vs/base/common/parsers.ts +++ b/src/vs/base/common/parsers.ts @@ -130,7 +130,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { public resolve(value: IStringDictionary>): IStringDictionary>; public resolve(value: any): any { if (Types.isString(value)) { - return this.resolveString(value); + return this.__resolveString(value); } else if (Types.isArray(value)) { return this.__resolveArray(value); } else if (Types.isObject(value)) { @@ -143,7 +143,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { resolveAny(value: T): T; resolveAny(value: any): any { if (Types.isString(value)) { - return this.resolveString(value); + return this.__resolveString(value); } else if (Types.isArray(value)) { return this.__resolveAnyArray(value); } else if (Types.isObject(value)) { @@ -153,7 +153,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { return value; } - protected resolveString(value: string): string { + private __resolveString(value: string): string { let regexp = /\$\{(.*?)\}/g; return value.replace(regexp, (match: string, name: string) => { let newValue = (this)[name]; @@ -185,7 +185,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { } private __resolveArray(value: string[]): string[] { - return value.map(s => this.resolveString(s)); + return value.map(s => this.__resolveString(s)); } private __resolveAnyArray(value: T[]): T[]; diff --git a/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts index 7ea04864882..6d2be639db5 100644 --- a/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts @@ -30,7 +30,6 @@ import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; -import { SettingsVariables } from 'vs/workbench/parts/lib/node/settingsVariables'; // debuggers extension point @@ -156,7 +155,6 @@ export class ConfigurationManager implements debug.IConfigurationManager { public configuration: debug.IConfig; private systemVariables: SystemVariables; - private settingsVariables: SettingsVariables; private adapters: Adapter[]; private allModeIdsForBreakpoints: { [key: string]: boolean }; private _onDidConfigurationChange: Emitter; @@ -173,7 +171,6 @@ export class ConfigurationManager implements debug.IConfigurationManager { ) { this._onDidConfigurationChange = new Emitter(); this.systemVariables = this.contextService.getWorkspace() ? new SystemVariables(this.editorService, this.contextService) : null; - this.settingsVariables = new SettingsVariables(this.configurationService.getConfiguration()); this.setConfiguration(configName); this.adapters = []; this.registerListeners(); @@ -329,12 +326,6 @@ export class ConfigurationManager implements debug.IConfigurationManager { this.configuration[key] = this.systemVariables.resolveAny(this.configuration[key]); }); } - // massage configuration attributes - substitute settings (from settings.json) variables. - if (this.systemVariables) { - Object.keys(this.configuration).forEach(key => { - this.configuration[key] = this.settingsVariables.resolveAny(this.configuration[key]); - }); - } } }).then(() => this._onDidConfigurationChange.fire(this.configurationName)); } diff --git a/src/vs/workbench/parts/lib/node/settingsVariables.ts b/src/vs/workbench/parts/lib/node/settingsVariables.ts deleted file mode 100644 index b593f749952..00000000000 --- a/src/vs/workbench/parts/lib/node/settingsVariables.ts +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * 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 { AbstractSystemVariables } from 'vs/base/common/parsers'; - -export class SettingsVariables extends AbstractSystemVariables { - constructor(private configuration: any) { - super(); - } - - protected resolveString(value: string): string { - let regexp = /\${settings.(.+)}/g; - return value.replace(regexp, (match: string, name: string) => { - return new Function('_', 'return _.' + name)(this.configuration); - }); - } -} \ No newline at end of file From 57fa648285cfc59e3a7ebb598f0da67e6e6b497b Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Fri, 15 Jul 2016 12:24:31 +1000 Subject: [PATCH 5/5] support auto indentation in python #3754 --- extensions/python/.vscode/launch.json | 18 ++++++++++++++++ extensions/python/.vscode/tasks.json | 30 ++++++++++++++++++++++++++ extensions/python/.vscodeignore | 1 + extensions/python/package.json | 6 ++++++ extensions/python/src/pythonMain.ts | 17 +++++++++++++++ extensions/python/src/typings/ref.d.ts | 10 +++++++++ extensions/python/tsconfig.json | 11 ++++++++++ 7 files changed, 93 insertions(+) create mode 100644 extensions/python/.vscode/launch.json create mode 100644 extensions/python/.vscode/tasks.json create mode 100644 extensions/python/.vscodeignore create mode 100644 extensions/python/src/pythonMain.ts create mode 100644 extensions/python/src/typings/ref.d.ts create mode 100644 extensions/python/tsconfig.json diff --git a/extensions/python/.vscode/launch.json b/extensions/python/.vscode/launch.json new file mode 100644 index 00000000000..476551bebae --- /dev/null +++ b/extensions/python/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}" + ], + "stopOnEntry": false, + "sourceMaps": true, + "outDir": "${workspaceRoot}/out", + "preLaunchTask": "npm" + } + ] +} \ No newline at end of file diff --git a/extensions/python/.vscode/tasks.json b/extensions/python/.vscode/tasks.json new file mode 100644 index 00000000000..a132a04214d --- /dev/null +++ b/extensions/python/.vscode/tasks.json @@ -0,0 +1,30 @@ +// Available variables which can be used inside of strings. +// ${workspaceRoot}: the root folder of the team +// ${file}: the current opened file +// ${fileBasename}: the current opened file's basename +// ${fileDirname}: the current opened file's dirname +// ${fileExtname}: the current opened file's extension +// ${cwd}: the current working directory of the spawned process + +// A task runner that calls a custom npm script that compiles the extension. +{ + "version": "0.1.0", + + // we want to run npm + "command": "npm", + + // the command is a shell script + "isShellCommand": true, + + // show the output window only if unrecognized errors occur. + "showOutput": "silent", + + // we run the custom script "compile" as defined in package.json + "args": ["run", "compile"], + + // The tsc compiler is started in watching mode + "isWatching": true, + + // use the standard tsc in watch mode problem matcher to find compile problems in the output. + "problemMatcher": "$tsc-watch" +} \ No newline at end of file diff --git a/extensions/python/.vscodeignore b/extensions/python/.vscodeignore new file mode 100644 index 00000000000..47cf365a078 --- /dev/null +++ b/extensions/python/.vscodeignore @@ -0,0 +1 @@ +test/** diff --git a/extensions/python/package.json b/extensions/python/package.json index 688862a4717..485620ef4a9 100644 --- a/extensions/python/package.json +++ b/extensions/python/package.json @@ -3,6 +3,8 @@ "version": "0.1.0", "publisher": "vscode", "engines": { "vscode": "*" }, + "activationEvents": ["onLanguage:python"], + "main": "./out/pythonMain", "contributes": { "languages": [{ "id": "python", @@ -19,5 +21,9 @@ "scopeName": "source.regexp.python", "path": "./syntaxes/Regular Expressions (Python).tmLanguage" }] + }, + "scripts": { + "compile": "gulp compile-extension:python", + "watch": "gulp watch-extension:python" } } diff --git a/extensions/python/src/pythonMain.ts b/extensions/python/src/pythonMain.ts new file mode 100644 index 00000000000..b96d2a46148 --- /dev/null +++ b/extensions/python/src/pythonMain.ts @@ -0,0 +1,17 @@ +/*--------------------------------------------------------------------------------------------- + * 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 { ExtensionContext, languages, IndentAction } from 'vscode'; + +export function activate(context: ExtensionContext): any { + languages.setLanguageConfiguration('python', { + onEnterRules: [ + { + beforeText: /^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/, + action: { indentAction: IndentAction.Indent } + } + ] + }); +} \ No newline at end of file diff --git a/extensions/python/src/typings/ref.d.ts b/extensions/python/src/typings/ref.d.ts new file mode 100644 index 00000000000..7f4835e6747 --- /dev/null +++ b/extensions/python/src/typings/ref.d.ts @@ -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. + *--------------------------------------------------------------------------------------------*/ + +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/extensions/python/tsconfig.json b/extensions/python/tsconfig.json new file mode 100644 index 00000000000..8cb16334377 --- /dev/null +++ b/extensions/python/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "noLib": true, + "target": "es5", + "module": "commonjs", + "outDir": "./out" + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file