Skip to content

Commit f7f347d

Browse files
Update README.md (#2149)
1 parent 248537f commit f7f347d

File tree

1 file changed

+51
-59
lines changed

1 file changed

+51
-59
lines changed

README.md

+51-59
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88
functionality needed to enable a consistent and robust PowerShell development
99
experience in almost any editor or integrated development environment (IDE).
1010

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

13-
The functionality in PowerShell Editor Services is already available in the following editor extensions:
13+
The functionality in PowerShell Editor Services is available in the following editor extensions:
1414

15-
- [The VSCode PowerShell extension](https://github.com/PowerShell/vscode-powershell), also available in Azure Data Studio
16-
- [coc-powershell](https://github.com/yatli/coc-powershell), a vim/neovim PowerShell plugin
17-
- [The IntelliJ PowerShell plugin](https://github.com/ant-druha/intellij-powershell)
15+
- [PowerShell for Visual Studio Code](https://github.com/PowerShell/vscode-powershell), also available in Azure Data Studio
1816
- [lsp-pwsh](https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-pwsh.el), an Emacs PowerShell plugin
17+
- [intellij-powershell](https://github.com/ant-druha/intellij-powershell), adds PowerShell language support to IntelliJ-based IDEs
18+
- [coc-powershell](https://github.com/yatli/coc-powershell), a Vim and Neovim plugin
19+
20+
Please note that other than PowerShell for Visual Studio Code, these clients are community maintained and may be very out of date.
21+
It is recommended that you simply use an LSP plugin for your editor and configure it as demonstrated [below](#Usage).
1922

2023
## Features
2124

@@ -24,55 +27,67 @@ The functionality in PowerShell Editor Services is already available in the foll
2427
- Statement completions (IntelliSense)
2528
- Real-time semantic analysis of scripts using PowerShell Script Analyzer
2629
- The Debugging Service simplifies interaction with the PowerShell debugger (breakpoints, variables, call stack, etc.)
27-
- The [$psEditor API](https://github.com/PowerShell/PowerShellEditorServices/blob/main/docs/guide/extensions.md) enables scripting of the host editor
30+
- The [$psEditor API](docs/guide/extensions.md) enables scripting of the host editor
2831
- A full, Extension Terminal experience for interactive development and debugging
2932

3033
## Usage
3134

32-
If you're 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+
If you're looking to integrate PowerShell Editor Services into your [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) compliant editor or client,
36+
we support two ways of connecting.
3337

34-
### Named Pipes/Unix Domain Sockets (recommended)
38+
### Named Pipes / Unix Domain Sockets
3539

3640
If you're looking for a more feature-rich experience,
37-
Named Pipes are the way to go.
41+
named pipes (AKA sockets) are the way to go.
3842
They give you all the benefits of the Language Server Protocol with extra capabilities that you can take advantage of:
3943

4044
- The PowerShell Extension Terminal
4145
- Debugging using the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/)
4246

43-
The typical command to start PowerShell Editor Services using `stdio` is as follows:
47+
The typical command to start PowerShell Editor Services using named pipes / sockets is as follows:
4448

4549
```powershell
46-
pwsh -NoLogo -NoProfile -Command "./PowerShellEditorServices/Start-EditorServices.ps1 -Stdio"
50+
pwsh -NoLogo -NoProfile -Command "./PowerShellEditorServices/Start-EditorServices.ps1 -SessionDetailsPath ./session.json"
4751
```
4852

49-
The start script, `Start-EditorServices.ps1` is found in the `PowerShellEditorServices` folder instead the `PowerShellEditorServices.zip` downloaded from the GitHub releases.
53+
The start script, `Start-EditorServices.ps1`, is found in the `PowerShellEditorServices` folder instead the `PowerShellEditorServices.zip` downloaded from the GitHub releases.
54+
55+
The session details (which named pipes were created) will be written to the given session details path,
56+
and the client needs to point to these in order to connect.
57+
58+
The Visual Studio Code, Vim, and IntelliJ extensions use named pipes.
59+
60+
### Standard Input and Output
5061

51-
Alternatively, the `-Stdio` argument can be removed and the argument `-SessionDetailsPath ./session.json` added to produce a JSON file the client needs to point to in order to connect over a named pipe / socket.
52-
The use stdio is the simplest way to connect with most LSP clients,
53-
but may limit some features (such as the debugger and Extension Terminal).
62+
Alternatively, the `-SessionDetailsPath ./session.json` argument can be replaced with just `-Stdio`.
63+
The use of stdio is the _simplest_ way to connect with most LSP clients,
64+
but will limit some features, such as the debugger and Extension Terminal.
65+
This is because because these two features require their own IO streams and stdio only provides a single pair of streams.
5466

55-
Please see the [emacs-simple-test.el](test\emacs-simple-test.el),
56-
[emacs-test.el](test\emacs-test.el),
57-
[vim-simple-test.el](test\vim-simple-test.vim) and [vim-test.vim](test\vim-test.vim) for examples of end-to-end tested configurations.
67+
Please see the [emacs-simple-test.el](test/emacs-simple-test.el),
68+
[emacs-test.el](test/emacs-test.el),
69+
[vim-simple-test.el](test/vim-simple-test.vim) and [vim-test.vim](test/vim-test.vim) for examples of end-to-end tested configurations.
70+
They use [eglot for Emacs](https://github.com/joaotavora/eglot) and [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim).
71+
72+
### Advanced Usage
5873

5974
If you are trying to automate the service in PowerShell, you can also run it under `Start-Process` to prevent hanging your script.
60-
It also gives you access to Process/PID automation features like `$process.Close()` or `$process.Kill()`.
61-
The script takes many more optional arguments, but they no longer _need_ to be specified.
75+
It also gives you access to process automation features like `$process.Close()` or `$process.Kill()`.
76+
The `Start-EditorServices.ps1` script takes many more optional arguments, but they no longer _need_ to be specified.
6277

6378
```powershell
6479
$command = @(
6580
"$PSES_BUNDLE_PATH/PowerShellEditorServices/Start-EditorServices.ps1",
6681
"-BundledModulesPath $PSES_BUNDLE_PATH",
67-
"-LogPath $SESSION_LOGS_PATH",
68-
"-SessionDetailsPath $SESSION_TEMP_PATH/session.json",
82+
"-LogPath ./logs",
83+
"-SessionDetailsPath ./session.json",
6984
"-FeatureFlags @()",
7085
"-AdditionalModules @()",
7186
"-HostName 'My Client'",
7287
"-HostProfileId 'myclient'",
7388
"-HostVersion 1.0.0",
7489
"-LogLevel Diagnostic"
75-
)-join " "
90+
) -join " "
7691
7792
$pwsh_arguments = "-NoLogo -NoProfile -Command $command"
7893
$process = Start-Process pwsh -ArgumentList $arguments -PassThru
@@ -86,63 +101,40 @@ The `session.json` will contain the paths of the named pipes that you will conne
86101
There will be one you immediately connect to for Language Server Protocol messages,
87102
and once you connect to when you launch the debugger for Debug Adapter Protocol messages.
88103

89-
The Visual Studio Code, Vim, and IntelliJ extensions currently can use named pipes.
90-
91-
#### PowerShell Extension Terminal
104+
### PowerShell Extension Terminal
92105

93106
![image](https://user-images.githubusercontent.com/2644648/66245084-6985da80-e6c0-11e9-9c7b-4c8476190df5.png)
94107

95-
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.
108+
The PowerShell Extension Terminal uses the host process' stdio streams for console input and output.
109+
Please note that this is mutually exclusive from using stdio for the Language Server Protocol messages.
96110

97-
If you want to take advantage of the PowerShell Extension Terminal which automatically shares state with the editor-side,
98-
you must include the `-EnableConsoleRepl` switch when called `Start-EditorServices.ps1`.
111+
If you want to take advantage of the PowerShell Extension Terminal,
112+
you must include the `-EnableConsoleRepl` switch when calling `Start-EditorServices.ps1`.
99113

100114
This is typically used if your client can create arbitrary terminals in the editor like below:
101115

102-
![Extension Terminal in vscode](https://user-images.githubusercontent.com/2644648/66245018-04ca8000-e6c0-11e9-808c-b86144149444.png)
116+
![Extension Terminal in VS Code](https://user-images.githubusercontent.com/2644648/66245018-04ca8000-e6c0-11e9-808c-b86144149444.png)
103117

104118
The Visual Studio Code, Vim, and IntelliJ extensions currently use the PowerShell Extension Terminal.
105119

106-
#### Debugging
120+
### Debugging
107121

108122
Debugging support is also exposed with PowerShell Editor Services.
109-
It is handled within the same process as the language server protocol handing.
110-
This provides a more integrated experience for end users but is something to note as not many other language servers work in this way.
123+
It is handled within the same process as the Language Server Protocol.
124+
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.
111125
If you want to take advantage of debugging,
112126
your client must support the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/).
113127
Your client should use the path to the debug named pipe found in the `session.json` file talked about above.
114128

115129
Currently, only the Visual Studio Code extension supports debugging.
116130

117-
### Stdio
118-
119-
Stdio is a simpler and more universal mechanism for the Language Server Protocol. We recommend using it if your editor/client doesn't need to support the PowerShell Extension Terminal or debugging.
120-
121-
> NOTE: Debugging and the Extension Terminal are not features of the Stdio channel because each feature requires its own IO streams and since the Stdio model only provides a single set of streams (Stdio),
122-
> these features cannot be leveraged.
123-
124-
The typical command to start PowerShell Editor Services using stdio is as follows:
125-
126-
```powershell
127-
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"
128-
```
129-
130-
> NOTE: In the example above,
131-
>
132-
> - `$PSES_BUNDLE_PATH` is the root of the PowerShellEditorServices.zip downloaded from the GitHub releases.
133-
> - `$SESSION_TEMP_PATH` is the folder path that you'll use for this specific editor session.
134-
135-
The important flag is the `-Stdio` flag which enables this communication protocol.
136-
137-
Currently, the Emacs extension uses Stdio.
138-
139-
### API Usage
131+
## API Usage
140132

141133
Please note that we only consider the following as stable APIs that can be relied on:
142134

143-
- Language server protocol connection
144-
- Debug adapter protocol connection
145-
- Start up mechanism
135+
- Language Server Protocol connection
136+
- Debug Adapter Protocol connection
137+
- Start-up mechanism
146138

147139
The types of PowerShell Editor Services can change at any moment and should not be linked against in a production environment.
148140

0 commit comments

Comments
 (0)