-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vscode-lib: expose vscode API via global
Currently vscode doesn't support dynamic imports, so it isn't possible for a javascript provider to opt-in to more advanced user experience via the vscode APIs. Until we can more easily opt-in to vscode support, we expose the vscode API via node's global object. We want to see what sort of APIs get used from vscode in providers, and will then likely evolve a first class editor abstraction.
- Loading branch information
1 parent
0b8b5d9
commit b9c1231
Showing
6 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as vscode from 'vscode' | ||
|
||
// dynamic imports don't work in node + vscode due to | ||
// https://github.com/microsoft/vscode-loader/issues/36 | ||
// | ||
// So vscode-lib sets a global so providers can optionally access vscode APIs. | ||
|
||
interface Global { | ||
openctx?: { | ||
vscode?: typeof vscode | ||
} | ||
} | ||
|
||
export function initializeOpenCtxGlobal() { | ||
initializeGlobal(global as Global) | ||
} | ||
|
||
function initializeGlobal(global: Global) { | ||
if (!global.openctx) { | ||
global.openctx = { vscode } | ||
} | ||
global.openctx.vscode = vscode | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters