Skip to content

Commit

Permalink
feat(lsp): inlineCompletion
Browse files Browse the repository at this point in the history
Closes #5071
  • Loading branch information
fannheyward committed Jul 23, 2024
1 parent 33d0a52 commit 7ac7233
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 79 deletions.
40 changes: 22 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"eslint-plugin-jsdoc": "^48.5.0",
"jest": "29.7.0",
"typescript": "^5.5.3",
"vscode-languageserver": "^9.0.1"
"vscode-languageserver": "^10.0.0-next.7"
},
"dependencies": {
"@chemzqm/neovim": "^6.1.2",
Expand All @@ -108,9 +108,9 @@
"unidecode": "^1.0.1",
"unzip-stream": "^0.3.4",
"uuid": "^9.0.1",
"vscode-languageserver-protocol": "^3.17.5",
"vscode-languageserver-protocol": "^3.17.6-next.7",
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-languageserver-types": "^3.17.5",
"vscode-languageserver-types": "^3.17.6-next.4",
"vscode-uri": "^3.0.8",
"which": "^4.0.0"
}
Expand Down
7 changes: 5 additions & 2 deletions src/language-client/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
import type { ApplyWorkspaceEditParams, ApplyWorkspaceEditResult, CallHierarchyPrepareRequest, CancellationStrategy, CancellationToken, ClientCapabilities, CodeActionRequest, CodeLensRequest, CompletionRequest, ConfigurationRequest, ConnectionStrategy, DeclarationRequest, DefinitionRequest, DidChangeConfigurationNotification, DidChangeConfigurationRegistrationOptions, DidChangeTextDocumentNotification, DidChangeWatchedFilesNotification, DidChangeWatchedFilesRegistrationOptions, DidChangeWorkspaceFoldersNotification, DidCloseTextDocumentNotification, DidCreateFilesNotification, DidDeleteFilesNotification, DidOpenTextDocumentNotification, DidRenameFilesNotification, DidSaveTextDocumentNotification, Disposable, DocumentColorRequest, DocumentDiagnosticRequest, DocumentFormattingRequest, DocumentHighlightRequest, DocumentLinkRequest, DocumentOnTypeFormattingRequest, DocumentRangeFormattingRequest, DocumentSelector, DocumentSymbolRequest, ExecuteCommandRegistrationOptions, ExecuteCommandRequest, FileOperationRegistrationOptions, FoldingRangeRequest, GenericNotificationHandler, GenericRequestHandler, HoverRequest, ImplementationRequest, InitializeParams, InitializeResult, InlineValueRequest, LinkedEditingRangeRequest, Message, MessageActionItem, MessageSignature, NotificationHandler, NotificationHandler0, NotificationType, NotificationType0, ProgressToken, ProgressType, ProtocolNotificationType, ProtocolNotificationType0, ProtocolRequestType, ProtocolRequestType0, PublishDiagnosticsParams, ReferencesRequest, RegistrationParams, RenameRequest, RequestHandler, RequestHandler0, RequestType, RequestType0, SelectionRangeRequest, SemanticTokensRegistrationType, ServerCapabilities, ShowDocumentParams, ShowDocumentResult, ShowMessageRequestParams, SignatureHelpRequest, TextDocumentRegistrationOptions, TextDocumentSyncOptions, TextEdit, TraceOptions, Tracer, TypeDefinitionRequest, TypeHierarchyPrepareRequest, UnregistrationParams, WillCreateFilesRequest, WillDeleteFilesRequest, WillRenameFilesRequest, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, WorkDoneProgressBegin, WorkDoneProgressCreateRequest, WorkDoneProgressEnd, WorkDoneProgressReport, WorkspaceEdit, WorkspaceSymbolRequest } from 'vscode-languageserver-protocol'
import type { ApplyWorkspaceEditParams, ApplyWorkspaceEditResult, CallHierarchyPrepareRequest, CancellationStrategy, CancellationToken, ClientCapabilities, CodeActionRequest, CodeLensRequest, CompletionRequest, ConfigurationRequest, ConnectionStrategy, DeclarationRequest, DefinitionRequest, DidChangeConfigurationNotification, DidChangeConfigurationRegistrationOptions, DidChangeTextDocumentNotification, DidChangeWatchedFilesNotification, DidChangeWatchedFilesRegistrationOptions, DidChangeWorkspaceFoldersNotification, DidCloseTextDocumentNotification, DidCreateFilesNotification, DidDeleteFilesNotification, DidOpenTextDocumentNotification, DidRenameFilesNotification, DidSaveTextDocumentNotification, Disposable, DocumentColorRequest, DocumentDiagnosticRequest, DocumentFormattingRequest, DocumentHighlightRequest, DocumentLinkRequest, DocumentOnTypeFormattingRequest, DocumentRangeFormattingRequest, DocumentSelector, DocumentSymbolRequest, ExecuteCommandRegistrationOptions, ExecuteCommandRequest, FileOperationRegistrationOptions, FoldingRangeRequest, GenericNotificationHandler, GenericRequestHandler, HoverRequest, ImplementationRequest, InitializeParams, InitializeResult, InlineCompletionRequest, InlineValueRequest, LinkedEditingRangeRequest, Message, MessageActionItem, MessageSignature, NotificationHandler, NotificationHandler0, NotificationType, NotificationType0, ProgressToken, ProgressType, ProtocolNotificationType, ProtocolNotificationType0, ProtocolRequestType, ProtocolRequestType0, PublishDiagnosticsParams, ReferencesRequest, RegistrationParams, RenameRequest, RequestHandler, RequestHandler0, RequestType, RequestType0, SelectionRangeRequest, SemanticTokensRegistrationType, ServerCapabilities, ShowDocumentParams, ShowDocumentResult, ShowMessageRequestParams, SignatureHelpRequest, TextDocumentRegistrationOptions, TextDocumentSyncOptions, TextEdit, TraceOptions, Tracer, TypeDefinitionRequest, TypeHierarchyPrepareRequest, UnregistrationParams, WillCreateFilesRequest, WillDeleteFilesRequest, WillRenameFilesRequest, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, WorkDoneProgressBegin, WorkDoneProgressCreateRequest, WorkDoneProgressEnd, WorkDoneProgressReport, WorkspaceEdit, WorkspaceSymbolRequest } from 'vscode-languageserver-protocol'
import { TextDocument } from "vscode-languageserver-textdocument"
import { Diagnostic, DiagnosticSeverity, DiagnosticTag, MarkupKind, TextDocumentEdit } from 'vscode-languageserver-types'
import { URI } from 'vscode-uri'
Expand Down Expand Up @@ -44,6 +44,7 @@ import { $FormattingOptions, DocumentFormattingFeature, DocumentOnTypeFormatting
import { HoverFeature, HoverMiddleware } from './hover'
import { ImplementationFeature, ImplementationMiddleware } from './implementation'
import { InlayHintsFeature, InlayHintsMiddleware, InlayHintsProviderShape } from './inlayHint'
import { InlineCompletionItemFeature, InlineCompletionMiddleware, InlineCompletionProviderShape } from './inlineCompletion'
import { InlineValueFeature, InlineValueMiddleware, InlineValueProviderShape } from './inlineValue'
import { LinkedEditingFeature, LinkedEditingRangeMiddleware } from './linkedEditingRange'
import { ProgressFeature } from './progress'
Expand Down Expand Up @@ -166,7 +167,7 @@ export type Middleware = _Middleware & TextDocumentSynchronizationMiddleware & S
HoverMiddleware & CompletionMiddleware & ExecuteCommandMiddleware & TypeDefinitionMiddleware &
ImplementationMiddleware & ColorProviderMiddleware & DeclarationMiddleware &
FoldingRangeProviderMiddleware & CallHierarchyMiddleware & SemanticTokensMiddleware &
InlayHintsMiddleware & InlineValueMiddleware & TypeHierarchyMiddleware &
InlayHintsMiddleware & InlineCompletionMiddleware & InlineValueMiddleware & TypeHierarchyMiddleware &
WorkspaceSymbolMiddleware & DiagnosticProviderMiddleware & LinkedEditingRangeMiddleware &
SelectionRangeProviderMiddleware

Expand Down Expand Up @@ -1405,6 +1406,7 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
public getFeature(request: typeof SemanticTokensRegistrationType.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<SemanticTokensProviderShape>
public getFeature(request: typeof LinkedEditingRangeRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<LinkedEditingRangeProvider>
public getFeature(request: typeof TypeHierarchyPrepareRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<TypeHierarchyProvider>
public getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<InlineCompletionProviderShape>
public getFeature(request: typeof InlineValueRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<InlineValueProviderShape>
public getFeature(request: typeof InlayHintRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<InlayHintsProviderShape>
public getFeature(request: typeof WorkspaceSymbolRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & WorkspaceProviderFeature<WorkspaceSymbolProvider>
Expand Down Expand Up @@ -1455,6 +1457,7 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
this.registerFeature(new WillDeleteFilesFeature(this), 'fileEvents')
this.registerFeature(new SemanticTokensFeature(this), 'semanticTokens')
this.registerFeature(new InlayHintsFeature(this), 'inlayHint')
this.registerFeature(new InlineCompletionItemFeature(this), 'inlineCompletion')
this.registerFeature(new InlineValueFeature(this), 'inlineValue')
this.registerFeature(new DiagnosticFeature(this), 'pullDiagnostic')
this.registerFeature(new TypeHierarchyFeature(this), 'typeHierarchy')
Expand Down
14 changes: 3 additions & 11 deletions src/language-client/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
DidChangeTextDocumentNotification, DidChangeWatchedFilesNotification, DidChangeWatchedFilesRegistrationOptions, DidChangeWorkspaceFoldersNotification, DidCloseTextDocumentNotification, DidCreateFilesNotification, DidDeleteFilesNotification, DidOpenTextDocumentNotification,
DidRenameFilesNotification, DidSaveTextDocumentNotification, Disposable, DocumentColorRequest, DocumentDiagnosticRequest, DocumentFormattingRequest, DocumentHighlightRequest,
DocumentLinkRequest, DocumentOnTypeFormattingRequest, DocumentRangeFormattingRequest, DocumentSelector, DocumentSymbolRequest, ExecuteCommandRegistrationOptions, ExecuteCommandRequest, FileOperationRegistrationOptions,
FoldingRangeRequest, GenericNotificationHandler, GenericRequestHandler, HoverRequest, ImplementationRequest, InitializeParams, InitializeResult, InlayHintRequest, InlineValueRequest,
FoldingRangeRequest, GenericNotificationHandler, GenericRequestHandler, HoverRequest, ImplementationRequest, InitializeParams, InitializeResult, InlayHintRequest, InlineCompletionRequest, InlineValueRequest,
LinkedEditingRangeRequest, MarkupKind, MessageSignature, NotificationHandler, NotificationHandler0,
NotificationType, NotificationType0, ProgressType, ProtocolNotificationType, ProtocolNotificationType0, ProtocolRequestType, ProtocolRequestType0, ReferencesRequest,
RegistrationType, RenameRequest, RequestHandler, RequestHandler0, RequestType, RequestType0, SelectionRangeRequest, SemanticTokensRegistrationType, ServerCapabilities,
Expand Down Expand Up @@ -174,14 +174,12 @@ export interface StaticFeature {
readonly method: string
/**
* Called to fill the initialize params.
*
* @params the initialize params.
*/
fillInitializeParams?: (params: InitializeParams) => void

/**
* Called to fill in the client capabilities this feature implements.
*
* @param capabilities The client capabilities to fill.
*/
fillClientCapabilities(capabilities: ClientCapabilities): void
Expand All @@ -190,7 +188,6 @@ export interface StaticFeature {
* A preflight where the server capabilities are shown to all features
* before a feature is actually initialized. This allows feature to
* capture some state if they are a pre-requisite for other features.
*
* @param capabilities the server capabilities
* @param documentSelector the document selector pass to the client's constructor.
* May be `undefined` if the client was created without a selector.
Expand All @@ -202,7 +199,6 @@ export interface StaticFeature {
* when the client has successfully received the initialize request from
* the server and before the client sends the initialized notification
* to the server.
*
* @param capabilities the server capabilities
* @param documentSelector the document selector pass to the client's constructor.
* May be `undefined` if the client was created without a selector.
Expand Down Expand Up @@ -237,14 +233,12 @@ export interface DynamicFeature<RO> {

/**
* Called to fill the initialize params.
*
* @params the initialize params.
*/
fillInitializeParams?: (params: InitializeParams) => void

/**
* Called to fill in the client capabilities this feature implements.
*
* @param capabilities The client capabilities to fill.
*/
fillClientCapabilities(capabilities: ClientCapabilities): void
Expand All @@ -253,7 +247,6 @@ export interface DynamicFeature<RO> {
* A preflight where the server capabilities are shown to all features
* before a feature is actually initialized. This allows feature to
* capture some state if they are a pre-requisite for other features.
*
* @param capabilities the server capabilities
* @param documentSelector the document selector pass to the client's constructor.
* May be `undefined` if the client was created without a selector.
Expand All @@ -265,7 +258,6 @@ export interface DynamicFeature<RO> {
* when the client has successfully received the initialize request from
* the server and before the client sends the initialized notification
* to the server.
*
* @param capabilities the server capabilities.
* @param documentSelector the document selector pass to the client's constructor.
* May be `undefined` if the client was created without a selector.
Expand All @@ -284,14 +276,12 @@ export interface DynamicFeature<RO> {

/**
* Is called when the server send a register request for the given message.
*
* @param data additional registration data as defined in the protocol.
*/
register(data: RegistrationData<RO>): void

/**
* Is called when the server wants to unregister a feature.
*
* @param id the id used when registering the feature.
*/
unregister(id: string): void
Expand Down Expand Up @@ -593,6 +583,7 @@ import { ProviderResult } from '../provider'
import { CodeLensProviderShape } from './codeLens'
import { DiagnosticProviderShape } from './diagnostic'
import { InlayHintsProviderShape } from './inlayHint'
import { InlineCompletionProviderShape } from './inlineCompletion'
import { InlineValueProviderShape } from './inlineValue'
import { SemanticTokensProviderShape } from './semanticTokens'
import { DidChangeTextDocumentFeatureShape, DidCloseTextDocumentFeatureShape, DidOpenTextDocumentFeatureShape, DidSaveTextDocumentFeatureShape } from './textSynchronization'
Expand Down Expand Up @@ -682,6 +673,7 @@ export interface FeatureClient<M, CO = object> {
getFeature(request: typeof SemanticTokensRegistrationType.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<SemanticTokensProviderShape>
getFeature(request: typeof LinkedEditingRangeRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<LinkedEditingRangeProvider>
getFeature(request: typeof TypeHierarchyPrepareRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<TypeHierarchyProvider>
getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<InlineCompletionProviderShape>
getFeature(request: typeof InlineValueRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<InlineValueProviderShape>
getFeature(request: typeof InlayHintRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<InlayHintsProviderShape>
getFeature(request: typeof WorkspaceSymbolRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & WorkspaceProviderFeature<WorkspaceSymbolProvider>
Expand Down
Loading

0 comments on commit 7ac7233

Please sign in to comment.