Skip to content
This repository was archived by the owner on Dec 24, 2020. It is now read-only.

Commit 079b56a

Browse files
author
Andrii Yurchuk
committed
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`.
1 parent 241c6b3 commit 079b56a

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Except from `test`, `debug` and `datascience` features of [vscode-python](https:
8080
- `python.autoComplete.showAdvancedMembers`:Controls appearance of methods with double underscores in the completion list., default: `true`
8181
- `python.autoComplete.typeshedPaths`:Specifies paths to local typeshed repository clone(s) for the Python language server., default: `[]`
8282
- `python.autoUpdateLanguageServer`:Automatically update the language server., default: `true`
83+
- `python.hideInterpreterName`:Hide Python interpreter name in status bar., default: `false`
8384
- `python.disableInstallationCheck`:Whether to check if Python is installed (also warn when using the macOS-installed Python)., default: `false`
8485
- `python.envFile`:Absolute path to a file containing environment variable definitions., default: `"${workspaceFolder}/.env"`
8586
- `python.trace.server`:Trace level of tsserver, default: `"off"`

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@
181181
"description": "Automatically update the language server.",
182182
"scope": "application"
183183
},
184+
"python.hideInterpreterName": {
185+
"type": "boolean",
186+
"default": false,
187+
"description": "Hide interpreter name in status bar.",
188+
"scope": "application"
189+
},
184190
"python.disableInstallationCheck": {
185191
"type": "boolean",
186192
"default": false,

src/common/configSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class PythonSettings implements IPythonSettings {
4343
public analysis!: IAnalysisSettings
4444
public autoUpdateLanguageServer = true
4545
public datascience!: IDataScienceSettings
46+
public hideInterpreterName = false
4647

4748
protected readonly changed = new Emitter<void>()
4849
private workspaceRoot: Uri
@@ -147,6 +148,7 @@ export class PythonSettings implements IPythonSettings {
147148
this.downloadLanguageServer = systemVariables.resolveAny(pythonSettings.get<boolean>('downloadLanguageServer', true))!
148149
this.jediEnabled = systemVariables.resolveAny(pythonSettings.get<boolean>('jediEnabled', true))!
149150
this.autoUpdateLanguageServer = systemVariables.resolveAny(pythonSettings.get<boolean>('autoUpdateLanguageServer', true))!
151+
this.hideInterpreterName = systemVariables.resolveAny(pythonSettings.get<boolean>('hideInterpreterName', false))!
150152
if (this.jediEnabled) {
151153
// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
152154
this.jediPath = systemVariables.resolveAny(pythonSettings.get<string>('jediPath'))!

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export interface IPythonSettings {
163163
readonly globalModuleInstallation: boolean
164164
readonly analysis: IAnalysisSettings
165165
readonly autoUpdateLanguageServer: boolean
166+
readonly hideInterpreterName: boolean
166167
readonly datascience: IDataScienceSettings
167168
readonly onDidChange: Event<void>
168169
}

src/interpreter/display/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { IDisposableRegistry, Resource } from '../../common/types'
55
import { IServiceContainer } from '../../ioc/types'
66
import { IInterpreterAutoSelectionService } from '../autoSelection/types'
77
import { IInterpreterDisplay, IInterpreterHelper, IInterpreterService, PythonInterpreter } from '../contracts'
8+
import { IConfigurationService } from '../../common/types'
89
import { emptyFn } from '../../common/function'
910

1011
// tslint:disable-next-line:completed-docs
@@ -16,13 +17,15 @@ export class InterpreterDisplay implements IInterpreterDisplay {
1617
private readonly interpreterService: IInterpreterService
1718
private currentlySelectedInterpreterPath?: string
1819
private currentlySelectedWorkspaceFolder: Resource
20+
private readonly configService: IConfigurationService
1921
private readonly autoSelection: IInterpreterAutoSelectionService
2022

2123
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
2224
this.helper = serviceContainer.get<IInterpreterHelper>(IInterpreterHelper)
2325
this.workspaceService = serviceContainer.get<IWorkspaceService>(IWorkspaceService)
2426
this.interpreterService = serviceContainer.get<IInterpreterService>(IInterpreterService)
2527
this.autoSelection = serviceContainer.get<IInterpreterAutoSelectionService>(IInterpreterAutoSelectionService)
28+
this.configService = serviceContainer.get<IConfigurationService>(IConfigurationService)
2629

2730
const application = serviceContainer.get<IApplicationShell>(IApplicationShell)
2831
const disposableRegistry = serviceContainer.get<Disposable[]>(IDisposableRegistry)
@@ -62,11 +65,16 @@ export class InterpreterDisplay implements IInterpreterDisplay {
6265
}
6366
}
6467
private async updateDisplay(workspaceFolder?: Uri): Promise<void> {
68+
const hideInterpreterName = this.configService.getSettings().hideInterpreterName
6569
await this.autoSelection.autoSelectInterpreter(workspaceFolder)
6670
const interpreter = await this.interpreterService.getActiveInterpreter(workspaceFolder)
6771
this.currentlySelectedWorkspaceFolder = workspaceFolder
6872
if (interpreter) {
69-
this.statusBar.text = interpreter.displayName!
73+
if (hideInterpreterName) {
74+
this.statusBar.text = ''
75+
} else {
76+
this.statusBar.text = interpreter.displayName!
77+
}
7078
this.currentlySelectedInterpreterPath = interpreter.path
7179
} else {
7280
this.statusBar.text = 'No Python Interpreter'

0 commit comments

Comments
 (0)