-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add install.ps1 to the package; add notification for auto installation
- Loading branch information
Yatao Li
committed
Jun 26, 2019
1 parent
c84a91e
commit ce33135
Showing
3 changed files
with
27 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,36 @@ import Shell from "node-powershell"; | |
|
||
const cocPowerShellRoot = path.join(__dirname, "..", ".."); | ||
const bundledModulesPath = path.join(cocPowerShellRoot, "PowerShellEditorServices"); | ||
// TODO configuration for log path? | ||
This comment has been minimized.
Sorry, something went wrong. |
||
const logPath = path.join(cocPowerShellRoot, "/.pses/logs/1234"); | ||
// TODO log redirection? | ||
const logger = workspace.createOutputChannel("coc-powershell"); | ||
|
||
export async function activate(context: ExtensionContext) { | ||
const pwshPath = getDefaultPowerShellPath(getPlatformDetails()) | ||
|
||
logger.appendLine("starting.") | ||
logger.appendLine(`pwshPath = ${pwshPath}`) | ||
logger.appendLine(`bundledModulesPath = ${bundledModulesPath}`) | ||
|
||
// If PowerShellEditorServices is not downloaded yet, run the install script to do so. | ||
if (!fs.existsSync(bundledModulesPath)) { | ||
let notification = workspace.createStatusBarItem(0, { progress: true}) | ||
notification.text = "Downloading PowerShellEditorServices..." | ||
notification.show() | ||
|
||
const ps = new Shell({ | ||
executionPolicy: 'Bypass', | ||
noProfile: true | ||
}); | ||
|
||
ps.addCommand(path.join(cocPowerShellRoot, "install.ps1")); | ||
await ps.invoke(); | ||
await ps.invoke() | ||
.catch(e => logger.appendLine("error downloading PSES: " + e)) | ||
.finally(() => { | ||
notification.hide() | ||
notification.dispose() | ||
}); | ||
|
||
} | ||
|
||
let serverOptions: ServerOptions = { | ||
|
@@ -51,13 +67,12 @@ export async function activate(context: ExtensionContext) { | |
|
||
// Options to control the language client | ||
let clientOptions: LanguageClientOptions = { | ||
// Register the server for F# documents | ||
// Register the server for powershell documents | ||
documentSelector: [{ scheme: 'file', language: 'ps1' }], | ||
synchronize: { | ||
// Synchronize the setting section 'powershell' to the server | ||
configurationSection: 'ps1', | ||
// Notify the server about file changes to PowerShell files contain in the workspace | ||
// TODO: is there a way to configure this via the language server protocol? | ||
fileEvents: [ | ||
workspace.createFileSystemWatcher('**/*.ps1'), | ||
workspace.createFileSystemWatcher('**/*.psd1'), | ||
|
@@ -76,6 +91,9 @@ export async function activate(context: ExtensionContext) { | |
commands.registerCommand('powershell.command.goto', goto); | ||
} | ||
|
||
// NOTE (yatli): this is in fact due to coc-fsharp CodeLens using a custom command | ||
// if PSES is not using a 'goto' codelens command we can discard this one. | ||
// Also, any other pwsh codelens/general commands, like "test this", "evaluate"? they could be implemented like this one | ||
This comment has been minimized.
Sorry, something went wrong.
TylerLeonhardt
Collaborator
|
||
function goto(file: string, startLine: number, startColumn: number, _endLine: number, _endColumn: number) { | ||
let selection = Range.create(startLine, startColumn, startLine, startColumn); | ||
workspace.jumpTo(file, selection.start); | ||
|
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
Yeah I was just lazy, this should be a "guid-pid".