lsp- alias []const u8 -> string so its closer to docs

This commit is contained in:
Meghan Denny 2021-10-02 15:15:08 -07:00
parent 9ceaf90657
commit caaec2bcfd

View File

@ -1,4 +1,5 @@
const std = @import("std"); const std = @import("std");
const string = []const u8;
// LSP types // LSP types
// https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/ // https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/
@ -14,13 +15,13 @@ pub const Range = struct {
}; };
pub const Location = struct { pub const Location = struct {
uri: []const u8, uri: string,
range: Range, range: Range,
}; };
/// Id of a request /// Id of a request
pub const RequestId = union(enum) { pub const RequestId = union(enum) {
String: []const u8, String: string,
Integer: i64, Integer: i64,
Float: f64, Float: f64,
}; };
@ -49,26 +50,26 @@ pub const Notification = struct {
pub const Params = union(enum) { pub const Params = union(enum) {
LogMessage: struct { LogMessage: struct {
type: MessageType, type: MessageType,
message: []const u8, message: string,
}, },
PublishDiagnostics: struct { PublishDiagnostics: struct {
uri: []const u8, uri: string,
diagnostics: []Diagnostic, diagnostics: []Diagnostic,
}, },
ShowMessage: struct { ShowMessage: struct {
type: MessageType, type: MessageType,
message: []const u8, message: string,
}, },
}; };
jsonrpc: []const u8 = "2.0", jsonrpc: string = "2.0",
method: []const u8, method: string,
params: Params, params: Params,
}; };
/// JSONRPC response /// JSONRPC response
pub const Response = struct { pub const Response = struct {
jsonrpc: []const u8 = "2.0", jsonrpc: string = "2.0",
id: RequestId, id: RequestId,
result: ResponseParams, result: ResponseParams,
}; };
@ -99,13 +100,13 @@ pub const DiagnosticSeverity = enum(i64) {
pub const Diagnostic = struct { pub const Diagnostic = struct {
range: Range, range: Range,
severity: DiagnosticSeverity, severity: DiagnosticSeverity,
code: []const u8, code: string,
source: []const u8, source: string,
message: []const u8, message: string,
}; };
pub const TextDocument = struct { pub const TextDocument = struct {
uri: []const u8, uri: string,
// This is a substring of mem starting at 0 // This is a substring of mem starting at 0
text: [:0]const u8, text: [:0]const u8,
// This holds the memory that we have actually allocated. // This holds the memory that we have actually allocated.
@ -164,7 +165,7 @@ pub const WorkspaceEdit = struct {
pub const TextEdit = struct { pub const TextEdit = struct {
range: Range, range: Range,
newText: []const u8, newText: string,
}; };
pub const MarkupContent = struct { pub const MarkupContent = struct {
@ -182,7 +183,7 @@ pub const MarkupContent = struct {
}; };
kind: Kind = .Markdown, kind: Kind = .Markdown,
value: []const u8, value: string,
}; };
pub const CompletionList = struct { pub const CompletionList = struct {
@ -232,13 +233,13 @@ pub const CompletionItem = struct {
} }
}; };
label: []const u8, label: string,
kind: Kind, kind: Kind,
textEdit: ?TextEdit = null, textEdit: ?TextEdit = null,
filterText: ?[]const u8 = null, filterText: ?string = null,
insertText: []const u8 = "", insertText: string = "",
insertTextFormat: ?InsertTextFormat = .PlainText, insertTextFormat: ?InsertTextFormat = .PlainText,
detail: ?[]const u8 = null, detail: ?string = null,
documentation: ?MarkupContent = null, documentation: ?MarkupContent = null,
}; };
@ -276,8 +277,8 @@ pub const DocumentSymbol = struct {
} }
}; };
name: []const u8, name: string,
detail: ?[]const u8 = null, detail: ?string = null,
kind: Kind, kind: Kind,
deprecated: bool = false, deprecated: bool = false,
range: Range, range: Range,
@ -286,18 +287,18 @@ pub const DocumentSymbol = struct {
}; };
pub const WorkspaceFolder = struct { pub const WorkspaceFolder = struct {
uri: []const u8, uri: string,
name: []const u8, name: string,
}; };
pub const SignatureInformation = struct { pub const SignatureInformation = struct {
pub const ParameterInformation = struct { pub const ParameterInformation = struct {
// TODO Can also send a pair of encoded offsets // TODO Can also send a pair of encoded offsets
label: []const u8, label: string,
documentation: ?MarkupContent, documentation: ?MarkupContent,
}; };
label: []const u8, label: string,
documentation: ?MarkupContent, documentation: ?MarkupContent,
parameters: ?[]const ParameterInformation, parameters: ?[]const ParameterInformation,
activeParameter: ?u32, activeParameter: ?u32,
@ -311,11 +312,11 @@ pub const SignatureHelp = struct {
// Only includes options we set in our initialize result. // Only includes options we set in our initialize result.
const InitializeResult = struct { const InitializeResult = struct {
offsetEncoding: []const u8, offsetEncoding: string,
capabilities: struct { capabilities: struct {
signatureHelpProvider: struct { signatureHelpProvider: struct {
triggerCharacters: []const []const u8, triggerCharacters: []const string,
retriggerCharacters: []const []const u8, retriggerCharacters: []const string,
}, },
textDocumentSync: enum(u32) { textDocumentSync: enum(u32) {
None = 0, None = 0,
@ -329,7 +330,7 @@ const InitializeResult = struct {
renameProvider: bool, renameProvider: bool,
completionProvider: struct { completionProvider: struct {
resolveProvider: bool, resolveProvider: bool,
triggerCharacters: []const []const u8, triggerCharacters: []const string,
}, },
documentHighlightProvider: bool, documentHighlightProvider: bool,
hoverProvider: bool, hoverProvider: bool,
@ -358,13 +359,13 @@ const InitializeResult = struct {
full: bool, full: bool,
range: bool, range: bool,
legend: struct { legend: struct {
tokenTypes: []const []const u8, tokenTypes: []const string,
tokenModifiers: []const []const u8, tokenModifiers: []const string,
}, },
}, },
}, },
serverInfo: struct { serverInfo: struct {
name: []const u8, name: string,
version: ?[]const u8 = null, version: ?string = null,
}, },
}; };