Skip to content

Commit 654540a

Browse files
[Ignore] Quick start doc in README (#1059)
* Start docs * steve and rob's feedback * add note on API usage * extra space after - * Rob's gone social! Co-Authored-By: Robert Holt <rjmholt@gmail.com>
1 parent 1415042 commit 654540a

File tree

1 file changed

+106
-16
lines changed

1 file changed

+106
-16
lines changed

README.md

Lines changed: 106 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,114 @@ PowerShell Editor Services is a PowerShell module that provides common
1010
functionality needed to enable a consistent and robust PowerShell development
1111
experience in almost any editor or integrated development environment (IDE).
1212

13-
## PowerShell Language Server Protocol clients using PowerShell Editor Services
13+
## PowerShell [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) clients using PowerShell Editor Services
1414

1515
The functionality in PowerShell Editor Services is already available in the following editor extensions:
1616

17-
- [The VSCode PowerShell extension](https://github.com/PowerShell/vscode-powershell), also available in Azure Data Studio
18-
- [coc-powershell](https://github.com/yatli/coc-powershell), a vim/neovim PowerShell plugin
19-
- [The IntelliJ PowerShell plugin](https://github.com/ant-druha/intellij-powershell)
20-
- [lsp-powershell](https://github.com/kiennq/lsp-powershell), an Emacs PowerShell plugin
17+
- [The VSCode PowerShell extension](https://github.com/PowerShell/vscode-powershell), also available in Azure Data Studio
18+
- [coc-powershell](https://github.com/yatli/coc-powershell), a vim/neovim PowerShell plugin
19+
- [The IntelliJ PowerShell plugin](https://github.com/ant-druha/intellij-powershell)
20+
- [lsp-powershell](https://github.com/kiennq/lsp-powershell), an Emacs PowerShell plugin
2121

2222
## Features
2323

24-
- The Language Service provides common editor features for the PowerShell language:
25-
- Code navigation actions (find references, go to definition)
26-
- Statement completions (IntelliSense)
27-
- Real-time semantic analysis of scripts using PowerShell Script Analyzer
28-
- The Debugging Service simplifies interaction with the PowerShell debugger (breakpoints, variables, call stack, etc)
29-
- The [$psEditor API](http://powershell.github.io/PowerShellEditorServices/guide/extensions.html) enables scripting of the host editor
30-
- A full, terminal-based Integrated Console experience for interactive development and debugging
24+
- The Language Service provides common editor features for the PowerShell language:
25+
- Code navigation actions (find references, go to definition)
26+
- Statement completions (IntelliSense)
27+
- Real-time semantic analysis of scripts using PowerShell Script Analyzer
28+
- The Debugging Service simplifies interaction with the PowerShell debugger (breakpoints, variables, call stack, etc)
29+
- The [$psEditor API](http://powershell.github.io/PowerShellEditorServices/guide/extensions.html) enables scripting of the host editor
30+
- A full, terminal-based Integrated Console experience for interactive development and debugging
31+
32+
## Usage
33+
34+
Looking to integrate PowerShell Editor Services into your [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) compliant editor or client? We support two ways of connecting.
35+
36+
### Named Pipes/Unix Domain Sockets (recommended)
37+
38+
If you're looking for the more feature-rich experience,
39+
Named Pipes are the way to go.
40+
They give you all the benefit of the Lanaguge Server Protocol with extra capabilities that you can take advantage of:
41+
42+
- The PowerShell Integrated Console
43+
- Debugging using the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/)
44+
45+
The typical command to start PowerShell Editor Services using named pipes is as follows:
46+
47+
```powershell
48+
pwsh -NoLogo -NoProfile -Command "$PSES_BUNDLE_PATH/PowerShellEditorServices/Start-EditorServices.ps1 -BundledModulesPath $PSES_BUNDLE_PATH -LogPath $SESSION_TEMP_PATH/logs.log -SessionDetailsPath $SESSION_TEMP_PATH/session.json -FeatureFlags @() -AdditionalModules @() -HostName 'My Client' -HostProfileId 'myclient' -HostVersion 1.0.0 -LogLevel Normal"
49+
```
50+
51+
> NOTE: In the example above,
52+
>
53+
> - `$PSES_BUNDLE_PATH` is the root of the PowerShellEditorServices.zip downloaded from the GitHub releases.
54+
> - `$SESSION_TEMP_PATH` is the folder path that you'll use for this specific editor session.
55+
56+
Once the command is run,
57+
PowerShell Editor Services will wait until the client connects to the Named Pipe.
58+
The `session.json` will contain the paths of the Named Pipes that you will connect to.
59+
There will be one you immediately connect to for Language Server Protocol messages,
60+
and one you connect to when you launch the debugger for Debug Adapter Protocol messages.
61+
62+
The Visual Studio Code, Vim, and IntelliJ extensions currently use Named Pipes.
63+
64+
#### PowerShell Integrated Console
65+
66+
![image](https://user-images.githubusercontent.com/2644648/66245084-6985da80-e6c0-11e9-9c7b-4c8476190df5.png)
67+
68+
The PowerShell Integrated Console 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.
69+
70+
If you want to take advantage of the PowerShell Integrated Console which automatically shares state with the editor-side,
71+
you must include the `-EnableConsoleRepl` switch when called `Start-EditorServices.ps1`.
72+
73+
This is typically used if your client has the ability to create arbirary terminals in the editor like below:
74+
75+
![integrated console in vscode](https://user-images.githubusercontent.com/2644648/66245018-04ca8000-e6c0-11e9-808c-b86144149444.png)
76+
77+
The Visual Studio Code, Vim, and IntelliJ extensions currently use the PowerShell Integrated Console.
78+
79+
#### Debugging
80+
81+
Debugging support is also exposed with PowerShell Editor Services.
82+
It is handled within the same process as the language server protocol handing.
83+
This provides a more integrated experience for end users but is something to note as not many other language servers work in this way.
84+
If you want to take advantage of debugging,
85+
your client must support the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/).
86+
Your client should use the path to the debug named pipe found in the `session.json` file talked about above.
87+
88+
Currently only the Visual Studio Code extension supports debugging.
89+
90+
### Stdio
91+
92+
Stdio is a simpler and more universal mechanism when it comes to the Language Server Protocol and is what we recommend if your editor/client doesn't need to support the PowerShell Integrated Console or debugging.
93+
94+
> NOTE: Debugging and the Integrated Console are not features of the Stdio channel because each feature requires their own IO streams and since the Stdio model only provides a single set of streams (Stdio),
95+
> these features cannot be leveraged.
96+
97+
The typical command to start PowerShell Editor Services using stdio is as follows:
98+
99+
```powershell
100+
pwsh -NoLogo -NoProfile -Command "$PSES_BUNDLE_PATH/PowerShellEditorServices/Start-EditorServices.ps1 -BundledModulesPath $PSES_BUNDLE_PATH -LogPath $SESSION_TEMP_PATH/logs.log -SessionDetailsPath $SESSION_TEMP_PATH/session.json -FeatureFlags @() -AdditionalModules @() -HostName 'My Client' -HostProfileId 'myclient' -HostVersion 1.0.0 -Stdio -LogLevel Normal"
101+
```
102+
103+
> NOTE: In the example above,
104+
>
105+
> - `$PSES_BUNDLE_PATH` is the root of the PowerShellEditorServices.zip downloaded from the GitHub releases.
106+
> - `$SESSION_TEMP_PATH` is the folder path that you'll use for this specific editor session.
107+
108+
The important flag is the `-Stdio` flag which enables this communication protocol.
109+
110+
Currently, the Emacs extension uses Stdio.
111+
112+
### API Usage
113+
114+
Please note that we only consider the following as stable APIs that can be relied on:
115+
116+
- Language server protocol connection
117+
- Debug adapter protocol connection
118+
- Start up mechanism
119+
120+
The types of PowerShell Editor Services can change at any moment and should not be linked against in production environment.
31121

32122
## Development
33123

@@ -67,10 +157,10 @@ contribute code, documentation, tests, or bug reports, please read our [Contribu
67157

68158
## Maintainers
69159

70-
- [Keith Hill](https://github.com/rkeithhill) - [@r_keith_hill](http://twitter.com/r_keith_hill)
71-
- [Patrick Meinecke](https://github.com/SeeminglyScience) - [@SeeminglyScienc](http://twitter.com/SeeminglyScienc)
72-
- [Tyler Leonhardt](https://github.com/tylerleonhardt) - [@TylerLeonhardt](http://twitter.com/tylerleonhardt)
73-
- [Rob Holt](https://github.com/rjmholt) - no twitter
160+
- [Keith Hill](https://github.com/rkeithhill) - [@r_keith_hill](http://twitter.com/r_keith_hill)
161+
- [Patrick Meinecke](https://github.com/SeeminglyScience) - [@SeeminglyScienc](http://twitter.com/SeeminglyScienc)
162+
- [Tyler Leonhardt](https://github.com/tylerleonhardt) - [@TylerLeonhardt](http://twitter.com/tylerleonhardt)
163+
- [Rob Holt](https://github.com/rjmholt) - [@rjmholt](https://twitter.com/rjmholt)
74164

75165
## License
76166

0 commit comments

Comments
 (0)