lsp.proto

  1syntax = "proto3";
  2package zed.messages;
  3
  4import "core.proto";
  5import "worktree.proto";
  6import "buffer.proto";
  7
  8message GetDefinition {
  9     uint64 project_id = 1;
 10     uint64 buffer_id = 2;
 11     Anchor position = 3;
 12     repeated VectorClockEntry version = 4;
 13}
 14
 15message GetDefinitionResponse {
 16    repeated LocationLink links = 1;
 17}
 18
 19message GetDeclaration {
 20     uint64 project_id = 1;
 21     uint64 buffer_id = 2;
 22     Anchor position = 3;
 23     repeated VectorClockEntry version = 4;
 24}
 25
 26message GetDeclarationResponse {
 27    repeated LocationLink links = 1;
 28}
 29
 30message GetTypeDefinition {
 31     uint64 project_id = 1;
 32     uint64 buffer_id = 2;
 33     Anchor position = 3;
 34     repeated VectorClockEntry version = 4;
 35 }
 36
 37message GetTypeDefinitionResponse {
 38    repeated LocationLink links = 1;
 39}
 40message GetImplementation {
 41     uint64 project_id = 1;
 42     uint64 buffer_id = 2;
 43     Anchor position = 3;
 44     repeated VectorClockEntry version = 4;
 45 }
 46
 47message GetImplementationResponse {
 48    repeated LocationLink links = 1;
 49}
 50
 51message GetReferences {
 52     uint64 project_id = 1;
 53     uint64 buffer_id = 2;
 54     Anchor position = 3;
 55     repeated VectorClockEntry version = 4;
 56 }
 57
 58message GetReferencesResponse {
 59    repeated Location locations = 1;
 60}
 61
 62message GetDocumentHighlights {
 63     uint64 project_id = 1;
 64     uint64 buffer_id = 2;
 65     Anchor position = 3;
 66     repeated VectorClockEntry version = 4;
 67 }
 68
 69message GetDocumentHighlightsResponse {
 70    repeated DocumentHighlight highlights = 1;
 71}
 72
 73message LocationLink {
 74    optional Location origin = 1;
 75    Location target = 2;
 76}
 77
 78message DocumentHighlight {
 79    Kind kind = 1;
 80    Anchor start = 2;
 81    Anchor end = 3;
 82
 83    enum Kind {
 84        Text = 0;
 85        Read = 1;
 86        Write = 2;
 87    }
 88}
 89
 90message GetProjectSymbols {
 91    uint64 project_id = 1;
 92    string query = 2;
 93}
 94
 95message GetProjectSymbolsResponse {
 96    repeated Symbol symbols = 4;
 97}
 98
 99message Symbol {
100    uint64 source_worktree_id = 1;
101    uint64 worktree_id = 2;
102    string language_server_name = 3;
103    string name = 4;
104    int32 kind = 5;
105    string path = 6;
106    // Cannot use generate anchors for unopened files,
107    // so we are forced to use point coords instead
108    PointUtf16 start = 7;
109    PointUtf16 end = 8;
110    bytes signature = 9;
111    uint64 language_server_id = 10;
112}
113
114message GetDocumentSymbols {
115    uint64 project_id = 1;
116    uint64 buffer_id = 2;
117    repeated VectorClockEntry version = 3;
118}
119
120message GetDocumentSymbolsResponse {
121    repeated DocumentSymbol symbols = 1;
122}
123
124message DocumentSymbol {
125    string name = 1;
126    int32 kind = 2;
127    // Cannot use generate anchors for unopened files,
128    // so we are forced to use point coords instead
129    PointUtf16 start = 3;
130    PointUtf16 end = 4;
131    PointUtf16 selection_start = 5;
132    PointUtf16 selection_end = 6;
133    repeated DocumentSymbol children = 7;
134}
135
136message InlayHints {
137    uint64 project_id = 1;
138    uint64 buffer_id = 2;
139    Anchor start = 3;
140    Anchor end = 4;
141    repeated VectorClockEntry version = 5;
142}
143
144message InlayHintsResponse {
145    repeated InlayHint hints = 1;
146    repeated VectorClockEntry version = 2;
147}
148
149message PointUtf16 {
150    uint32 row = 1;
151    uint32 column = 2;
152}
153
154message LspExtExpandMacro {
155    uint64 project_id = 1;
156    uint64 buffer_id = 2;
157    Anchor position = 3;
158}
159
160message LspExtExpandMacroResponse {
161    string name = 1;
162    string expansion = 2;
163}
164
165message LspExtOpenDocs {
166    uint64 project_id = 1;
167    uint64 buffer_id = 2;
168    Anchor position = 3;
169}
170
171message LspExtOpenDocsResponse {
172    optional string web = 1;
173    optional string local = 2;
174}
175
176message LspExtSwitchSourceHeader {
177    uint64 project_id = 1;
178    uint64 buffer_id = 2;
179}
180
181message LspExtSwitchSourceHeaderResponse {
182    string target_file = 1;
183}
184
185message LspExtGoToParentModule {
186    uint64 project_id = 1;
187    uint64 buffer_id = 2;
188    Anchor position = 3;
189}
190
191message LspExtGoToParentModuleResponse {
192    repeated LocationLink links = 1;
193}
194
195message GetCompletionsResponse {
196    repeated Completion completions = 1;
197    repeated VectorClockEntry version = 2;
198    // `!is_complete`, inverted for a default of `is_complete = true`
199    bool can_reuse = 3;
200}
201
202message ApplyCompletionAdditionalEdits {
203    uint64 project_id = 1;
204    uint64 buffer_id = 2;
205    Completion completion = 3;
206}
207
208message ApplyCompletionAdditionalEditsResponse {
209    Transaction transaction = 1;
210}
211
212message Completion {
213    Anchor old_replace_start = 1;
214    Anchor old_replace_end = 2;
215    string new_text = 3;
216    uint64 server_id = 4;
217    bytes lsp_completion = 5;
218    bool resolved = 6;
219    Source source = 7;
220    optional bytes lsp_defaults = 8;
221    optional Anchor buffer_word_start = 9;
222    optional Anchor buffer_word_end = 10;
223    Anchor old_insert_start = 11;
224    Anchor old_insert_end = 12;
225
226    enum Source {
227        Lsp = 0;
228        Custom = 1;
229        BufferWord = 2;
230    }
231}
232
233message GetCodeActions {
234    uint64 project_id = 1;
235    uint64 buffer_id = 2;
236    Anchor start = 3;
237    Anchor end = 4;
238    repeated VectorClockEntry version = 5;
239}
240
241message GetCodeActionsResponse {
242    repeated CodeAction actions = 1;
243    repeated VectorClockEntry version = 2;
244}
245
246message GetSignatureHelp {
247    uint64 project_id = 1;
248    uint64 buffer_id = 2;
249    Anchor position = 3;
250    repeated VectorClockEntry version = 4;
251}
252
253message GetSignatureHelpResponse {
254    optional SignatureHelp signature_help = 1;
255}
256
257message SignatureHelp {
258    repeated SignatureInformation signatures = 1;
259    optional uint32 active_signature = 2;
260    optional uint32 active_parameter = 3;
261}
262
263message SignatureInformation {
264    string label = 1;
265    optional Documentation documentation = 2;
266    repeated ParameterInformation parameters = 3;
267    optional uint32 active_parameter = 4;
268}
269
270message Documentation {
271    oneof content {
272        string value = 1;
273        MarkupContent markup_content = 2;
274    }
275}
276
277enum MarkupKind {
278    PlainText = 0;
279    Markdown = 1;
280}
281
282message ParameterInformation {
283    oneof label {
284        string simple = 1;
285        LabelOffsets label_offsets = 2;
286    }
287    optional Documentation documentation = 3;
288}
289
290message LabelOffsets {
291    uint32 start = 1;
292    uint32 end = 2;
293}
294
295message GetHover {
296    uint64 project_id = 1;
297    uint64 buffer_id = 2;
298    Anchor position = 3;
299    repeated VectorClockEntry version = 5;
300}
301
302message GetHoverResponse {
303    optional Anchor start = 1;
304    optional Anchor end = 2;
305    repeated HoverBlock contents = 3;
306}
307
308message HoverBlock {
309    string text = 1;
310    optional string language = 2;
311    bool is_markdown = 3;
312}
313
314message ApplyCodeAction {
315    uint64 project_id = 1;
316    uint64 buffer_id = 2;
317    CodeAction action = 3;
318}
319
320message ApplyCodeActionResponse {
321    ProjectTransaction transaction = 1;
322}
323
324message PrepareRename {
325    uint64 project_id = 1;
326    uint64 buffer_id = 2;
327    Anchor position = 3;
328    repeated VectorClockEntry version = 4;
329}
330
331message PrepareRenameResponse {
332    bool can_rename = 1;
333    Anchor start = 2;
334    Anchor end = 3;
335    repeated VectorClockEntry version = 4;
336    bool only_unprepared_rename_supported = 5;
337}
338
339message PerformRename {
340    uint64 project_id = 1;
341    uint64 buffer_id = 2;
342    Anchor position = 3;
343    string new_name = 4;
344    repeated VectorClockEntry version = 5;
345}
346
347message OnTypeFormatting {
348    uint64 project_id = 1;
349    uint64 buffer_id = 2;
350    Anchor position = 3;
351    string trigger = 4;
352    repeated VectorClockEntry version = 5;
353}
354
355message OnTypeFormattingResponse {
356    Transaction transaction = 1;
357}
358
359
360message LinkedEditingRange {
361    uint64 project_id = 1;
362    uint64 buffer_id = 2;
363    Anchor position = 3;
364    repeated VectorClockEntry version = 4;
365}
366
367message LinkedEditingRangeResponse {
368    repeated AnchorRange items = 1;
369    repeated VectorClockEntry version = 4;
370}
371
372message InlayHint {
373    Anchor position = 1;
374    InlayHintLabel label = 2;
375    optional string kind = 3;
376    bool padding_left = 4;
377    bool padding_right = 5;
378    InlayHintTooltip tooltip = 6;
379    ResolveState resolve_state = 7;
380}
381
382message InlayHintLabel {
383    oneof label {
384        string value = 1;
385        InlayHintLabelParts label_parts = 2;
386    }
387}
388
389message InlayHintLabelParts {
390    repeated InlayHintLabelPart parts = 1;
391}
392
393message InlayHintLabelPart {
394    string value = 1;
395    InlayHintLabelPartTooltip tooltip = 2;
396    optional string location_url = 3;
397    PointUtf16 location_range_start = 4;
398    PointUtf16 location_range_end = 5;
399    optional uint64 language_server_id = 6;
400}
401
402message InlayHintTooltip {
403    oneof content {
404        string value = 1;
405        MarkupContent markup_content = 2;
406    }
407}
408
409message InlayHintLabelPartTooltip {
410    oneof content {
411        string value = 1;
412        MarkupContent markup_content = 2;
413    }
414}
415
416message ResolveState {
417    State state = 1;
418    LspResolveState lsp_resolve_state = 2;
419
420    enum State {
421        Resolved = 0;
422        CanResolve = 1;
423        Resolving = 2;
424    }
425
426    message LspResolveState {
427        optional string value = 1;
428        uint64 server_id = 2;
429    }
430}
431
432// This type is used to resolve more than just
433// the documentation, but for backwards-compatibility
434// reasons we can't rename the type.
435message ResolveCompletionDocumentation {
436    uint64 project_id = 1;
437    uint64 language_server_id = 2;
438    bytes lsp_completion = 3;
439    uint64 buffer_id = 4;
440}
441
442message ResolveCompletionDocumentationResponse {
443    string documentation = 1;
444    bool documentation_is_markdown = 2;
445    Anchor old_replace_start = 3;
446    Anchor old_replace_end = 4;
447    string new_text = 5;
448    bytes lsp_completion = 6;
449    Anchor old_insert_start = 7;
450    Anchor old_insert_end = 8;
451}
452
453message ResolveInlayHint {
454    uint64 project_id = 1;
455    uint64 buffer_id = 2;
456    uint64 language_server_id = 3;
457    InlayHint hint = 4;
458}
459
460message ResolveInlayHintResponse {
461    InlayHint hint = 1;
462}
463
464message RefreshInlayHints {
465    uint64 project_id = 1;
466}
467
468message CodeLens {
469    bytes lsp_lens = 1;
470}
471
472message GetCodeLens {
473    uint64 project_id = 1;
474    uint64 buffer_id = 2;
475    repeated VectorClockEntry version = 3;
476}
477
478message GetCodeLensResponse {
479    repeated CodeAction lens_actions = 1;
480    repeated VectorClockEntry version = 2;
481}
482
483message RefreshCodeLens {
484    uint64 project_id = 1;
485}
486
487message MarkupContent {
488    bool is_markdown = 1;
489    string value = 2;
490}
491
492message PerformRenameResponse {
493    ProjectTransaction transaction = 2;
494}
495
496message CodeAction {
497    uint64 server_id = 1;
498    Anchor start = 2;
499    Anchor end = 3;
500    bytes lsp_action = 4;
501    Kind kind = 5;
502    bool resolved = 6;
503    enum Kind {
504        Action = 0;
505        Command = 1;
506        CodeLens = 2;
507    }
508}
509
510message LanguageServer {
511    uint64 id = 1;
512    string name = 2;
513    optional uint64 worktree_id = 3;
514}
515
516message StartLanguageServer {
517    uint64 project_id = 1;
518    LanguageServer server = 2;
519}
520
521message UpdateDiagnosticSummary {
522    uint64 project_id = 1;
523    uint64 worktree_id = 2;
524    DiagnosticSummary summary = 3;
525}
526
527message DiagnosticSummary {
528    string path = 1;
529    uint64 language_server_id = 2;
530    uint32 error_count = 3;
531    uint32 warning_count = 4;
532}
533
534message UpdateLanguageServer {
535    uint64 project_id = 1;
536    uint64 language_server_id = 2;
537    oneof variant {
538        LspWorkStart work_start = 3;
539        LspWorkProgress work_progress = 4;
540        LspWorkEnd work_end = 5;
541        LspDiskBasedDiagnosticsUpdating disk_based_diagnostics_updating = 6;
542        LspDiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 7;
543    }
544}
545
546message LspWorkStart {
547    string token = 1;
548    optional string title = 4;
549    optional string message = 2;
550    optional uint32 percentage = 3;
551    optional bool is_cancellable = 5;
552}
553
554message LspWorkProgress {
555    string token = 1;
556    optional string message = 2;
557    optional uint32 percentage = 3;
558    optional bool is_cancellable = 4;
559}
560
561message LspWorkEnd {
562    string token = 1;
563}
564
565message LspDiskBasedDiagnosticsUpdating {}
566
567message LspDiskBasedDiagnosticsUpdated {}
568
569message LanguageServerLog {
570    uint64 project_id = 1;
571    uint64 language_server_id = 2;
572    oneof log_type {
573        uint32 log_message_type = 3;
574        LspLogTrace log_trace = 4;
575    }
576    string message = 5;
577}
578
579message LspLogTrace {
580    optional string message = 1;
581}
582
583message ApplyCodeActionKind {
584    uint64 project_id = 1;
585    string kind = 2;
586    repeated uint64 buffer_ids = 3;
587}
588
589message ApplyCodeActionKindResponse {
590    ProjectTransaction transaction = 1;
591}
592
593message RegisterBufferWithLanguageServers {
594    uint64 project_id = 1;
595    uint64 buffer_id = 2;
596}
597
598enum FormatTrigger {
599    Save = 0;
600    Manual = 1;
601}
602
603message OpenBufferForSymbol {
604    uint64 project_id = 1;
605    Symbol symbol = 2;
606}
607
608message OpenBufferForSymbolResponse {
609    uint64 buffer_id = 1;
610}
611
612message FormatBuffers {
613    uint64 project_id = 1;
614    FormatTrigger trigger = 2;
615    repeated uint64 buffer_ids = 3;
616}
617
618message FormatBuffersResponse {
619    ProjectTransaction transaction = 1;
620}
621
622message GetCompletions {
623    uint64 project_id = 1;
624    uint64 buffer_id = 2;
625    Anchor position = 3;
626    repeated VectorClockEntry version = 4;
627}
628
629message CancelLanguageServerWork {
630    uint64 project_id = 1;
631
632    oneof work {
633        Buffers buffers = 2;
634        LanguageServerWork language_server_work = 3;
635    }
636
637    message Buffers {
638        repeated uint64 buffer_ids = 2;
639    }
640
641    message LanguageServerWork {
642        uint64 language_server_id = 1;
643        optional string token = 2;
644    }
645}
646
647message LanguageServerPromptRequest {
648    uint64 project_id = 1;
649
650    oneof level {
651        Info info = 2;
652        Warning warning = 3;
653        Critical critical = 4;
654    }
655
656    message Info {}
657    message Warning {}
658    message Critical {}
659
660    string message = 5;
661    repeated string actions = 6;
662    string lsp_name = 7;
663}
664
665message LanguageServerPromptResponse {
666    optional uint64 action_response = 1;
667}
668
669message GetDocumentColor {
670    uint64 project_id = 1;
671    uint64 buffer_id = 2;
672    repeated VectorClockEntry version = 3;
673
674}
675
676message GetDocumentColorResponse {
677    repeated ColorInformation colors = 1;
678    repeated VectorClockEntry version = 2;
679
680}
681
682message ColorInformation {
683    PointUtf16 lsp_range_start = 1;
684    PointUtf16 lsp_range_end = 2;
685    float red = 3;
686    float green = 4;
687    float blue = 5;
688    float alpha = 6;
689}
690
691message GetColorPresentation {
692    uint64 project_id = 1;
693    uint64 buffer_id = 2;
694    ColorInformation color = 3;
695    uint64 server_id = 4;
696}
697
698message GetColorPresentationResponse {
699    repeated ColorPresentation presentations = 1;
700}
701
702message ColorPresentation {
703    string label = 1;
704    optional TextEdit text_edit = 2;
705    repeated TextEdit additional_text_edits = 3;
706}
707
708message TextEdit {
709    string new_text = 1;
710    PointUtf16 lsp_range_start = 2;
711    PointUtf16 lsp_range_end = 3;
712}
713
714message MultiLspQuery {
715    uint64 project_id = 1;
716    uint64 buffer_id = 2;
717    repeated VectorClockEntry version = 3;
718    oneof strategy {
719        AllLanguageServers all = 4;
720    }
721    oneof request {
722        GetHover get_hover = 5;
723        GetCodeActions get_code_actions = 6;
724        GetSignatureHelp get_signature_help = 7;
725        GetCodeLens get_code_lens = 8;
726        GetDocumentDiagnostics get_document_diagnostics = 9;
727        GetDocumentColor get_document_color = 10;
728    }
729}
730
731message AllLanguageServers {}
732
733message RestartLanguageServers {
734    uint64 project_id = 1;
735    repeated uint64 buffer_ids = 2;
736}
737
738message StopLanguageServers {
739    uint64 project_id = 1;
740    repeated uint64 buffer_ids = 2;
741}
742
743message MultiLspQueryResponse {
744    repeated LspResponse responses = 1;
745}
746
747message LspResponse {
748    oneof response {
749        GetHoverResponse get_hover_response = 1;
750        GetCodeActionsResponse get_code_actions_response = 2;
751        GetSignatureHelpResponse get_signature_help_response = 3;
752        GetCodeLensResponse get_code_lens_response = 4;
753        GetDocumentDiagnosticsResponse get_document_diagnostics_response = 5;
754        GetDocumentColorResponse get_document_color_response = 6;
755    }
756    uint64 server_id = 7;
757}
758
759message LanguageServerIdForName {
760    uint64 project_id = 1;
761    uint64 buffer_id = 2;
762    string name = 3;
763}
764
765message LanguageServerIdForNameResponse {
766    optional uint64 server_id = 1;
767}
768
769message LspExtRunnables {
770    uint64 project_id = 1;
771    uint64 buffer_id = 2;
772    optional Anchor position = 3;
773}
774
775message LspExtRunnablesResponse {
776    repeated LspRunnable runnables = 1;
777}
778
779message LspRunnable {
780    bytes task_template = 1;
781    optional LocationLink location = 2;
782}
783
784message LspExtCancelFlycheck {
785    uint64 project_id = 1;
786    uint64 buffer_id = 2;
787    uint64 language_server_id = 3;
788}
789
790message LspExtRunFlycheck {
791    uint64 project_id = 1;
792    uint64 buffer_id = 2;
793    uint64 language_server_id = 3;
794    bool current_file_only = 4;
795}
796
797message LspExtClearFlycheck {
798    uint64 project_id = 1;
799    uint64 buffer_id = 2;
800    uint64 language_server_id = 3;
801}
802
803message LspDiagnosticRelatedInformation {
804    optional string location_url = 1;
805    PointUtf16 location_range_start = 2;
806    PointUtf16 location_range_end = 3;
807    string message = 4;
808}
809
810enum LspDiagnosticTag {
811    None = 0;
812    Unnecessary = 1;
813    Deprecated = 2;
814}
815
816message LspDiagnostic {
817    PointUtf16 start = 1;
818    PointUtf16 end = 2;
819    Severity severity = 3;
820    optional string code = 4;
821    optional string code_description = 5;
822    optional string source = 6;
823    string message = 7;
824    repeated LspDiagnosticRelatedInformation related_information = 8;
825    repeated LspDiagnosticTag tags = 9;
826    optional string data = 10;
827
828    enum Severity {
829        None = 0;
830        Error = 1;
831        Warning = 2;
832        Information = 3;
833        Hint = 4;
834    }
835}
836
837message GetDocumentDiagnostics {
838    uint64 project_id = 1;
839    uint64 buffer_id = 2;
840    repeated VectorClockEntry version = 3;
841}
842
843message GetDocumentDiagnosticsResponse {
844    repeated PulledDiagnostics pulled_diagnostics = 1;
845}
846
847message PulledDiagnostics {
848    uint64 server_id = 1;
849    string uri = 2;
850    optional string result_id = 3;
851    bool changed = 4;
852    repeated LspDiagnostic diagnostics = 5;
853}
854
855message PullWorkspaceDiagnostics {
856    uint64 project_id = 1;
857    uint64 server_id = 2;
858}