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    optional string server_name = 8;
538    oneof variant {
539        LspWorkStart work_start = 3;
540        LspWorkProgress work_progress = 4;
541        LspWorkEnd work_end = 5;
542        LspDiskBasedDiagnosticsUpdating disk_based_diagnostics_updating = 6;
543        LspDiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 7;
544        StatusUpdate status_update = 9;
545        RegisteredForBuffer registered_for_buffer = 10;
546    }
547}
548
549message LspWorkStart {
550    string token = 1;
551    optional string title = 4;
552    optional string message = 2;
553    optional uint32 percentage = 3;
554    optional bool is_cancellable = 5;
555}
556
557message LspWorkProgress {
558    string token = 1;
559    optional string message = 2;
560    optional uint32 percentage = 3;
561    optional bool is_cancellable = 4;
562}
563
564message LspWorkEnd {
565    string token = 1;
566}
567
568message LspDiskBasedDiagnosticsUpdating {}
569
570message LspDiskBasedDiagnosticsUpdated {}
571
572message StatusUpdate {
573    optional string message = 1;
574    oneof status {
575        ServerBinaryStatus binary = 2;
576        ServerHealth health = 3;
577    }
578}
579
580enum ServerHealth {
581    OK = 0;
582    WARNING = 1;
583    ERROR = 2;
584}
585
586enum ServerBinaryStatus {
587    NONE = 0;
588    CHECKING_FOR_UPDATE = 1;
589    DOWNLOADING = 2;
590    STARTING = 3;
591    STOPPING = 4;
592    STOPPED = 5;
593    FAILED = 6;
594}
595
596message RegisteredForBuffer {
597    string buffer_abs_path = 1;
598}
599
600message LanguageServerLog {
601    uint64 project_id = 1;
602    uint64 language_server_id = 2;
603    oneof log_type {
604        uint32 log_message_type = 3;
605        LspLogTrace log_trace = 4;
606    }
607    string message = 5;
608}
609
610message LspLogTrace {
611    optional string message = 1;
612}
613
614message ApplyCodeActionKind {
615    uint64 project_id = 1;
616    string kind = 2;
617    repeated uint64 buffer_ids = 3;
618}
619
620message ApplyCodeActionKindResponse {
621    ProjectTransaction transaction = 1;
622}
623
624message RegisterBufferWithLanguageServers {
625    uint64 project_id = 1;
626    uint64 buffer_id = 2;
627    repeated LanguageServerSelector only_servers = 3;
628}
629
630enum FormatTrigger {
631    Save = 0;
632    Manual = 1;
633}
634
635message OpenBufferForSymbol {
636    uint64 project_id = 1;
637    Symbol symbol = 2;
638}
639
640message OpenBufferForSymbolResponse {
641    uint64 buffer_id = 1;
642}
643
644message FormatBuffers {
645    uint64 project_id = 1;
646    FormatTrigger trigger = 2;
647    repeated uint64 buffer_ids = 3;
648}
649
650message FormatBuffersResponse {
651    ProjectTransaction transaction = 1;
652}
653
654message GetCompletions {
655    uint64 project_id = 1;
656    uint64 buffer_id = 2;
657    Anchor position = 3;
658    repeated VectorClockEntry version = 4;
659}
660
661message CancelLanguageServerWork {
662    uint64 project_id = 1;
663
664    oneof work {
665        Buffers buffers = 2;
666        LanguageServerWork language_server_work = 3;
667    }
668
669    message Buffers {
670        repeated uint64 buffer_ids = 2;
671    }
672
673    message LanguageServerWork {
674        uint64 language_server_id = 1;
675        optional string token = 2;
676    }
677}
678
679message LanguageServerPromptRequest {
680    uint64 project_id = 1;
681
682    oneof level {
683        Info info = 2;
684        Warning warning = 3;
685        Critical critical = 4;
686    }
687
688    message Info {}
689    message Warning {}
690    message Critical {}
691
692    string message = 5;
693    repeated string actions = 6;
694    string lsp_name = 7;
695}
696
697message LanguageServerPromptResponse {
698    optional uint64 action_response = 1;
699}
700
701message GetDocumentColor {
702    uint64 project_id = 1;
703    uint64 buffer_id = 2;
704    repeated VectorClockEntry version = 3;
705
706}
707
708message GetDocumentColorResponse {
709    repeated ColorInformation colors = 1;
710    repeated VectorClockEntry version = 2;
711
712}
713
714message ColorInformation {
715    PointUtf16 lsp_range_start = 1;
716    PointUtf16 lsp_range_end = 2;
717    float red = 3;
718    float green = 4;
719    float blue = 5;
720    float alpha = 6;
721}
722
723message GetColorPresentation {
724    uint64 project_id = 1;
725    uint64 buffer_id = 2;
726    ColorInformation color = 3;
727    uint64 server_id = 4;
728}
729
730message GetColorPresentationResponse {
731    repeated ColorPresentation presentations = 1;
732}
733
734message ColorPresentation {
735    string label = 1;
736    optional TextEdit text_edit = 2;
737    repeated TextEdit additional_text_edits = 3;
738}
739
740message TextEdit {
741    string new_text = 1;
742    PointUtf16 lsp_range_start = 2;
743    PointUtf16 lsp_range_end = 3;
744}
745
746message MultiLspQuery {
747    uint64 project_id = 1;
748    uint64 buffer_id = 2;
749    repeated VectorClockEntry version = 3;
750    oneof strategy {
751        AllLanguageServers all = 4;
752    }
753    oneof request {
754        GetHover get_hover = 5;
755        GetCodeActions get_code_actions = 6;
756        GetSignatureHelp get_signature_help = 7;
757        GetCodeLens get_code_lens = 8;
758        GetDocumentDiagnostics get_document_diagnostics = 9;
759        GetDocumentColor get_document_color = 10;
760        GetDefinition get_definition = 11;
761        GetDeclaration get_declaration = 12;
762        GetTypeDefinition get_type_definition = 13;
763        GetImplementation get_implementation = 14;
764        GetReferences get_references = 15;
765    }
766}
767
768message AllLanguageServers {}
769
770message LanguageServerSelector {
771    oneof selector {
772        uint64 server_id = 1;
773        string name = 2;
774    }
775}
776
777message RestartLanguageServers {
778    uint64 project_id = 1;
779    repeated uint64 buffer_ids = 2;
780    repeated LanguageServerSelector only_servers = 3;
781    bool all = 4;
782}
783
784message StopLanguageServers {
785    uint64 project_id = 1;
786    repeated uint64 buffer_ids = 2;
787    repeated LanguageServerSelector also_servers = 3;
788    bool all = 4;
789}
790
791message MultiLspQueryResponse {
792    repeated LspResponse responses = 1;
793}
794
795message LspResponse {
796    oneof response {
797        GetHoverResponse get_hover_response = 1;
798        GetCodeActionsResponse get_code_actions_response = 2;
799        GetSignatureHelpResponse get_signature_help_response = 3;
800        GetCodeLensResponse get_code_lens_response = 4;
801        GetDocumentDiagnosticsResponse get_document_diagnostics_response = 5;
802        GetDocumentColorResponse get_document_color_response = 6;
803        GetDefinitionResponse get_definition_response = 8;
804        GetDeclarationResponse get_declaration_response = 9;
805        GetTypeDefinitionResponse get_type_definition_response = 10;
806        GetImplementationResponse get_implementation_response = 11;
807        GetReferencesResponse get_references_response = 12;
808    }
809    uint64 server_id = 7;
810}
811
812message LanguageServerIdForName {
813    uint64 project_id = 1;
814    uint64 buffer_id = 2;
815    string name = 3;
816}
817
818message LanguageServerIdForNameResponse {
819    optional uint64 server_id = 1;
820}
821
822message LspExtRunnables {
823    uint64 project_id = 1;
824    uint64 buffer_id = 2;
825    optional Anchor position = 3;
826}
827
828message LspExtRunnablesResponse {
829    repeated LspRunnable runnables = 1;
830}
831
832message LspRunnable {
833    bytes task_template = 1;
834    optional LocationLink location = 2;
835}
836
837message LspExtCancelFlycheck {
838    uint64 project_id = 1;
839    uint64 buffer_id = 2;
840    uint64 language_server_id = 3;
841}
842
843message LspExtRunFlycheck {
844    uint64 project_id = 1;
845    uint64 buffer_id = 2;
846    uint64 language_server_id = 3;
847    bool current_file_only = 4;
848}
849
850message LspExtClearFlycheck {
851    uint64 project_id = 1;
852    uint64 buffer_id = 2;
853    uint64 language_server_id = 3;
854}
855
856message LspDiagnosticRelatedInformation {
857    optional string location_url = 1;
858    PointUtf16 location_range_start = 2;
859    PointUtf16 location_range_end = 3;
860    string message = 4;
861}
862
863enum LspDiagnosticTag {
864    None = 0;
865    Unnecessary = 1;
866    Deprecated = 2;
867}
868
869message LspDiagnostic {
870    PointUtf16 start = 1;
871    PointUtf16 end = 2;
872    Severity severity = 3;
873    optional string code = 4;
874    optional string code_description = 5;
875    optional string source = 6;
876    string message = 7;
877    repeated LspDiagnosticRelatedInformation related_information = 8;
878    repeated LspDiagnosticTag tags = 9;
879    optional string data = 10;
880
881    enum Severity {
882        None = 0;
883        Error = 1;
884        Warning = 2;
885        Information = 3;
886        Hint = 4;
887    }
888}
889
890message GetDocumentDiagnostics {
891    uint64 project_id = 1;
892    uint64 buffer_id = 2;
893    repeated VectorClockEntry version = 3;
894}
895
896message GetDocumentDiagnosticsResponse {
897    repeated PulledDiagnostics pulled_diagnostics = 1;
898}
899
900message PulledDiagnostics {
901    uint64 server_id = 1;
902    string uri = 2;
903    optional string result_id = 3;
904    bool changed = 4;
905    repeated LspDiagnostic diagnostics = 5;
906}
907
908message PullWorkspaceDiagnostics {
909    uint64 project_id = 1;
910    uint64 server_id = 2;
911}