compatible with the settings.zls in didChangeConfigurationHandler
				
					
				
			Signed-off-by: Ye Sijun <junnplus@gmail.com>
This commit is contained in:
		
							parent
							
								
									905f531a08
								
							
						
					
					
						commit
						643496922d
					
				@ -946,11 +946,12 @@ pub fn formattingHandler(server: *Server, request: types.DocumentFormattingParam
 | 
			
		||||
    return if (diff.edits(allocator, handle.text, formatted, server.offset_encoding)) |text_edits| text_edits.items else |_| null;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn didChangeConfigurationHandler(server: *Server, request: configuration.DidChangeConfigurationParams) Error!void {
 | 
			
		||||
fn didChangeConfigurationHandler(server: *Server, request: types.DidChangeConfigurationParams) Error!void {
 | 
			
		||||
    var new_zig_exe = false;
 | 
			
		||||
 | 
			
		||||
    // NOTE: VS Code seems to always respond with null
 | 
			
		||||
    if (request.settings) |cfg| {
 | 
			
		||||
    if (request.settings != .null) {
 | 
			
		||||
        const cfg = tres.parse(configuration.Configuration, request.settings.object.get("zls") orelse request.settings, null) catch return;
 | 
			
		||||
        inline for (std.meta.fields(configuration.Configuration)) |field| {
 | 
			
		||||
            if (@field(cfg, field.name)) |value| {
 | 
			
		||||
                blk: {
 | 
			
		||||
@ -1474,7 +1475,7 @@ pub fn processMessage(server: *Server, message: Message) Error!void {
 | 
			
		||||
        .{ "textDocument/references", referencesHandler },
 | 
			
		||||
        .{ "textDocument/documentHighlight", documentHighlightHandler },
 | 
			
		||||
        .{ "textDocument/codeAction", codeActionHandler },
 | 
			
		||||
        .{ "workspace/didChangeConfiguration", didChangeConfigurationHandler }, // types.DidChangeConfigurationParams
 | 
			
		||||
        .{ "workspace/didChangeConfiguration", didChangeConfigurationHandler },
 | 
			
		||||
        .{ "textDocument/foldingRange", foldingRangeHandler },
 | 
			
		||||
        .{ "textDocument/selectionRange", selectionRangeHandler },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@ -214,9 +214,6 @@ pub fn getZigEnv(allocator: std.mem.Allocator, zig_exe_path: []const u8) ?Env {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub const Configuration = getConfigurationType();
 | 
			
		||||
pub const DidChangeConfigurationParams = struct {
 | 
			
		||||
    settings: ?Configuration,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// returns a Struct which is the same as `Config` except that every field is optional.
 | 
			
		||||
fn getConfigurationType() type {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user