Update to LSP version 3.16 semantic tokens protocol
This commit is contained in:
parent
2559f5c6fd
commit
b52817cd8f
@ -1140,7 +1140,7 @@ fn openDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req
|
|||||||
const handle = try document_store.openDocument(req.params.textDocument.uri, req.params.textDocument.text);
|
const handle = try document_store.openDocument(req.params.textDocument.uri, req.params.textDocument.text);
|
||||||
try publishDiagnostics(arena, handle.*, configFromUriOr(req.params.textDocument.uri, config));
|
try publishDiagnostics(arena, handle.*, configFromUriOr(req.params.textDocument.uri, config));
|
||||||
|
|
||||||
try semanticTokensHandler(arena, id, .{ .params = .{ .textDocument = .{ .uri = req.params.textDocument.uri } } }, config);
|
try semanticTokensFullHandler(arena, id, .{ .params = .{ .textDocument = .{ .uri = req.params.textDocument.uri } } }, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn changeDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.ChangeDocument, config: Config) !void {
|
fn changeDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.ChangeDocument, config: Config) !void {
|
||||||
@ -1166,7 +1166,7 @@ fn closeDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, re
|
|||||||
document_store.closeDocument(req.params.textDocument.uri);
|
document_store.closeDocument(req.params.textDocument.uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn semanticTokensHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.SemanticTokens, config: Config) (error{OutOfMemory} || std.fs.File.WriteError)!void {
|
fn semanticTokensFullHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.SemanticTokensFull, config: Config) (error{OutOfMemory} || std.fs.File.WriteError)!void {
|
||||||
const this_config = configFromUriOr(req.params.textDocument.uri, config);
|
const this_config = configFromUriOr(req.params.textDocument.uri, config);
|
||||||
if (this_config.enable_semantic_tokens) {
|
if (this_config.enable_semantic_tokens) {
|
||||||
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
|
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
|
||||||
@ -1180,7 +1180,7 @@ fn semanticTokensHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, r
|
|||||||
|
|
||||||
return try send(arena, types.Response{
|
return try send(arena, types.Response{
|
||||||
.id = id,
|
.id = id,
|
||||||
.result = .{ .SemanticTokens = .{ .data = token_array } },
|
.result = .{ .SemanticTokensFull = .{ .data = token_array } },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1427,7 +1427,7 @@ fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, jso
|
|||||||
.{ "textDocument/didChange", requests.ChangeDocument, changeDocumentHandler },
|
.{ "textDocument/didChange", requests.ChangeDocument, changeDocumentHandler },
|
||||||
.{ "textDocument/didSave", requests.SaveDocument, saveDocumentHandler },
|
.{ "textDocument/didSave", requests.SaveDocument, saveDocumentHandler },
|
||||||
.{ "textDocument/didClose", requests.CloseDocument, closeDocumentHandler },
|
.{ "textDocument/didClose", requests.CloseDocument, closeDocumentHandler },
|
||||||
.{ "textDocument/semanticTokens", requests.SemanticTokens, semanticTokensHandler },
|
.{ "textDocument/semanticTokens/full", requests.SemanticTokensFull, semanticTokensFullHandler },
|
||||||
.{ "textDocument/completion", requests.Completion, completionHandler },
|
.{ "textDocument/completion", requests.Completion, completionHandler },
|
||||||
.{ "textDocument/signatureHelp", void, signatureHelperHandler },
|
.{ "textDocument/signatureHelp", void, signatureHelperHandler },
|
||||||
.{ "textDocument/definition", requests.GotoDefinition, gotoDefinitionHandler },
|
.{ "textDocument/definition", requests.GotoDefinition, gotoDefinitionHandler },
|
||||||
@ -1482,6 +1482,7 @@ fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, jso
|
|||||||
.{"textDocument/prepareRename"},
|
.{"textDocument/prepareRename"},
|
||||||
.{"textDocument/foldingRange"},
|
.{"textDocument/foldingRange"},
|
||||||
.{"textDocument/selectionRange"},
|
.{"textDocument/selectionRange"},
|
||||||
|
.{"textDocument/semanticTokens/range"},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (unimplemented_map.has(method)) {
|
if (unimplemented_map.has(method)) {
|
||||||
|
@ -186,7 +186,7 @@ const TextDocumentIdentifierRequest = struct {
|
|||||||
|
|
||||||
pub const SaveDocument = TextDocumentIdentifierRequest;
|
pub const SaveDocument = TextDocumentIdentifierRequest;
|
||||||
pub const CloseDocument = TextDocumentIdentifierRequest;
|
pub const CloseDocument = TextDocumentIdentifierRequest;
|
||||||
pub const SemanticTokens = TextDocumentIdentifierRequest;
|
pub const SemanticTokensFull = TextDocumentIdentifierRequest;
|
||||||
|
|
||||||
const TextDocumentIdentifierPositionRequest = struct {
|
const TextDocumentIdentifierPositionRequest = struct {
|
||||||
params: struct {
|
params: struct {
|
||||||
|
@ -56,7 +56,7 @@ pub const ResponseParams = union(enum) {
|
|||||||
Location: Location,
|
Location: Location,
|
||||||
Hover: Hover,
|
Hover: Hover,
|
||||||
DocumentSymbols: []DocumentSymbol,
|
DocumentSymbols: []DocumentSymbol,
|
||||||
SemanticTokens: struct { data: []const u32 },
|
SemanticTokensFull: struct { data: []const u32 },
|
||||||
TextEdits: []TextEdit,
|
TextEdits: []TextEdit,
|
||||||
Locations: []Location,
|
Locations: []Location,
|
||||||
WorkspaceEdit: WorkspaceEdit,
|
WorkspaceEdit: WorkspaceEdit,
|
||||||
|
@ -92,7 +92,7 @@ test "Open file, ask for semantic tokens" {
|
|||||||
const new_file_req = \\{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file://./tests/test.zig","languageId":"zig","version":420,"text":"const std = @import(\"std\");"}}}
|
const new_file_req = \\{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file://./tests/test.zig","languageId":"zig","version":420,"text":"const std = @import(\"std\");"}}}
|
||||||
;
|
;
|
||||||
try sendRequest(new_file_req, process);
|
try sendRequest(new_file_req, process);
|
||||||
const sem_toks_req = \\{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens","params":{"textDocument":{"uri":"file://./tests/test.zig"}}}
|
const sem_toks_req = \\{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file://./tests/test.zig"}}}
|
||||||
;
|
;
|
||||||
try sendRequest(sem_toks_req, process);
|
try sendRequest(sem_toks_req, process);
|
||||||
try sendRequest(shutdown_message, process);
|
try sendRequest(shutdown_message, process);
|
||||||
|
Loading…
Reference in New Issue
Block a user