Skip to content

Commit 349c393

Browse files
committed
code: Stop injecting active Python env into config
1 parent 28685b2 commit 349c393

File tree

3 files changed

+9
-34
lines changed

3 files changed

+9
-34
lines changed

code/changes/881.misc.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**IMPORTANT!**
2+
3+
The VSCode extension will no longer automatically inject the currently active Python interpreter into the configuration sent to the server.
4+
It is now required for all users to set the `esbonio.sphinx.pythonCommand` option, either in your VSCode settings, or in your project's `pyproject.toml` file.
5+
6+
This makes VSCode's behavior more predicable and brings it in line with how other editors behave.
7+
It also encourages the sharing of project configuration settings, which is particuarly useful if you use an [environment manager](https://docs.esbon.io/en/latest/lsp/howto/use-esbonio-with.html)

code/guides/bring-your-own-sphinx.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@ While the `esbonio` language server is bundled as part of the extension, it does
44

55
This is because every Sphinx project is unique with its own set of dependencies and required extensions. In order to correctly understand your project `esbonio` needs to use the same Python environment that you use to build your documentation.
66

7-
The Esbonio extension supports two mechanisms for selecting your Python environment.
8-
9-
1. If the official Python extension is available, by default Esbonio will attempt to use the same environment you have configured for your workspace.
10-
2. Alternatively, you can use the `esbonio.sphinx.pythonCommand` setting to override this behavior.
7+
You can tell Esbonio which environment to use by setting the `esbonio.sphinx.pythonCommand` option. See [this guide](https://docs.esbon.io/en/latest/lsp/howto/use-esbonio-with.html) for some examples

code/src/node/client.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ export class EsbonioClient {
338338
* transport.
339339
*/
340340
private getLanguageClientOptions(config: vscode.WorkspaceConfiguration): LanguageClientOptions {
341-
342-
343-
344341
let documentSelector = config.get<TextDocumentFilter[]>("server.documentSelector")
345342
if (!documentSelector || documentSelector.length === 0) {
346343
documentSelector = Server.DEFAULT_SELECTOR
@@ -361,8 +358,7 @@ export class EsbonioClient {
361358
return result
362359
}
363360

364-
result.forEach(async (config, i) => {
365-
await this.injectPython(params, i, config)
361+
result.forEach((config) => {
366362
this.stripNulls(config)
367363
})
368364
return result
@@ -394,31 +390,6 @@ export class EsbonioClient {
394390
}
395391
}
396392

397-
/**
398-
* Inject the user's configured Python interpreter into the configuration.
399-
*/
400-
private async injectPython(params: ConfigurationParams, index: number, config: any) {
401-
if (params.items[index].section !== "esbonio") {
402-
return
403-
}
404-
405-
if (config?.sphinx?.pythonCommand?.length > 0) {
406-
return
407-
}
408-
409-
// User has not explictly configured a Python command, try and inject the
410-
// Python interpreter they have configured for this resource.
411-
let scopeUri: vscode.Uri | undefined
412-
let scope = params.items[index].scopeUri
413-
if (scope) {
414-
scopeUri = vscode.Uri.parse(scope)
415-
}
416-
let python = await this.python.getCmd(scopeUri)
417-
if (python) {
418-
config.sphinx.pythonCommand = python
419-
}
420-
}
421-
422393
private callHandlers(method: string, params: any) {
423394
this.handlers.get(method)?.forEach(handler => {
424395
try {

0 commit comments

Comments
 (0)