Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support initialization options #1934

Merged
merged 2 commits into from
Jul 3, 2024
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
10 changes: 9 additions & 1 deletion src/Server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ fn autofix(server: *Server, arena: std.mem.Allocator, handle: *DocumentStore.Han
return text_edits;
}

fn initializeHandler(server: *Server, _: std.mem.Allocator, request: types.InitializeParams) Error!types.InitializeResult {
fn initializeHandler(server: *Server, arena: std.mem.Allocator, request: types.InitializeParams) Error!types.InitializeResult {
var skip_set_fixall = false;

if (request.clientInfo) |clientInfo| {
Expand Down Expand Up @@ -538,6 +538,14 @@ fn initializeHandler(server: *Server, _: std.mem.Allocator, request: types.Initi

server.status = .initializing;

if (request.initializationOptions) |initialization_options| {
if (std.json.parseFromValueLeaky(Config, arena, initialization_options, .{})) |new_cfg| {
try server.updateConfiguration2(new_cfg);
} else |err| {
log.err("failed to read initialization_options: {}", .{err});
}
}

if (!zig_builtin.is_test) {
var maybe_config_result = if (server.config_path) |config_path|
configuration.loadFromFile(server.allocator, config_path)
Expand Down