From a04fe16c393d647dc2a63715ec34ae3f9397d825 Mon Sep 17 00:00:00 2001 From: james <2923777+jnichols0@users.noreply.github.com> Date: Sun, 17 May 2026 01:50:01 -0400 Subject: [PATCH] Add task templates for running PowerShell code Add tasks.json with two task templates: - 'PowerShell: Run Selection' to run selected text via pwsh - 'PowerShell: Run File' to run the current file via pwsh This enables the F8 run-selection workflow familiar to PowerShell ISE and VS Code users when bound via keymap.json. Update README with documentation on the new tasks and example keybinding configuration. Closes zed-extensions/powershell#10 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 22 ++++++++++++++++++++++ languages/powershell/tasks.json | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 languages/powershell/tasks.json 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"] + } +]