From 698ba4e35d78f685dec07b1bf967be6bafc35193 Mon Sep 17 00:00:00 2001 From: Andrii Yurchuk Date: Wed, 2 Sep 2020 17:12:31 +0200 Subject: [PATCH] Allow hiding Python interpreter name in status bar Adds a new option `python.hideInterpreterName` (`false` by default), which, if set to `true`, will hide the selected Python interpreter name (something like `Python 3.8.5 64-bit ('python-3.8.5': venv)`) in the status bar. If an interpreter was not found, the text `No Python Interpreter` will still be displayed regardless of the setting of `python.hideInterpreterName`. --- Readme.md | 1 + package.json | 6 ++++++ src/common/configSettings.ts | 2 ++ src/common/types.ts | 1 + src/interpreter/display/index.ts | 10 +++++++++- 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index f0f3036..74d1643 100644 --- a/Readme.md +++ b/Readme.md @@ -80,6 +80,7 @@ Except from `test`, `debug` and `datascience` features of [vscode-python](https: - `python.autoComplete.showAdvancedMembers`:Controls appearance of methods with double underscores in the completion list., default: `true` - `python.autoComplete.typeshedPaths`:Specifies paths to local typeshed repository clone(s) for the Python language server., default: `[]` - `python.autoUpdateLanguageServer`:Automatically update the language server., default: `true` +- `python.hideInterpreterName`:Hide Python interpreter name in status bar., default: `false` - `python.disableInstallationCheck`:Whether to check if Python is installed (also warn when using the macOS-installed Python)., default: `false` - `python.envFile`:Absolute path to a file containing environment variable definitions., default: `"${workspaceFolder}/.env"` - `python.trace.server`:Trace level of tsserver, default: `"off"` diff --git a/package.json b/package.json index 4c2108d..29e519e 100644 --- a/package.json +++ b/package.json @@ -181,6 +181,12 @@ "description": "Automatically update the language server.", "scope": "application" }, + "python.hideInterpreterName": { + "type": "boolean", + "default": false, + "description": "Hide interpreter name in status bar.", + "scope": "application" + }, "python.disableInstallationCheck": { "type": "boolean", "default": false, diff --git a/src/common/configSettings.ts b/src/common/configSettings.ts index 0cffa24..1031edb 100644 --- a/src/common/configSettings.ts +++ b/src/common/configSettings.ts @@ -43,6 +43,7 @@ export class PythonSettings implements IPythonSettings { public analysis!: IAnalysisSettings public autoUpdateLanguageServer = true public datascience!: IDataScienceSettings + public hideInterpreterName = false protected readonly changed = new Emitter() private workspaceRoot: Uri @@ -147,6 +148,7 @@ export class PythonSettings implements IPythonSettings { this.downloadLanguageServer = systemVariables.resolveAny(pythonSettings.get('downloadLanguageServer', true))! this.jediEnabled = systemVariables.resolveAny(pythonSettings.get('jediEnabled', true))! this.autoUpdateLanguageServer = systemVariables.resolveAny(pythonSettings.get('autoUpdateLanguageServer', true))! + this.hideInterpreterName = systemVariables.resolveAny(pythonSettings.get('hideInterpreterName', false))! if (this.jediEnabled) { // tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion this.jediPath = systemVariables.resolveAny(pythonSettings.get('jediPath'))! diff --git a/src/common/types.ts b/src/common/types.ts index cf9e95c..3125153 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -163,6 +163,7 @@ export interface IPythonSettings { readonly globalModuleInstallation: boolean readonly analysis: IAnalysisSettings readonly autoUpdateLanguageServer: boolean + readonly hideInterpreterName: boolean readonly datascience: IDataScienceSettings readonly onDidChange: Event } diff --git a/src/interpreter/display/index.ts b/src/interpreter/display/index.ts index 0aa083f..3185454 100644 --- a/src/interpreter/display/index.ts +++ b/src/interpreter/display/index.ts @@ -5,6 +5,7 @@ import { IDisposableRegistry, Resource } from '../../common/types' import { IServiceContainer } from '../../ioc/types' import { IInterpreterAutoSelectionService } from '../autoSelection/types' import { IInterpreterDisplay, IInterpreterHelper, IInterpreterService, PythonInterpreter } from '../contracts' +import { IConfigurationService } from '../../common/types' import { emptyFn } from '../../common/function' // tslint:disable-next-line:completed-docs @@ -16,6 +17,7 @@ export class InterpreterDisplay implements IInterpreterDisplay { private readonly interpreterService: IInterpreterService private currentlySelectedInterpreterPath?: string private currentlySelectedWorkspaceFolder: Resource + private readonly configService: IConfigurationService private readonly autoSelection: IInterpreterAutoSelectionService constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) { @@ -23,6 +25,7 @@ export class InterpreterDisplay implements IInterpreterDisplay { this.workspaceService = serviceContainer.get(IWorkspaceService) this.interpreterService = serviceContainer.get(IInterpreterService) this.autoSelection = serviceContainer.get(IInterpreterAutoSelectionService) + this.configService = serviceContainer.get(IConfigurationService) const application = serviceContainer.get(IApplicationShell) const disposableRegistry = serviceContainer.get(IDisposableRegistry) @@ -62,11 +65,16 @@ export class InterpreterDisplay implements IInterpreterDisplay { } } private async updateDisplay(workspaceFolder?: Uri): Promise { + const hideInterpreterName = this.configService.getSettings().hideInterpreterName await this.autoSelection.autoSelectInterpreter(workspaceFolder) const interpreter = await this.interpreterService.getActiveInterpreter(workspaceFolder) this.currentlySelectedWorkspaceFolder = workspaceFolder if (interpreter) { - this.statusBar.text = interpreter.displayName! + if (hideInterpreterName) { + this.statusBar.text = '' + } else { + this.statusBar.text = interpreter.displayName! + } this.currentlySelectedInterpreterPath = interpreter.path } else { this.statusBar.text = 'No Python Interpreter'