diff --git a/README.md b/README.md index 76ba1bd..41cb7af 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,28 @@ If you wish to specify a custom path to your language server, you can do so via } ``` +## Running PowerShell code + +This extension provides task templates for running PowerShell code: + +- **PowerShell: Run Selection** — runs the currently selected text +- **PowerShell: Run File** — runs the current file + +These tasks are available via the `task: spawn` action. + +To bind `F8` for running selected text (like PowerShell ISE and VS Code), add the following to your `keymap.json`: + +```json +{ + "context": "Editor && extension == powershell", + "bindings": { + "f8": ["task::Spawn", { "task_name": "PowerShell: Run Selection" }] + } +} +``` + +## Configuring your language server settings + Additionally, you can configure settings for your language server as well as initialization options to pass to the language server on start. diff --git a/languages/powershell/tasks.json b/languages/powershell/tasks.json new file mode 100644 index 0000000..03341d7 --- /dev/null +++ b/languages/powershell/tasks.json @@ -0,0 +1,12 @@ +[ + { + "label": "PowerShell: Run Selection", + "command": "pwsh", + "args": ["-NoLogo", "-NoProfile", "-Command", "$ZED_SELECTED_TEXT"] + }, + { + "label": "PowerShell: Run File", + "command": "pwsh", + "args": ["-NoLogo", "-NoProfile", "-File", "$ZED_FILE"] + } +]