Skip to content

Commit

Permalink
#38 allow user to customize python settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Almenon committed Mar 6, 2018
1 parent fcd1408 commit 8f2dd16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
"type": "number",
"default": 70,
"description": "strings over X characters are truncated with an option to expand"
},
"AREPL.pythonPath": {
"type": "string",
"default": null,
"description": "By default python is used if windows or python3 otherwise. Changing this setting not reccomended"
},
"AREPL.pythonOptions": {
"type": "array",
"default": ["-u"],
"description": "default -u to see prints in real-time. See https://docs.python.org/3/using/cmdline.html#miscellaneous-options for other options. Changing this setting not reccomended"
}
}
},
Expand Down
19 changes: 12 additions & 7 deletions src/PreviewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,29 @@ export default class PreviewManager {
status: vscode.StatusBarItem;

constructor(context: vscode.ExtensionContext) {

const settings = vscode.workspace.getConfiguration('AREPL');

this.pythonPreviewContentProvider = new HtmlDocumentContentProvider(context);
this.pythonEvaluator = new PythonEvaluator()
this.pythonEditor = vscode.window.activeTextEditor.document;
this.status = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
this.status.text = "Running python..."
this.status.tooltip = "AREPL is currently running your python file. Close the AREPL preview to stop"

const settings = vscode.workspace.getConfiguration('AREPL');



vscode.workspace.registerTextDocumentContentProvider(HtmlDocumentContentProvider.scheme, this.pythonPreviewContentProvider);

/////////////////////////////////////////////////////////
// python
/////////////////////////////////////////////////////////
let self:PreviewManager = this;
let pythonPath = settings.get<string>('pythonPath')
let pythonOptions = settings.get<string[]>('pythonOptions')

this.pythonEvaluator = new PythonEvaluator(pythonPath, pythonOptions)

let debounce = settings.get<number>('delay');
let restartExtraDebounce = settings.get<number>('restartDelay');

this.pythonEvaluator.startPython()
this.pythonEvaluator.pyshell.childProcess.on('error', err => {
let error:any = err; //typescript complains about type for some reason so defining to any
Expand Down

0 comments on commit 8f2dd16

Please sign in to comment.