Skip to content

Commit

Permalink
code: Add ${workspaceFolder} support to esbonio.server.pythonPath
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Jun 6, 2022
1 parent 931c5ad commit 7885bd9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions code/changes/404.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The ``esbonio.server.pythonPath`` setting now accepts paths relative to ``${workspaceFolder}``.

**Note** This is simply an alias for the existing ``${workspaceRoot}`` functionality.
6 changes: 3 additions & 3 deletions code/src/lsp/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ export class PythonManager {
if (userPython) {

// Support for ${workspaceRoot}/...
let match = userPython.match(/^\${(\w+)}.*/)
if (match && match[1] === 'workspaceRoot') {
let match = userPython.match(/^\${(\w+)}/)
if (match && (match[1] === 'workspaceRoot' || match[1] === 'workspaceFolder')) {
let workspaceRoot = ""
let workspaceFolders = vscode.workspace.workspaceFolders

if (workspaceFolders) {
workspaceRoot = workspaceFolders[0].uri.fsPath
}

userPython = userPython.replace("${workspaceRoot}", workspaceRoot)
userPython = userPython.replace(match[0], workspaceRoot)
}

this.logger.debug(`Using user configured Python: ${userPython}`)
Expand Down
1 change: 1 addition & 0 deletions docs/lsp/editors/vscode/_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The following options are available.

- ``/path/to/python/`` - An absolute path
- ``${workspaceRoot}/../venv/bin/python`` - A path relative to the root of your workspace
- ``${workspaceFolder}/../venv/bin/python`` - Same as ``${workspaceRoot}``, placeholder for true multi-root workspace support.

.. confval:: esbonio.server.installBehavior (string)

Expand Down

0 comments on commit 7885bd9

Please sign in to comment.