mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
LSP Example for Log Streaming
This is a repository adapted from lsp-sample to demonstrate
- Usage of the JSON output
- Streaming the JSON into LSP Inspector
Synopsis
- With
vscode-languageclient@5.1.0-next.9, you can specify a JSON log output format with[langId].trace.serveras follows:"languageServerExample.trace.server": { "format": "json", "verbosity": "verbose" } - A webview build of the LSP Inspector can be downloaded here:
- When using the Webview LSP Inspector, it will open a WebSocket Server taking incoming connection that sends logs following this format.
- You can stream the JSON log of any Language Server using
vscode-languageclientto the LSP Inspector, and it will show a live view of the LSP connection.
Functionality
This Language Server works for plain text file. It has the following language features:
- Completions
- Diagnostics regenerated on each file change or configuration change
It also includes an End-to-End test.
Structure
.
├── client // Language Client
│ ├── src
│ │ ├── test // End to End tests for Language Client / Server
│ │ └── extension.ts // Language Client entry point
├── package.json // The extension manifest.
└── server // Language Server
└── src
└── server.ts // Language Server entry point
Compile and Run
- Run
npm installin this folder. This installs all necessary npm modules in both the client and server folder - Open VS Code on this folder.
- Press Ctrl+Shift+B to compile the client and server.
- Switch to the Debug viewlet.
- Select
Launch Clientfrom the drop down. - Run the lauch config.
- If you want to debug the server as well use the launch configuration
Attach to Server - In the [Extension Development Host] instance of VSCode, open a document in 'plain text' language mode.
- Type
jortto seeJavascriptandTypeScriptcompletion. - Enter text content such as
AAA aaa BBB. The extension will emit diagnostics for all words in all-uppercase.
- Type