Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions examples/my_first_server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub const Handler = struct {
},
},
.hoverProvider = .{ .bool = true },
.completionProvider = .{ .triggerCharacters = &.{"."} },
};

// Tries to validate that our server capabilities are actually implemented.
Expand Down Expand Up @@ -256,6 +257,33 @@ pub const Handler = struct {
};
}

pub fn @"textDocument/completion"(
_: *Handler,
arena: std.mem.Allocator,
params: lsp.types.CompletionParams,
) error{OutOfMemory}!lsp.ResultType("textDocument/completion") {
std.log.debug("Received 'textDocument/completion' notification", .{});

if (params.context) |context| {
std.log.info("completion triggered by {?s} {t}", .{
context.triggerCharacter,
context.triggerKind,
});
}

const completions = try arena.dupe(lsp.types.CompletionItem, &.{
.{
.label = "get",
.detail = "get the value",
},
.{
.label = "set",
.detail = "set the value",
},
});
return .{ .array_of_CompletionItem = completions };
}

/// We received a response message from the client/editor.
pub fn onResponse(
_: *Handler,
Expand Down
Loading