Use TS for examples

This commit is contained in:
Christopher Schleiden
2023-01-25 09:15:22 -08:00
parent 5984871a7c
commit 9ae4b7d9c9
2 changed files with 7 additions and 9 deletions
+5 -7
View File
@@ -16,9 +16,9 @@ npm install @actions/languageserver
For the server, import the module. It detects whether it's running in a Node.js environment or a web worker and initializes the appropriate connection. For the server, import the module. It detects whether it's running in a Node.js environment or a web worker and initializes the appropriate connection.
`server.js`: `server.ts`:
```js ```typescript
import "@actions/languageserver"; import "@actions/languageserver";
``` ```
@@ -26,7 +26,7 @@ For the client, create a new `LanguageClient` pointing to the server module.
`client.ts`: `client.ts`:
```js ```typescript
import {LanguageClient, ServerOptions, TransportKind} from "vscode-languageclient/node"; import {LanguageClient, ServerOptions, TransportKind} from "vscode-languageclient/node";
const debugOptions = {execArgv: ["--nolazy", "--inspect=6010"]}; const debugOptions = {execArgv: ["--nolazy", "--inspect=6010"]};
@@ -34,8 +34,7 @@ const debugOptions = {execArgv: ["--nolazy", "--inspect=6010"]};
const clientOptions: LanguageClientOptions = { const clientOptions: LanguageClientOptions = {
documentSelector: [{ documentSelector: [{
pattern: "**/.github/workflows/*.{yaml,yml}" pattern: "**/.github/workflows/*.{yaml,yml}"
}], }]
progressOnInitialization: true
}; };
const serverModule = context.asAbsolutePath(path.join("dist", "server.js")); const serverModule = context.asAbsolutePath(path.join("dist", "server.js"));
@@ -87,8 +86,7 @@ const clientOptions: LanguageClientOptions = {
documentSelector: [{ documentSelector: [{
pattern: "**/.github/workflows/*.{yaml,yml}" pattern: "**/.github/workflows/*.{yaml,yml}"
}], }],
initializationOptions: initializationOptions, initializationOptions: initializationOptions
progressOnInitialization: true
}; };
const client = new LanguageClient("actions-language", "GitHub Actions Language Server", serverOptions, clientOptions); const client = new LanguageClient("actions-language", "GitHub Actions Language Server", serverOptions, clientOptions);
+2 -2
View File
@@ -34,7 +34,7 @@ TODO
Validate a workflow file, returns an array of [`Diagnostic`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic) objects. Validate a workflow file, returns an array of [`Diagnostic`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic) objects.
```js ```typescript
const config: ValidationConfig = { const config: ValidationConfig = {
valueProviderConfig: valueProviders(sessionToken, repoContext, cache), valueProviderConfig: valueProviders(sessionToken, repoContext, cache),
contextProviderConfig: contextProviders(sessionToken, repoContext, cache), contextProviderConfig: contextProviders(sessionToken, repoContext, cache),
@@ -47,7 +47,7 @@ const result = await validate(textDocument, config); // result is an array of `D
Get information when [hovering](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_hover) over a token in the workflow file. Get information when [hovering](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_hover) over a token in the workflow file.
```js ```typescript
import {hover} from "@actions/languageservice"; import {hover} from "@actions/languageservice";
const document = { const document = {