rust-analyzer/editors/code/src/lsp_ext.ts

163 lines
5.2 KiB
TypeScript
Raw Normal View History

/**
2020-08-28 18:55:24 +00:00
* This file mirrors `crates/rust-analyzer/src/lsp_ext.rs` declarations.
*/
import * as lc from "vscode-languageclient";
export interface AnalyzerStatusParams {
textDocument?: lc.TextDocumentIdentifier;
}
export const analyzerStatus = new lc.RequestType<AnalyzerStatusParams, string, void>("rust-analyzer/analyzerStatus");
2020-09-17 10:31:42 +00:00
export const memoryUsage = new lc.RequestType0<string, void>("rust-analyzer/memoryUsage");
2021-04-06 11:16:35 +00:00
export interface ServerStatusParams {
2021-04-06 12:50:02 +00:00
health: "ok" | "warning" | "error";
quiescent: boolean;
message?: string;
2020-08-17 11:56:27 +00:00
}
2021-04-06 11:16:35 +00:00
export const serverStatus = new lc.NotificationType<ServerStatusParams>("experimental/serverStatus");
2020-07-02 10:37:04 +00:00
2020-09-17 10:31:42 +00:00
export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
export const hoverRange = new lc.RequestType<HoverRangeParams, lc.Hover | null, void>("rust-analyzer/hoverRange");
export interface HoverRangeParams {
textDocument: lc.TextDocumentIdentifier;
range: lc.Range;
}
export interface SyntaxTreeParams {
textDocument: lc.TextDocumentIdentifier;
range: lc.Range | null;
}
export const syntaxTree = new lc.RequestType<SyntaxTreeParams, string, void>("rust-analyzer/syntaxTree");
export const viewHir = new lc.RequestType<lc.TextDocumentPositionParams, string, void>("rust-analyzer/viewHir");
2021-05-21 21:59:52 +00:00
export interface ViewItemTreeParams {
textDocument: lc.TextDocumentIdentifier;
}
export const viewItemTree = new lc.RequestType<ViewItemTreeParams, string, void>("rust-analyzer/viewItemTree");
2021-07-01 22:08:05 +00:00
export interface ViewCrateGraphParams {
full: boolean;
}
export const viewCrateGraph = new lc.RequestType<ViewCrateGraphParams, string, void>("rust-analyzer/viewCrateGraph");
export interface ExpandMacroParams {
textDocument: lc.TextDocumentIdentifier;
position: lc.Position;
}
export interface ExpandedMacro {
name: string;
expansion: string;
}
export const expandMacro = new lc.RequestType<ExpandMacroParams, ExpandedMacro | null, void>("rust-analyzer/expandMacro");
export interface MatchingBraceParams {
textDocument: lc.TextDocumentIdentifier;
positions: lc.Position[];
}
export const matchingBrace = new lc.RequestType<MatchingBraceParams, lc.Position[], void>("experimental/matchingBrace");
export const parentModule = new lc.RequestType<lc.TextDocumentPositionParams, lc.LocationLink[], void>("experimental/parentModule");
export interface JoinLinesParams {
textDocument: lc.TextDocumentIdentifier;
ranges: lc.Range[];
}
export const joinLines = new lc.RequestType<JoinLinesParams, lc.TextEdit[], void>("experimental/joinLines");
export const onEnter = new lc.RequestType<lc.TextDocumentPositionParams, lc.TextEdit[], void>("experimental/onEnter");
export interface RunnablesParams {
textDocument: lc.TextDocumentIdentifier;
position: lc.Position | null;
}
export interface Runnable {
label: string;
2020-06-02 15:22:23 +00:00
location?: lc.LocationLink;
kind: "cargo";
args: {
workspaceRoot?: string;
cargoArgs: string[];
cargoExtraArgs: string[];
2020-06-02 15:22:23 +00:00
executableArgs: string[];
expectTest?: boolean;
overrideCargo?: string;
2020-06-02 15:22:23 +00:00
};
}
2020-06-02 15:34:18 +00:00
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("experimental/runnables");
2021-02-27 17:04:43 +00:00
export interface TestInfo {
runnable: Runnable;
}
2021-03-11 14:39:41 +00:00
export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>("rust-analyzer/relatedTests");
2021-02-27 17:04:43 +00:00
export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint;
export namespace InlayHint {
export const enum Kind {
TypeHint = "TypeHint",
ParamHint = "ParameterHint",
ChainingHint = "ChainingHint",
}
interface Common {
range: lc.Range;
label: string;
}
export type TypeHint = Common & { kind: Kind.TypeHint };
export type ParamHint = Common & { kind: Kind.ParamHint };
export type ChainingHint = Common & { kind: Kind.ChainingHint };
}
export interface InlayHintsParams {
textDocument: lc.TextDocumentIdentifier;
}
export const inlayHints = new lc.RequestType<InlayHintsParams, InlayHint[], void>("rust-analyzer/inlayHints");
export interface SsrParams {
query: string;
parseOnly: boolean;
textDocument: lc.TextDocumentIdentifier;
position: lc.Position;
selections: lc.Range[];
}
export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');
2020-06-03 11:15:54 +00:00
export interface CommandLink extends lc.Command {
/**
* A tooltip for the command, when represented in the UI.
*/
tooltip?: string;
}
export interface CommandLinkGroup {
title?: string;
commands: CommandLink[];
}
2020-08-30 08:02:29 +00:00
2020-09-01 08:26:10 +00:00
export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>('experimental/externalDocs');
2020-11-13 01:48:07 +00:00
export const openCargoToml = new lc.RequestType<OpenCargoTomlParams, lc.Location, void>("experimental/openCargoToml");
export interface OpenCargoTomlParams {
textDocument: lc.TextDocumentIdentifier;
}
2021-03-16 12:37:00 +00:00
export const moveItem = new lc.RequestType<MoveItemParams, lc.TextEdit[], void>("experimental/moveItem");
2021-03-16 12:37:00 +00:00
export interface MoveItemParams {
2021-03-16 15:11:50 +00:00
textDocument: lc.TextDocumentIdentifier;
range: lc.Range;
direction: Direction;
2021-03-16 12:37:00 +00:00
}
export const enum Direction {
Up = "Up",
Down = "Down"
}