From 1da34f09fee1ce650108367e266ddcb917604f01 Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Sat, 24 Oct 2020 18:07:35 +0800 Subject: [PATCH 1/5] typescript signature help --- .../language-server/src/plugins/PluginHost.ts | 21 ++- .../language-server/src/plugins/interfaces.ts | 16 +- .../plugins/typescript/TypeScriptPlugin.ts | 16 +- .../features/SignatureHelpProvider.ts | 141 ++++++++++++++++++ packages/language-server/src/server.ts | 10 +- 5 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts diff --git a/packages/language-server/src/plugins/PluginHost.ts b/packages/language-server/src/plugins/PluginHost.ts index b631d61d8..f8a084149 100644 --- a/packages/language-server/src/plugins/PluginHost.ts +++ b/packages/language-server/src/plugins/PluginHost.ts @@ -21,7 +21,9 @@ import { FormattingOptions, ReferenceContext, Location, - SelectionRange + SelectionRange, + SignatureHelp, + SignatureHelpContext } from 'vscode-languageserver'; import { LSConfig, LSConfigManager } from '../ls-config'; import { DocumentManager } from '../lib/documents'; @@ -347,6 +349,23 @@ export class PluginHost implements LSProvider, OnWatchFileChanges { ); } + async getSignatureHelp( + textDocument: TextDocumentIdentifier, + position: Position, + context: SignatureHelpContext | undefined + ): Promise { + const document = this.getDocument(textDocument.uri); + if (!document) { + throw new Error('Cannot call methods on an unopened document'); + } + + return await this.execute( + 'getSignatureHelp', + [document, position, context], + ExecuteMode.FirstNonNull + ); + } + /** * The selection range supports multiple cursors, * each position should return its own selection range tree like `Array.map`. diff --git a/packages/language-server/src/plugins/interfaces.ts b/packages/language-server/src/plugins/interfaces.ts index a89c4a4a6..52358bb93 100644 --- a/packages/language-server/src/plugins/interfaces.ts +++ b/packages/language-server/src/plugins/interfaces.ts @@ -1,4 +1,4 @@ -import { CompletionContext, FileChangeType } from 'vscode-languageserver'; +import { CompletionContext, FileChangeType, SignatureHelpContext } from 'vscode-languageserver'; import { CodeAction, CodeActionContext, @@ -19,7 +19,8 @@ import { TextDocumentIdentifier, TextEdit, WorkspaceEdit, - SelectionRange + SelectionRange, + SignatureHelp } from 'vscode-languageserver-types'; import { Document } from '../lib/documents'; @@ -128,6 +129,14 @@ export interface FindReferencesProvider { ): Promise; } +export interface SignatureHelpProvider { + getSignatureHelp( + document: Document, + position: Position, + context: SignatureHelpContext | undefined + ): Resolvable +} + export interface SelectionRangeProvider { getSelectionRange(document: Document, position: Position): Resolvable; } @@ -147,7 +156,8 @@ type ProviderBase = DiagnosticsProvider & UpdateImportsProvider & CodeActionsProvider & FindReferencesProvider & - RenameProvider; + RenameProvider & + SignatureHelpProvider; export type LSProvider = ProviderBase & BackwardsCompatibleDefinitionsProvider; diff --git a/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts b/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts index a7bce1bbf..c03a694e0 100644 --- a/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts +++ b/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts @@ -15,7 +15,9 @@ import { SymbolInformation, WorkspaceEdit, CompletionList, - SelectionRange + SelectionRange, + SignatureHelp, + SignatureHelpContext } from 'vscode-languageserver'; import { Document, @@ -38,7 +40,9 @@ import { HoverProvider, OnWatchFileChanges, RenameProvider, + Resolvable, SelectionRangeProvider, + SignatureHelpProvider, UpdateImportsProvider } from '../interfaces'; import { SnapshotFragment } from './DocumentSnapshot'; @@ -56,6 +60,7 @@ import { convertToLocationRange, getScriptKindFromFileName, symbolKindFromString import { getDirectiveCommentCompletions } from './features/getDirectiveCommentCompletions'; import { FindReferencesProviderImpl } from './features/FindReferencesProvider'; import { SelectionRangeProviderImpl } from './features/SelectionRangeProvider'; +import { SignatureHelpProviderImpl } from './features/SignatureHelpProvider'; export class TypeScriptPlugin implements @@ -68,6 +73,7 @@ export class TypeScriptPlugin RenameProvider, FindReferencesProvider, SelectionRangeProvider, + SignatureHelpProvider, OnWatchFileChanges, CompletionsProvider { private readonly configManager: LSConfigManager; @@ -80,6 +86,7 @@ export class TypeScriptPlugin private readonly hoverProvider: HoverProviderImpl; private readonly findReferencesProvider: FindReferencesProviderImpl; private readonly selectionRangeProvider: SelectionRangeProviderImpl; + private readonly signatureHelpProvider: SignatureHelpProviderImpl; constructor( docManager: DocumentManager, @@ -99,6 +106,7 @@ export class TypeScriptPlugin this.hoverProvider = new HoverProviderImpl(this.lsAndTsDocResolver); this.findReferencesProvider = new FindReferencesProviderImpl(this.lsAndTsDocResolver); this.selectionRangeProvider = new SelectionRangeProviderImpl(this.lsAndTsDocResolver); + this.signatureHelpProvider = new SignatureHelpProviderImpl(this.lsAndTsDocResolver); } async getDiagnostics(document: Document): Promise { @@ -365,6 +373,12 @@ export class TypeScriptPlugin return this.selectionRangeProvider.getSelectionRange(document, position); } + getSignatureHelp( + document: Document, position: Position, context: SignatureHelpContext | undefined + ): Resolvable { + return this.signatureHelpProvider.getSignatureHelp(document, position, context); + } + private getLSAndTSDoc(document: Document) { return this.lsAndTsDocResolver.getLSAndTSDoc(document); } diff --git a/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts b/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts new file mode 100644 index 000000000..937d2336b --- /dev/null +++ b/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts @@ -0,0 +1,141 @@ +import ts from 'typescript'; +import { + Position, + SignatureHelpContext, + SignatureHelp, + SignatureHelpTriggerKind, + SignatureInformation, + ParameterInformation +} from 'vscode-languageserver'; +import { SignatureHelpProvider } from '../..'; +import { Document } from '../../../lib/documents'; +import { LSAndTSDocResolver } from '../LSAndTSDocResolver'; +import { getMarkdownDocumentation, plain } from '../previewer'; + +export class SignatureHelpProviderImpl implements SignatureHelpProvider { + constructor(private readonly lsAndTsDocResolver: LSAndTSDocResolver) {} + + private static readonly triggerCharacters = ['(', ',', '<']; + private static readonly retriggerCharacters = [')']; + + async getSignatureHelp( + document: Document, + position: Position, + context: SignatureHelpContext | undefined + ): Promise { + const { lang, tsDoc } = this.lsAndTsDocResolver.getLSAndTSDoc(document); + const fragment = await tsDoc.getFragment(); + + const offset = fragment.offsetAt(fragment.getGeneratedPosition(position)); + const triggerReason = this.toTsTriggerReason(context); + const info = lang.getSignatureHelpItems( + tsDoc.filePath, + offset, + triggerReason ? { triggerReason } : undefined + ); + if ( + !info || + info.items.some((signature) => this.isInSvelte2tsxGeneratedFunction(signature)) + ) { + return null; + } + + const signatures = info.items + .map(this.toSignatureHelpInfomation); + + return { + signatures, + activeSignature: info.selectedItemIndex, + activeParameter: info.argumentIndex + }; + } + + isReTrigger( + isRetrigger: boolean, + triggerCharacter: string + ): triggerCharacter is ts.SignatureHelpRetriggerCharacter { + return ( + isRetrigger && + (this.isTriggerCharacter(triggerCharacter) || + SignatureHelpProviderImpl.retriggerCharacters.includes(triggerCharacter)) + ); + } + + isTriggerCharacter( + triggerCharacter: string + ): triggerCharacter is ts.SignatureHelpTriggerCharacter { + return SignatureHelpProviderImpl.triggerCharacters.includes(triggerCharacter); + } + + private toTsTriggerReason( + context: SignatureHelpContext | undefined + ): ts.SignatureHelpTriggerReason { + switch (context?.triggerKind) { + case SignatureHelpTriggerKind.TriggerCharacter: + if (context.triggerCharacter) { + if (this.isReTrigger(context.isRetrigger, context.triggerCharacter)) { + return { kind: 'retrigger', triggerCharacter: context.triggerCharacter }; + } + if (this.isTriggerCharacter(context.triggerCharacter)) { + return { + kind: 'characterTyped', + triggerCharacter: context.triggerCharacter + }; + } + } + return { kind: 'invoked' }; + case SignatureHelpTriggerKind.ContentChange: + return context.isRetrigger ? { kind: 'retrigger' } : { kind: 'invoked' }; + + case SignatureHelpTriggerKind.Invoked: + default: + return { kind: 'invoked' }; + } + } + + private toSignatureHelpInfomation(item: ts.SignatureHelpItem): SignatureInformation { + const [prefixLabel, seperatorLabel, suffixLabel] = [ + item.prefixDisplayParts, + item.separatorDisplayParts, + item.suffixDisplayParts + ].map(ts.displayPartsToString); + + let textIndex = prefixLabel.length; + let signatureLabel = ''; + const parameters: ParameterInformation[] = []; + const lastIndex = item.parameters.length - 1; + + item.parameters.forEach((parameter, index) => { + const label = ts.displayPartsToString(parameter.displayParts); + + const startIndex = textIndex; + const endIndex = textIndex + label.length; + const doc = plain(parameter.documentation); + + signatureLabel += label; + parameters.push(ParameterInformation.create([startIndex, endIndex], doc)); + + if (index < lastIndex) { + textIndex = endIndex + seperatorLabel.length; + signatureLabel += signatureLabel; + } + }); + const signatureDocumentation = getMarkdownDocumentation( + item.documentation, + item.tags.filter((tag) => tag.name !== 'param') + ); + + return SignatureInformation.create( + prefixLabel + signatureLabel + suffixLabel, + signatureDocumentation, + ...parameters + ); + } + + private isInSvelte2tsxGeneratedFunction( + signatureHelpItem: ts.SignatureHelpItem + ) { + return ts.displayPartsToString(signatureHelpItem.prefixDisplayParts) + .includes('__sveltets'); + } +} diff --git a/packages/language-server/src/server.ts b/packages/language-server/src/server.ts index def4c1159..8e8096e2b 100644 --- a/packages/language-server/src/server.ts +++ b/packages/language-server/src/server.ts @@ -189,7 +189,11 @@ export function startServer(options?: LSOptions) { ? { prepareProvider: true } : true, referencesProvider: true, - selectionRangeProvider: true + selectionRangeProvider: true, + signatureHelpProvider: { + triggerCharacters: ['(', ',', '<'], + retriggerCharacters: [')'] + } } }; }); @@ -262,6 +266,10 @@ export function startServer(options?: LSOptions) { return pluginHost.resolveCompletion(data, completionItem); }); + connection.onSignatureHelp((evt) => + pluginHost.getSignatureHelp(evt.textDocument, evt.position, evt.context) + ); + connection.onSelectionRanges((evt) => pluginHost.getSelectionRanges(evt.textDocument, evt.positions) ); From a0623cffa8d597561bce509a79a750a23e6f8305 Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Tue, 3 Nov 2020 14:16:15 +0800 Subject: [PATCH 2/5] test --- .../language-server/src/plugins/PluginHost.ts | 2 +- .../features/SignatureHelpProvider.ts | 40 ++++---- .../features/SignatureHelpProvider.test.ts | 96 +++++++++++++++++++ .../signature-help/signature-help.svelte | 21 ++++ 4 files changed, 140 insertions(+), 19 deletions(-) create mode 100644 packages/language-server/test/plugins/typescript/features/SignatureHelpProvider.test.ts create mode 100644 packages/language-server/test/plugins/typescript/testfiles/signature-help/signature-help.svelte diff --git a/packages/language-server/src/plugins/PluginHost.ts b/packages/language-server/src/plugins/PluginHost.ts index f8a084149..040d72c7a 100644 --- a/packages/language-server/src/plugins/PluginHost.ts +++ b/packages/language-server/src/plugins/PluginHost.ts @@ -351,7 +351,7 @@ export class PluginHost implements LSProvider, OnWatchFileChanges { async getSignatureHelp( textDocument: TextDocumentIdentifier, - position: Position, + position: Position, context: SignatureHelpContext | undefined ): Promise { const document = this.getDocument(textDocument.uri); diff --git a/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts b/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts index 937d2336b..b88f66626 100644 --- a/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts @@ -5,15 +5,16 @@ import { SignatureHelp, SignatureHelpTriggerKind, SignatureInformation, - ParameterInformation + ParameterInformation, + MarkupKind } from 'vscode-languageserver'; import { SignatureHelpProvider } from '../..'; import { Document } from '../../../lib/documents'; import { LSAndTSDocResolver } from '../LSAndTSDocResolver'; -import { getMarkdownDocumentation, plain } from '../previewer'; +import { getMarkdownDocumentation } from '../previewer'; export class SignatureHelpProviderImpl implements SignatureHelpProvider { - constructor(private readonly lsAndTsDocResolver: LSAndTSDocResolver) {} + constructor(private readonly lsAndTsDocResolver: LSAndTSDocResolver) { } private static readonly triggerCharacters = ['(', ',', '<']; private static readonly retriggerCharacters = [')']; @@ -41,7 +42,7 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { } const signatures = info.items - .map(this.toSignatureHelpInfomation); + .map(this.toSignatureHelpInformation); return { signatures, @@ -50,7 +51,7 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { }; } - isReTrigger( + private isReTrigger( isRetrigger: boolean, triggerCharacter: string ): triggerCharacter is ts.SignatureHelpRetriggerCharacter { @@ -61,7 +62,7 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { ); } - isTriggerCharacter( + private isTriggerCharacter( triggerCharacter: string ): triggerCharacter is ts.SignatureHelpTriggerCharacter { return SignatureHelpProviderImpl.triggerCharacters.includes(triggerCharacter); @@ -93,8 +94,8 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { } } - private toSignatureHelpInfomation(item: ts.SignatureHelpItem): SignatureInformation { - const [prefixLabel, seperatorLabel, suffixLabel] = [ + private toSignatureHelpInformation(item: ts.SignatureHelpItem): SignatureInformation { + const [prefixLabel, separatorLabel, suffixLabel] = [ item.prefixDisplayParts, item.separatorDisplayParts, item.suffixDisplayParts @@ -110,14 +111,14 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { const startIndex = textIndex; const endIndex = textIndex + label.length; - const doc = plain(parameter.documentation); + const doc = ts.displayPartsToString(parameter.documentation); signatureLabel += label; parameters.push(ParameterInformation.create([startIndex, endIndex], doc)); if (index < lastIndex) { - textIndex = endIndex + seperatorLabel.length; - signatureLabel += signatureLabel; + textIndex = endIndex + separatorLabel.length; + signatureLabel += separatorLabel; } }); const signatureDocumentation = getMarkdownDocumentation( @@ -125,17 +126,20 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { item.tags.filter((tag) => tag.name !== 'param') ); - return SignatureInformation.create( - prefixLabel + signatureLabel + suffixLabel, - signatureDocumentation, - ...parameters - ); + return { + label: prefixLabel + signatureLabel + suffixLabel, + documentation: signatureDocumentation ? { + value: signatureDocumentation, + kind: MarkupKind.Markdown + } : undefined, + parameters + }; } private isInSvelte2tsxGeneratedFunction( signatureHelpItem: ts.SignatureHelpItem ) { - return ts.displayPartsToString(signatureHelpItem.prefixDisplayParts) - .includes('__sveltets'); + return signatureHelpItem.prefixDisplayParts + .some((part) => part.text.includes('__sveltets')); } } diff --git a/packages/language-server/test/plugins/typescript/features/SignatureHelpProvider.test.ts b/packages/language-server/test/plugins/typescript/features/SignatureHelpProvider.test.ts new file mode 100644 index 000000000..909e2f144 --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/SignatureHelpProvider.test.ts @@ -0,0 +1,96 @@ +import path from 'path'; +import assert from 'assert'; +import ts from 'typescript'; +import { MarkupKind, Position, SignatureHelp } from 'vscode-languageserver'; +import { Document, DocumentManager } from '../../../../src/lib/documents'; +import { SignatureHelpProviderImpl } from '../../../../src/plugins/typescript/features/SignatureHelpProvider'; +import { LSAndTSDocResolver } from '../../../../src/plugins/typescript/LSAndTSDocResolver'; +import { pathToUrl } from '../../../../src/utils'; + +const testDir = path.join(__dirname, '..'); + +describe('SignatureHelpProvider', () => { + function setup() { + const docManager = new DocumentManager( + (textDocument) => new Document(textDocument.uri, textDocument.text) + ); + const filePath = path.join( + testDir, + 'testfiles', + 'signature-help', + 'signature-help.svelte' + ); + const lsAndTsDocResolver = new LSAndTSDocResolver(docManager, [pathToUrl(testDir)]); + const provider = new SignatureHelpProviderImpl(lsAndTsDocResolver); + const document = docManager.openDocument({ + uri: pathToUrl(filePath), + text: ts.sys.readFile(filePath) + }); + return { provider, document }; + } + + it('provide signature help with formatted documentation', async () => { + const { provider, document } = setup(); + + const result = await provider.getSignatureHelp(document, Position.create(3, 8), undefined); + + assert.deepStrictEqual(result, { + signatures: [ + { + label: 'foo(): boolean', + documentation: { value: 'bars\n\n*@author* — John', kind: MarkupKind.Markdown }, + parameters: [] + } + ], + activeParameter: 0, + activeSignature: 0 + }); + }); + + it('provide signature help with function signatures', async () => { + const { provider, document } = setup(); + + const result = await provider.getSignatureHelp(document, Position.create(4, 12), undefined); + + assert.deepStrictEqual(result, { + signatures: [ + { + label: 'abc(a: number, b: number): string', + documentation: undefined, + parameters: [ + { + label: [4, 13] + }, + { + label: [15, 24] + } + ] + }, + { + label: 'abc(a: number, b: string): string', + documentation: undefined, + parameters: [ + { + label: [4, 13] + }, + { + label: [15, 24], + documentation: 'formatted number' + } + ] + } + ], + activeParameter: 1, + activeSignature: 1 + }); + }); + + it('filter out svelte2tsx signature', async () => { + const { provider, document } = setup(); + + const result = await provider.getSignatureHelp( + document, Position.create(18, 18), undefined); + + assert.equal(result, null); + }); +}); diff --git a/packages/language-server/test/plugins/typescript/testfiles/signature-help/signature-help.svelte b/packages/language-server/test/plugins/typescript/testfiles/signature-help/signature-help.svelte new file mode 100644 index 000000000..6c65c1ea5 --- /dev/null +++ b/packages/language-server/test/plugins/typescript/testfiles/signature-help/signature-help.svelte @@ -0,0 +1,21 @@ + + +{#each items as item} + {item} +{/each} From d25ff905ab8a5c8226d990761dc425d88a4a6cab Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Wed, 4 Nov 2020 13:29:10 +0800 Subject: [PATCH 3/5] credit --- .../plugins/typescript/features/SignatureHelpProvider.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts b/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts index b88f66626..f8b7355c8 100644 --- a/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts @@ -68,6 +68,9 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { return SignatureHelpProviderImpl.triggerCharacters.includes(triggerCharacter); } + /** + * adopted from https://github.com/microsoft/vscode/blob/265a2f6424dfbd3a9788652c7d376a7991d049a3/extensions/typescript-language-features/src/languageFeatures/signatureHelp.ts#L103 + */ private toTsTriggerReason( context: SignatureHelpContext | undefined ): ts.SignatureHelpTriggerReason { @@ -94,6 +97,9 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider { } } + /** + * adopted from https://github.com/microsoft/vscode/blob/265a2f6424dfbd3a9788652c7d376a7991d049a3/extensions/typescript-language-features/src/languageFeatures/signatureHelp.ts#L73 + */ private toSignatureHelpInformation(item: ts.SignatureHelpItem): SignatureInformation { const [prefixLabel, separatorLabel, suffixLabel] = [ item.prefixDisplayParts, From 64caa5af37b2557500698bfae1ba5bf39a65602b Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Wed, 4 Nov 2020 13:29:32 +0800 Subject: [PATCH 4/5] config --- packages/language-server/src/ls-config.ts | 6 +++++- .../src/plugins/typescript/TypeScriptPlugin.ts | 4 ++++ packages/svelte-vscode/README.md | 6 +++++- packages/svelte-vscode/package.json | 12 +++++++++--- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/language-server/src/ls-config.ts b/packages/language-server/src/ls-config.ts index 5bb2d1c4e..ccde02d79 100644 --- a/packages/language-server/src/ls-config.ts +++ b/packages/language-server/src/ls-config.ts @@ -14,7 +14,8 @@ const defaultLSConfig: LSConfig = { documentSymbols: { enable: true }, codeActions: { enable: true }, rename: { enable: true }, - selectionRange: { enable: true } + selectionRange: { enable: true }, + signatureHelp: { enable: true } }, css: { enable: true, @@ -87,6 +88,9 @@ export interface LSTypescriptConfig { selectionRange: { enable: boolean; }; + signatureHelp: { + enable: boolean; + } } export interface LSCSSConfig { diff --git a/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts b/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts index d886554c2..803a025c4 100644 --- a/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts +++ b/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts @@ -391,6 +391,10 @@ export class TypeScriptPlugin getSignatureHelp( document: Document, position: Position, context: SignatureHelpContext | undefined ): Resolvable { + if (!this.featureEnabled('signatureHelp')) { + return null; + } + return this.signatureHelpProvider.getSignatureHelp(document, position, context); } diff --git a/packages/svelte-vscode/README.md b/packages/svelte-vscode/README.md index b2894fd1f..a6b96a363 100644 --- a/packages/svelte-vscode/README.md +++ b/packages/svelte-vscode/README.md @@ -98,7 +98,7 @@ Enable go to definition for TypeScript. _Default_: `true` Enable code actions for TypeScript. _Default_: `true` -##### `svelte.plugin.typescript.codeActions` +##### `svelte.plugin.typescript.selectionRange` Enable selection range for TypeScript. _Default_: `true` @@ -106,6 +106,10 @@ Enable selection range for TypeScript. _Default_: `true` Enable rename functionality for JS/TS variables inside Svelte files. _Default_: `true` +##### `svelte.plugin.typescript.signatureHelp.enable` + +Enable signature help (parameter hints) for JS/TS. _Default_: `true` + ##### `svelte.plugin.css.enable` Enable the CSS plugin. _Default_: `true` diff --git a/packages/svelte-vscode/package.json b/packages/svelte-vscode/package.json index d2868ca09..c73dadb72 100644 --- a/packages/svelte-vscode/package.json +++ b/packages/svelte-vscode/package.json @@ -113,9 +113,15 @@ "svelte.plugin.typescript.selectionRange.enable": { "type": "boolean", "default": true, - "title": "TypeScript: SelectionRange", + "title": "TypeScript: Selection Range", "description": "Enable selection range for TypeScript" }, + "svelte.plugin.typescript.signatureHelp.enable": { + "type": "boolean", + "default": true, + "title": "TypeScript: Signature Help", + "description": "Enable signature help (parameter hints) for TypeScript" + }, "svelte.plugin.typescript.rename.enable": { "type": "boolean", "default": true, @@ -308,7 +314,7 @@ "source.ts": "typescript", "text.pug": "jade" } - }, + }, { "scopeName": "svelte.pug.tags", "path": "./syntaxes/pug-svelte-tags.json", @@ -319,7 +325,7 @@ "source.ts": "typescript", "text.pug": "jade" } - }, + }, { "scopeName": "svelte.pug.dotblock", "path": "./syntaxes/pug-svelte-dotblock.json", From cb8472d6e1283221e6179d2a8c32c77e125c0f30 Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Wed, 4 Nov 2020 15:24:38 +0800 Subject: [PATCH 5/5] tweak --- .../src/plugins/typescript/TypeScriptPlugin.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts b/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts index 803a025c4..0ceef118c 100644 --- a/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts +++ b/packages/language-server/src/plugins/typescript/TypeScriptPlugin.ts @@ -40,7 +40,6 @@ import { HoverProvider, OnWatchFileChanges, RenameProvider, - Resolvable, SelectionRangeProvider, SignatureHelpProvider, UpdateImportsProvider, @@ -388,9 +387,9 @@ export class TypeScriptPlugin return this.selectionRangeProvider.getSelectionRange(document, position); } - getSignatureHelp( + async getSignatureHelp( document: Document, position: Position, context: SignatureHelpContext | undefined - ): Resolvable { + ): Promise { if (!this.featureEnabled('signatureHelp')) { return null; }