Skip to content

Commit 57fa648

Browse files
committed
support auto indentation in python microsoft#3754
1 parent 8e02408 commit 57fa648

7 files changed

Lines changed: 93 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch Extension",
6+
"type": "extensionHost",
7+
"request": "launch",
8+
"runtimeExecutable": "${execPath}",
9+
"args": [
10+
"--extensionDevelopmentPath=${workspaceRoot}"
11+
],
12+
"stopOnEntry": false,
13+
"sourceMaps": true,
14+
"outDir": "${workspaceRoot}/out",
15+
"preLaunchTask": "npm"
16+
}
17+
]
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Available variables which can be used inside of strings.
2+
// ${workspaceRoot}: the root folder of the team
3+
// ${file}: the current opened file
4+
// ${fileBasename}: the current opened file's basename
5+
// ${fileDirname}: the current opened file's dirname
6+
// ${fileExtname}: the current opened file's extension
7+
// ${cwd}: the current working directory of the spawned process
8+
9+
// A task runner that calls a custom npm script that compiles the extension.
10+
{
11+
"version": "0.1.0",
12+
13+
// we want to run npm
14+
"command": "npm",
15+
16+
// the command is a shell script
17+
"isShellCommand": true,
18+
19+
// show the output window only if unrecognized errors occur.
20+
"showOutput": "silent",
21+
22+
// we run the custom script "compile" as defined in package.json
23+
"args": ["run", "compile"],
24+
25+
// The tsc compiler is started in watching mode
26+
"isWatching": true,
27+
28+
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
29+
"problemMatcher": "$tsc-watch"
30+
}

extensions/python/.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/**

extensions/python/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "0.1.0",
44
"publisher": "vscode",
55
"engines": { "vscode": "*" },
6+
"activationEvents": ["onLanguage:python"],
7+
"main": "./out/pythonMain",
68
"contributes": {
79
"languages": [{
810
"id": "python",
@@ -19,5 +21,9 @@
1921
"scopeName": "source.regexp.python",
2022
"path": "./syntaxes/Regular Expressions (Python).tmLanguage"
2123
}]
24+
},
25+
"scripts": {
26+
"compile": "gulp compile-extension:python",
27+
"watch": "gulp watch-extension:python"
2228
}
2329
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
'use strict';
6+
import { ExtensionContext, languages, IndentAction } from 'vscode';
7+
8+
export function activate(context: ExtensionContext): any {
9+
languages.setLanguageConfiguration('python', {
10+
onEnterRules: [
11+
{
12+
beforeText: /^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,
13+
action: { indentAction: IndentAction.Indent }
14+
}
15+
]
16+
});
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/// <reference path='../../../../src/vs/vscode.d.ts'/>
7+
/// <reference path='../../../../src/typings/mocha.d.ts'/>
8+
/// <reference path='../../../../extensions/node.d.ts'/>
9+
/// <reference path='../../../../extensions/lib.core.d.ts'/>
10+
/// <reference path='../../../../extensions/declares.d.ts'/>

extensions/python/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"noLib": true,
4+
"target": "es5",
5+
"module": "commonjs",
6+
"outDir": "./out"
7+
},
8+
"exclude": [
9+
"node_modules"
10+
]
11+
}

0 commit comments

Comments
 (0)