Specification

This document describes the extended LSP methods supported by ChatLSP.

For the full LSP specifications, check the Official Page for Language Server Protocol.


textDocument/expectedType

Returns the expected type of an incomplete expression.

Request:

ExpectedTypeParamsdefined as follows:

export interface expectedTypeParams extends TextDocumentPositionParams,
  WorkDoneProgressParams, PartialResultParams {
}
Response:

ExtectedTypedefined as follows:

/**
* The result of an ExpectedType request.
*/
export interface ExpectedType {
  /**
  * The expected type content
  */
  content: MarkupContent;
  /**
  * The expected type location
  */
  location: Location;
}

textDocument/relevantTypes

Returns a list of strings, each representing a type definition that may be relevant at a given cursor location. The returned list contains components that can be used to build up the expected type.

Request:

RelevantTypesParamsdefined as follows:

export interface RelevantTypesParams extends TextDocumentPositionParams,
  WorkDoneProgressParams, PartialResultParams {
}
Response:

RelevantTypesdefined as follows:

/**
* The result of an RelevantTypes request.
*/
export interface RelevantTypes {
  /**
  * The list of relevant types contents
  */
  contents: MarkupContent[];
  /**
  * The list of relevant types locations
  */
  locations: Location[];
}

textDocument/relevantHeaders

Returns a list of strings, each representing a function header that we can call to return the expected type, or part of it, at a given cursor location.

Request:

RelevantHeadersParamsdefined as follows:

export interface RelevantHeadersParams extends TextDocumentPositionParams,
  WorkDoneProgressParams, PartialResultParams {
}
Response:

RelevantHeadersdefined as follows:

/**
* The result of an RelevantHeaders request.
*/
export interface RelevantHeaders {
  /**
  * The list of relevant headers contents
  */
  contents: MarkupContent[];
  /**
  * The list of relevant headers locations
  */
  locations: Location[];
}

textDocument/llmCompletion

Works similarly to the previously existing completion method, but uses LLM to complete the code, akin to GitHub copilot. The result is immediately visible in the editor, and users will be able to tab through different completions.

Request:

LLMCompletionParamsdefined as follows:

export interface LLMCompletionParams extends TextDocumentPositionParams,
  WorkDoneProgressParams, PartialResultParams {
}
Response:

LLMCompletiondefined as follows:

/**
* The result of a LLMCompletion request.
*/
export interface LLMCompletion {
  /**
  * Completed snippet
  */
  snippet: string;
  /**
  * The context returned by LLM
  */
  context: object;
}

textDocument/llmCompletionResolveErrors

Will attempt to resolve incorrect completions by using error rounds, iteratively fixing the generated code by replying with static errors and prompting for a corrected version.

Request:

LLMCompletionResolveErrorsParamsdefined as follows:

export interface LLMCompletionResolveErrorsParams extends TextDocumentPositionParams,
  WorkDoneProgressParams, PartialResultParams {
}
Response:

LLMCompletionResolveErrorsdefined as follows:

/**
* The result of a LLMCompletionResolveErrors request.
*/
export interface LLMCompletionResolveErrors {
  /**
  * Completed snippet
  */
  snippet: string;
  /**
  * The context returned by LLM
  */
  context: object;
}