Skip to content

Commit

Permalink
feat: add _typescript.configurePlugin workspace command (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Oct 11, 2022
1 parent c6b3947 commit 59a5217
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,20 @@ Most of the time, you'll execute commands with arguments retrieved from another
void
```

### Configure plugin

- Request:
```ts
{
command: `_typescript.configurePlugin`
arguments: [pluginName: string, configuration: any]
}
```
- Response:
```ts
void
```

## Inlay hints (`typescript/inlayHints`) (experimental)

> !!! This implementation is deprecated. Use the spec-compliant `textDocument/inlayHint` request instead. !!!
Expand Down
1 change: 1 addition & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Commands = {
APPLY_WORKSPACE_EDIT: '_typescript.applyWorkspaceEdit',
APPLY_CODE_ACTION: '_typescript.applyCodeAction',
APPLY_REFACTORING: '_typescript.applyRefactoring',
CONFIGURE_PLUGIN: '_typescript.configurePlugin',
ORGANIZE_IMPORTS: '_typescript.organizeImports',
APPLY_RENAME_FILE: '_typescript.applyRenameFile',
APPLY_COMPLETION_CODE_ACTION: '_typescript.applyCompletionCodeAction',
Expand Down
10 changes: 10 additions & 0 deletions src/lsp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export class LspServer {
Commands.APPLY_WORKSPACE_EDIT,
Commands.APPLY_CODE_ACTION,
Commands.APPLY_REFACTORING,
Commands.CONFIGURE_PLUGIN,
Commands.ORGANIZE_IMPORTS,
Commands.APPLY_RENAME_FILE,
Commands.SOURCE_DEFINITION,
Expand Down Expand Up @@ -919,6 +920,15 @@ export class LspServer {
position: Position.fromLocation(renameLocation),
});
}
} else if (arg.command === Commands.CONFIGURE_PLUGIN && arg.arguments) {
const [pluginName, configuration] = arg.arguments as [string, unknown];

if (this.tspClient?.apiVersion.gte(API.v314)) {
this.tspClient.executeWithoutWaitingForResponse(CommandTypes.ConfigurePlugin, {
configuration,
pluginName,
});
}
} else if (arg.command === Commands.ORGANIZE_IMPORTS && arg.arguments) {
const file = arg.arguments[0] as string;
const additionalArguments: { skipDestructiveCodeActions?: boolean; } = arg.arguments[1] || {};
Expand Down
1 change: 1 addition & 0 deletions src/tsServer/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface TypeScriptRequestTypes {
[CommandTypes.CompletionDetails]: [tsp.CompletionDetailsRequestArgs, tsp.CompletionDetailsResponse];
[CommandTypes.CompletionInfo]: [tsp.CompletionsRequestArgs, tsp.CompletionInfoResponse];
[CommandTypes.Configure]: [tsp.ConfigureRequestArguments, tsp.ConfigureResponse];
[CommandTypes.ConfigurePlugin]: [tsp.ConfigurePluginRequestArguments, tsp.ConfigurePluginResponse];
[CommandTypes.Definition]: [tsp.FileLocationRequestArgs, tsp.DefinitionResponse];
[CommandTypes.DefinitionAndBoundSpan]: [tsp.FileLocationRequestArgs, tsp.DefinitionInfoAndBoundSpanResponse];
[CommandTypes.DocCommentTemplate]: [tsp.FileLocationRequestArgs, tsp.DocCommandTemplateResponse];
Expand Down

0 comments on commit 59a5217

Please sign in to comment.