Skip to content

Commit 290a64f

Browse files
committed
code: Align to esbonio.sphinx.pythonCommand changes
1 parent 89bac4b commit 290a64f

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

code/package.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,6 @@
406406
"default": false,
407407
"description": "Enable lsp-devtools integration for sphinx agent instances."
408408
},
409-
"esbonio.sphinx.pythonPath": {
410-
"scope": "resource",
411-
"type": "array",
412-
"items": {
413-
"type": "string"
414-
},
415-
"default": [],
416-
"description": "List of paths to use when constructing the value of PYTHONPATH. Used to inject the sphinx agent into the target environment."
417-
},
418409
"esbonio.preview.showLineMarkers": {
419410
"scope": "resource",
420411
"type": "boolean",

code/src/node/client.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,30 @@ export interface SphinxClientConfig {
2424
/**
2525
* The python command used to launch the client
2626
*/
27-
pythonCommand: string[]
27+
pythonCommand: PythonCommand
2828

2929
/**
3030
* The sphinx-build command in use
3131
*/
3232
buildCommand: string[]
3333

34+
}
35+
36+
export interface PythonCommand {
3437
/**
35-
* The working directory of the client
38+
* The command that was invoked
3639
*/
37-
cwd: string
40+
command: string[]
41+
42+
/**
43+
* The environment variables the command was launched with
44+
*/
45+
env: { [key: string]: string }
3846

47+
/**
48+
* The working directory the command was launched in
49+
*/
50+
cwd: string
3951
}
4052

4153
export interface ClientCreatedNotification {
@@ -297,7 +309,7 @@ export class EsbonioClient {
297309
'esbonio',
298310
'Esbonio Language Server',
299311
server,
300-
this.getLanguageClientOptions(config)
312+
this.getLanguageClientOptions(pythonCommand, config)
301313
)
302314
this.registerHandlers(client)
303315
return client
@@ -335,7 +347,7 @@ export class EsbonioClient {
335347
* Returns the LanguageClient options that are common to both modes of
336348
* transport.
337349
*/
338-
private getLanguageClientOptions(config: vscode.WorkspaceConfiguration): LanguageClientOptions {
350+
private getLanguageClientOptions(pythonCommand: string[], config: vscode.WorkspaceConfiguration): LanguageClientOptions {
339351
let documentSelector = config.get<TextDocumentFilter[]>("server.documentSelector")
340352
if (!documentSelector || documentSelector.length === 0) {
341353
documentSelector = Server.DEFAULT_SELECTOR
@@ -348,8 +360,14 @@ export class EsbonioClient {
348360
maxRestartCount: 0
349361
},
350362
initializationOptions: {
363+
// Fallback sphinx configuration
351364
sphinx: {
352-
fallbackEnv: vscode.Uri.joinPath(this.extensionUri, "bundled", "env").fsPath,
365+
pythonCommand: {
366+
command: [...pythonCommand, "-S"],
367+
env: {
368+
PYTHONPATH: vscode.Uri.joinPath(this.extensionUri, "bundled", "env").fsPath
369+
}
370+
}
353371
}
354372
},
355373
middleware: {

code/src/node/processTreeView.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vscode from 'vscode'
22
import { Notifications, Events } from "../common/constants";
33
import { OutputChannelLogger } from '../common/log'
44

5-
import { AppCreatedNotification, ClientCreatedNotification, ClientDestroyedNotification, ClientErroredNotification, EsbonioClient, SphinxClientConfig, SphinxInfo } from './client';
5+
import { AppCreatedNotification, ClientCreatedNotification, ClientDestroyedNotification, ClientErroredNotification, EsbonioClient, PythonCommand, SphinxClientConfig, SphinxInfo } from './client';
66

77
/**
88
* Tree View provider that visualises the Sphinx processes currently
@@ -101,10 +101,10 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
101101

102102
case 'python':
103103
let pyCmd: string[] = []
104-
element.command?.forEach(c => pyCmd.push(`- ${c}`))
104+
element.command?.command.forEach(c => pyCmd.push(`- ${c}`))
105105

106106
return {
107-
label: element.command?.join(' '),
107+
label: element.command?.command.join(' '),
108108
iconPath: vscode.ThemeIcon.File,
109109
tooltip: new vscode.MarkdownString(`**Python Command**\n ${pyCmd.join('\n ')}`),
110110
resourceUri: vscode.Uri.parse('file:///test.py'), // Needed to pull in the icon for Python
@@ -146,7 +146,7 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
146146
if (!element) {
147147
for (let process of this.sphinxClients.values()) {
148148

149-
let cwd = process.config.cwd
149+
let cwd = process.config.pythonCommand.cwd
150150
let node: ProcessContainerNode = { kind: 'container', name: cwd, path: cwd }
151151
result.push(node)
152152
}
@@ -157,7 +157,7 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
157157
switch (element.kind) {
158158
case 'container':
159159
for (let [id, process] of this.sphinxClients.entries()) {
160-
if (element.name === process.config.cwd) {
160+
if (element.name === process.config.pythonCommand.cwd) {
161161
let node: SphinxProcessNode = { kind: 'sphinxProcess', id: id }
162162
result.push(node)
163163
}
@@ -279,7 +279,7 @@ type ProcessTreeNode = ProcessContainerNode | SphinxProcessNode | SphinxBuilderN
279279
*/
280280
interface PythonCommandNode {
281281
kind: 'python'
282-
command: string[] | undefined
282+
command: PythonCommand | undefined
283283
}
284284

285285
/**

0 commit comments

Comments
 (0)