- Notifications
You must be signed in to change notification settings - Fork237
A common platform for PowerShell development support in any editor or application!
License
PowerShell/PowerShellEditorServices
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PowerShell Editor Services is a PowerShell module that provides commonfunctionality needed to enable a consistent and robust PowerShell developmentexperience in almost any editor or integrated development environment (IDE).
Language Server Protocol clients using PowerShell Editor Services:
Note
PowerShell for Azure Data Studio will no longer be updated or maintained.
The functionality in PowerShell Editor Services is available in the following editor extensions:
Warning
These clients are community maintained and may be very out of date.It is recommended to use a genericLSP plugin with your client if possible.
- lsp-pwsh, an Emacs PowerShell plugin
- intellij-powershell, adds PowerShell language support to IntelliJ-based IDEs
- coc-powershell, a Vim and Neovim plugin
- powershell.nvim a Neovim plugin
PSES runs as a PowerShell Module incurrently supported versions of PowerShell 7+.
Windows PowerShell 5.1 is supported on a best-effort basis.
- The Language Service provides common editor features for the PowerShell language:
- Code navigation actions (find references, go to definition)
- Statement completions (IntelliSense)
- Real-time semantic analysis of scripts using PowerShell Script Analyzer
- The Debugging Service simplifies interaction with the PowerShell debugger (breakpoints, variables, call stack, etc.)
- The$psEditor API enables scripting of the host editor
- A full, Extension Terminal experience for interactive development and debugging
If you're looking to integrate PowerShell Editor Services into yourLanguage Server Protocol compliant editor or client,we support two ways of connecting.
If you're looking for a more feature-rich experience,named pipes (AKA sockets) are the way to go.They give you all the benefits of the Language Server Protocol with extra capabilities that you can take advantage of:
- The PowerShell Extension Terminal
- Debugging using theDebug Adapter Protocol
The typical command to start PowerShell Editor Services using named pipes / sockets is as follows:
pwsh-NoLogo-NoProfile-Command"./PowerShellEditorServices/Start-EditorServices.ps1 -SessionDetailsPath ./session.json"
The start script,Start-EditorServices.ps1
, is found in thePowerShellEditorServices
folder instead thePowerShellEditorServices.zip
downloaded from the GitHub releases.
The session details (which named pipes were created) will be written to the given session details path,and the client needs to point to these in order to connect.
The Visual Studio Code, Vim, Neovim, and IntelliJ extensions use named pipes.
Alternatively, the-SessionDetailsPath ./session.json
argument can be replaced with just-Stdio
.The use of stdio is thesimplest way to connect with most LSP clients,but will limit some features, such as the debugger and Extension Terminal.This is because because these two features require their own IO streams and stdio only provides a single pair of streams.
Please see theemacs-simple-test.el,emacs-test.el,vim-simple-test.vim andvim-test.vim for examples of end-to-end tested configurations.They useeglot for Emacs andLanguageClient-neovim.
If you are trying to automate the service in PowerShell, you can also run it underStart-Process
to prevent hanging your script.It also gives you access to process automation features like$process.Close()
or$process.Kill()
.TheStart-EditorServices.ps1
script takes many more optional arguments, but they no longerneed to be specified.
$command=@("$PSES_BUNDLE_PATH/PowerShellEditorServices/Start-EditorServices.ps1","-BundledModulesPath$PSES_BUNDLE_PATH","-LogPath ./logs","-SessionDetailsPath ./session.json","-FeatureFlags @()","-AdditionalModules @()","-HostName 'My Client'","-HostProfileId 'myclient'","-HostVersion 1.0.0","-LogLevel Trace")-join""$pwsh_arguments="-NoLogo -NoProfile -Command$command"$process=Start-Process pwsh-ArgumentList$arguments-PassThru...$process.Close();#$process.Kill();
Once the command is run,PowerShell Editor Services will wait until the client connects to the named pipe.Thesession.json
will contain the paths of the named pipes that you will connect to.There will be one you immediately connect to for Language Server Protocol messages,and once you connect to when you launch the debugger for Debug Adapter Protocol messages.
The PowerShell Extension Terminal uses the host process' stdio streams for console input and output.Please note that this is mutually exclusive from using stdio for the Language Server Protocol messages.
If you want to take advantage of the PowerShell Extension Terminal,you must include the-EnableConsoleRepl
switch when callingStart-EditorServices.ps1
.
This is typically used if your client can create arbitrary terminals in the editor like below:
The Visual Studio Code, Vim, and IntelliJ extensions currently use the PowerShell Extension Terminal.
Debugging support is also exposed with PowerShell Editor Services.It is handled within the same process as the Language Server Protocol.This provides a more integrated experience for end users but is something to note as not many other language servers work in the same way.If you want to take advantage of debugging,your client must support theDebug Adapter Protocol.Your client should use the path to the debug named pipe found in thesession.json
file talked about above.
The debugging functionality in PowerShell Editor Services is available in the following editor extensions:
- PowerShell for Visual Studio Code
- nvim-dap-powershell for Neovim
- powershell.nvim for Neovim
- intellij-powershell
Please note that we only consider the following as stable APIs that can be relied on:
- Language Server Protocol connection
- Debug Adapter Protocol connection
- Start-up mechanism
The types of PowerShell Editor Services can change at any moment and should not be linked against in a production environment.
Tip
The easiest way to manually test changes you've made in PowerShellEditorServices is to follow thevscode-powershell development doc.
Install PowerShell 7+ withthese instructions.
git clone https://github.com/PowerShell/PowerShellEditorServices.git
3. InstallInvoke-Build
Install-Module InvokeBuild-Scope CurrentUserInstall-Module platyPS-Scope CurrentUser
Our NuGet configuration uses a secure feed with allow-listed third party dependency packages. If your contribution requires any changes to the included NuGet packages, you must disable this secure feed.
First, run this command to prevent accidentally commiting changes to this file
gitupdate-index--skip-worktree nuget.config
Then, either delete the file or remove thepackagesources
section to use nuget.org again. Your PRwill fail automated build checks and youmust inform us at the top of your PR so the appropriate packages can be added if approved.
Now you're ready to build the code. You can do so in one of two ways:
PS C:\src\PowerShellEditorServices>Invoke-Build
Open the PowerShellEditorServices folder that you cloned locally and pressCtrl+Shift+B(orCmd+Shift+B on macOS) which will run the default build task.
Please see ourCode of Conduct before participating in this project.
We would love to incorporate community contributions into this project. If you would like tocontribute code, documentation, tests, or bug reports, please read ourContribution Guide to learn more.
For any security issues, please seehere.
- Andy Jordan -@andyleejordan
- Patrick Meinecke -@SeeminglyScience
- Sydney Smith -@SydneyhSmith
- Justin Grote -@JustinGrote
- Rob Holt -@rjmholt
- Tyler Leonhardt -@TylerLeonhardt
- David Wilson -@daviwil
This project islicensed under the MIT License. Please see thethird-party notices file for details on the third-partybinaries that we include with releases of this project.
About
A common platform for PowerShell development support in any editor or application!
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.