]> git.lizzy.rs Git - rust.git/blob - editors/code/src/lsp_ext.ts
Provide navigations to parent modules
[rust.git] / editors / code / src / lsp_ext.ts
1 /**
2  * This file mirrors `crates/rust-analyzer/src/lsp_ext.rs` declarations.
3  */
4
5 import * as lc from "vscode-languageclient";
6
7 export interface AnalyzerStatusParams {
8     textDocument?: lc.TextDocumentIdentifier;
9 }
10 export const analyzerStatus = new lc.RequestType<AnalyzerStatusParams, string, void>("rust-analyzer/analyzerStatus");
11 export const memoryUsage = new lc.RequestType0<string, void>("rust-analyzer/memoryUsage");
12
13 export interface ServerStatusParams {
14     health: "ok" | "warning" | "error";
15     quiescent: boolean;
16     message?: string;
17 }
18 export const serverStatus = new lc.NotificationType<ServerStatusParams>("experimental/serverStatus");
19
20 export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
21
22 export const hover = new lc.RequestType<HoverParams, lc.Hover | null, void>("textDocument/hover");
23
24 export interface HoverParams extends lc.WorkDoneProgressParams {
25     textDocument: lc.TextDocumentIdentifier;
26     position: lc.Range | lc.Position;
27 }
28
29 export interface SyntaxTreeParams {
30     textDocument: lc.TextDocumentIdentifier;
31     range: lc.Range | null;
32 }
33 export const syntaxTree = new lc.RequestType<SyntaxTreeParams, string, void>("rust-analyzer/syntaxTree");
34
35 export const viewHir = new lc.RequestType<lc.TextDocumentPositionParams, string, void>("rust-analyzer/viewHir");
36
37 export interface ViewItemTreeParams {
38     textDocument: lc.TextDocumentIdentifier;
39 }
40
41 export const viewItemTree = new lc.RequestType<ViewItemTreeParams, string, void>("rust-analyzer/viewItemTree");
42
43 export interface ViewCrateGraphParams {
44     full: boolean;
45 }
46
47 export const viewCrateGraph = new lc.RequestType<ViewCrateGraphParams, string, void>("rust-analyzer/viewCrateGraph");
48
49 export interface ExpandMacroParams {
50     textDocument: lc.TextDocumentIdentifier;
51     position: lc.Position;
52 }
53 export interface ExpandedMacro {
54     name: string;
55     expansion: string;
56 }
57 export const expandMacro = new lc.RequestType<ExpandMacroParams, ExpandedMacro | null, void>("rust-analyzer/expandMacro");
58
59 export interface MatchingBraceParams {
60     textDocument: lc.TextDocumentIdentifier;
61     positions: lc.Position[];
62 }
63 export const matchingBrace = new lc.RequestType<MatchingBraceParams, lc.Position[], void>("experimental/matchingBrace");
64
65 export const parentModule = new lc.RequestType<lc.TextDocumentPositionParams, lc.LocationLink[] | null, void>("experimental/parentModule");
66
67 export interface JoinLinesParams {
68     textDocument: lc.TextDocumentIdentifier;
69     ranges: lc.Range[];
70 }
71 export const joinLines = new lc.RequestType<JoinLinesParams, lc.TextEdit[], void>("experimental/joinLines");
72
73 export const onEnter = new lc.RequestType<lc.TextDocumentPositionParams, lc.TextEdit[], void>("experimental/onEnter");
74
75 export interface RunnablesParams {
76     textDocument: lc.TextDocumentIdentifier;
77     position: lc.Position | null;
78 }
79
80 export interface Runnable {
81     label: string;
82     location?: lc.LocationLink;
83     kind: "cargo";
84     args: {
85         workspaceRoot?: string;
86         cargoArgs: string[];
87         cargoExtraArgs: string[];
88         executableArgs: string[];
89         expectTest?: boolean;
90         overrideCargo?: string;
91     };
92 }
93 export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("experimental/runnables");
94
95 export interface TestInfo {
96     runnable: Runnable;
97 }
98
99 export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>("rust-analyzer/relatedTests");
100
101 export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint;
102
103 export namespace InlayHint {
104     export const enum Kind {
105         TypeHint = "TypeHint",
106         ParamHint = "ParameterHint",
107         ChainingHint = "ChainingHint",
108     }
109     interface Common {
110         range: lc.Range;
111         label: string;
112     }
113     export type TypeHint = Common & { kind: Kind.TypeHint };
114     export type ParamHint = Common & { kind: Kind.ParamHint };
115     export type ChainingHint = Common & { kind: Kind.ChainingHint };
116 }
117 export interface InlayHintsParams {
118     textDocument: lc.TextDocumentIdentifier;
119 }
120 export const inlayHints = new lc.RequestType<InlayHintsParams, InlayHint[], void>("rust-analyzer/inlayHints");
121
122 export interface SsrParams {
123     query: string;
124     parseOnly: boolean;
125     textDocument: lc.TextDocumentIdentifier;
126     position: lc.Position;
127     selections: lc.Range[];
128 }
129 export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');
130
131 export interface CommandLink extends lc.Command {
132     /**
133      * A tooltip for the command, when represented in the UI.
134      */
135     tooltip?: string;
136 }
137
138 export interface CommandLinkGroup {
139     title?: string;
140     commands: CommandLink[];
141 }
142
143 export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>('experimental/externalDocs');
144
145 export const openCargoToml = new lc.RequestType<OpenCargoTomlParams, lc.Location, void>("experimental/openCargoToml");
146
147 export interface OpenCargoTomlParams {
148     textDocument: lc.TextDocumentIdentifier;
149 }
150
151 export const moveItem = new lc.RequestType<MoveItemParams, lc.TextEdit[], void>("experimental/moveItem");
152
153 export interface MoveItemParams {
154     textDocument: lc.TextDocumentIdentifier;
155     range: lc.Range;
156     direction: Direction;
157 }
158
159 export const enum Direction {
160     Up = "Up",
161     Down = "Down"
162 }