Fix merge conflicts
This commit is contained in:
		
						commit
						04abb3a5ff
					
				
							
								
								
									
										106
									
								
								src/main.zig
									
									
									
									
									
								
							
							
						
						
									
										106
									
								
								src/main.zig
									
									
									
									
									
								
							@ -45,12 +45,12 @@ pub fn log(comptime fmt: []const u8, args: var) !void {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    try send(types.Notification{
 | 
					    try send(types.Notification{
 | 
				
			||||||
        .method = "window/logMessage",
 | 
					        .method = "window/logMessage",
 | 
				
			||||||
        .params = types.NotificationParams{
 | 
					        .params = .{
 | 
				
			||||||
            .LogMessageParams = types.LogMessageParams{
 | 
					            .LogMessageParams = .{
 | 
				
			||||||
                .@"type" = types.MessageType.Log,
 | 
					                .@"type" = .Log,
 | 
				
			||||||
                .message = message
 | 
					                .message = message,
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,9 +71,9 @@ pub fn respondGeneric(id: i64, response: []const u8) !void {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pub fn openDocument(uri: []const u8, text: []const u8) !void {
 | 
					pub fn openDocument(uri: []const u8, text: []const u8) !void {
 | 
				
			||||||
    const du = try std.mem.dupe(allocator, u8, uri);
 | 
					    const du = try std.mem.dupe(allocator, u8, uri);
 | 
				
			||||||
    _ = try documents.put(du, types.TextDocument{
 | 
					    _ = try documents.put(du, .{
 | 
				
			||||||
        .uri = du,
 | 
					        .uri = du,
 | 
				
			||||||
        .text = try std.mem.dupe(allocator, u8, text)
 | 
					        .text = try std.mem.dupe(allocator, u8, text),
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -97,18 +97,18 @@ pub fn publishDiagnostics(document: types.TextDocument) !void {
 | 
				
			|||||||
            var fbs = std.io.fixedBufferStream(&mem_buffer);
 | 
					            var fbs = std.io.fixedBufferStream(&mem_buffer);
 | 
				
			||||||
            _ = try tree.renderError(err, fbs.outStream());
 | 
					            _ = try tree.renderError(err, fbs.outStream());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try diagnostics.append(types.Diagnostic{
 | 
					            try diagnostics.append(.{
 | 
				
			||||||
                .range = types.Range{
 | 
					                .range = .{
 | 
				
			||||||
                    .start = types.Position{
 | 
					                    .start = .{
 | 
				
			||||||
                        .line = @intCast(i64, loc.line),
 | 
					                        .line = @intCast(i64, loc.line),
 | 
				
			||||||
                        .character = @intCast(i64, loc.column)
 | 
					                        .character = @intCast(i64, loc.column),
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    .end = types.Position{
 | 
					                    .end = .{
 | 
				
			||||||
                        .line = @intCast(i64, loc.line),
 | 
					                        .line = @intCast(i64, loc.line),
 | 
				
			||||||
                        .character = @intCast(i64, loc.column)
 | 
					                        .character = @intCast(i64, loc.column),
 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                .severity = types.DiagnosticSeverity.Error,
 | 
					                },
 | 
				
			||||||
 | 
					                .severity = .Error,
 | 
				
			||||||
                .code = @tagName(err.*),
 | 
					                .code = @tagName(err.*),
 | 
				
			||||||
                .source = "zls",
 | 
					                .source = "zls",
 | 
				
			||||||
                // We dupe the string from the stack to our arena
 | 
					                // We dupe the string from the stack to our arena
 | 
				
			||||||
@ -126,18 +126,18 @@ pub fn publishDiagnostics(document: types.TextDocument) !void {
 | 
				
			|||||||
                    if (func.name_token) |name_token| {
 | 
					                    if (func.name_token) |name_token| {
 | 
				
			||||||
                        const loc = tree.tokenLocation(0, name_token);
 | 
					                        const loc = tree.tokenLocation(0, name_token);
 | 
				
			||||||
                        if (func.extern_export_inline_token == null and !analysis.isCamelCase(tree.tokenSlice(name_token))) {
 | 
					                        if (func.extern_export_inline_token == null and !analysis.isCamelCase(tree.tokenSlice(name_token))) {
 | 
				
			||||||
                            try diagnostics.append(types.Diagnostic{
 | 
					                            try diagnostics.append(.{
 | 
				
			||||||
                                .range = types.Range{
 | 
					                                .range = .{
 | 
				
			||||||
                                    .start = types.Position{
 | 
					                                    .start = .{
 | 
				
			||||||
                                        .line = @intCast(i64, loc.line),
 | 
					                                        .line = @intCast(i64, loc.line),
 | 
				
			||||||
                                        .character = @intCast(i64, loc.column)
 | 
					                                        .character = @intCast(i64, loc.column),
 | 
				
			||||||
                                    },
 | 
					                                    },
 | 
				
			||||||
                                    .end = types.Position{
 | 
					                                    .end = .{
 | 
				
			||||||
                                        .line = @intCast(i64, loc.line),
 | 
					                                        .line = @intCast(i64, loc.line),
 | 
				
			||||||
                                        .character = @intCast(i64, loc.column)
 | 
					                                        .character = @intCast(i64, loc.column),
 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                    },
 | 
					                                    },
 | 
				
			||||||
                                .severity = types.DiagnosticSeverity.Information,
 | 
					                                },
 | 
				
			||||||
 | 
					                                .severity = .Information,
 | 
				
			||||||
                                .code = "BadStyle",
 | 
					                                .code = "BadStyle",
 | 
				
			||||||
                                .source = "zls",
 | 
					                                .source = "zls",
 | 
				
			||||||
                                .message = "Callables should be camelCase"
 | 
					                                .message = "Callables should be camelCase"
 | 
				
			||||||
@ -152,12 +152,12 @@ pub fn publishDiagnostics(document: types.TextDocument) !void {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    try send(types.Notification{
 | 
					    try send(types.Notification{
 | 
				
			||||||
        .method = "textDocument/publishDiagnostics",
 | 
					        .method = "textDocument/publishDiagnostics",
 | 
				
			||||||
        .params = types.NotificationParams{
 | 
					        .params = .{
 | 
				
			||||||
            .PublishDiagnosticsParams = types.PublishDiagnosticsParams{
 | 
					            .PublishDiagnosticsParams = .{
 | 
				
			||||||
                .uri = document.uri,
 | 
					                .uri = document.uri,
 | 
				
			||||||
                .diagnostics = diagnostics.items,
 | 
					                .diagnostics = diagnostics.items,
 | 
				
			||||||
            }
 | 
					            },
 | 
				
			||||||
        }
 | 
					        },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -184,28 +184,28 @@ pub fn completeGlobal(id: i64, document: types.TextDocument) !void {
 | 
				
			|||||||
                const func = decl.cast(std.zig.ast.Node.FnProto).?;
 | 
					                const func = decl.cast(std.zig.ast.Node.FnProto).?;
 | 
				
			||||||
                var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl);
 | 
					                var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl);
 | 
				
			||||||
                var doc = types.MarkupContent{
 | 
					                var doc = types.MarkupContent{
 | 
				
			||||||
                    .kind = types.MarkupKind.Markdown,
 | 
					                    .kind = .Markdown,
 | 
				
			||||||
                    .value = doc_comments orelse ""
 | 
					                    .value = doc_comments orelse "",
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                try completions.append(types.CompletionItem{
 | 
					                try completions.append(.{
 | 
				
			||||||
                    .label = tree.tokenSlice(func.name_token.?),
 | 
					                    .label = tree.tokenSlice(func.name_token.?),
 | 
				
			||||||
                    .kind = types.CompletionItemKind.Function,
 | 
					                    .kind = .Function,
 | 
				
			||||||
                    .documentation = doc,
 | 
					                    .documentation = doc,
 | 
				
			||||||
                    .detail = analysis.getFunctionSignature(tree, func)
 | 
					                    .detail = analysis.getFunctionSignature(tree, func),
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            .VarDecl => {
 | 
					            .VarDecl => {
 | 
				
			||||||
                const var_decl = decl.cast(std.zig.ast.Node.VarDecl).?;
 | 
					                const var_decl = decl.cast(std.zig.ast.Node.VarDecl).?;
 | 
				
			||||||
                var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl);
 | 
					                var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl);
 | 
				
			||||||
                var doc = types.MarkupContent{
 | 
					                var doc = types.MarkupContent{
 | 
				
			||||||
                    .kind = types.MarkupKind.Markdown,
 | 
					                    .kind = .Markdown,
 | 
				
			||||||
                    .value = doc_comments orelse ""
 | 
					                    .value = doc_comments orelse "",
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                try completions.append(types.CompletionItem{
 | 
					                try completions.append(.{
 | 
				
			||||||
                    .label = tree.tokenSlice(var_decl.name_token),
 | 
					                    .label = tree.tokenSlice(var_decl.name_token),
 | 
				
			||||||
                    .kind = types.CompletionItemKind.Variable,
 | 
					                    .kind = .Variable,
 | 
				
			||||||
                    .documentation = doc,
 | 
					                    .documentation = doc,
 | 
				
			||||||
                    .detail = analysis.getVariableSignature(tree, var_decl)
 | 
					                    .detail = analysis.getVariableSignature(tree, var_decl),
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            else => {}
 | 
					            else => {}
 | 
				
			||||||
@ -215,12 +215,12 @@ pub fn completeGlobal(id: i64, document: types.TextDocument) !void {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    try send(types.Response{
 | 
					    try send(types.Response{
 | 
				
			||||||
        .id = .{.Integer = id},
 | 
					        .id = .{.Integer = id},
 | 
				
			||||||
        .result = types.ResponseParams{
 | 
					        .result = .{
 | 
				
			||||||
            .CompletionList = types.CompletionList{
 | 
					            .CompletionList = .{
 | 
				
			||||||
                .isIncomplete = false,
 | 
					                .isIncomplete = false,
 | 
				
			||||||
                .items = completions.items,
 | 
					                .items = completions.items,
 | 
				
			||||||
            }
 | 
					            },
 | 
				
			||||||
        }
 | 
					        },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -232,18 +232,18 @@ const builtin_completions = block: {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    for (data.builtins) |builtin, i| {
 | 
					    for (data.builtins) |builtin, i| {
 | 
				
			||||||
        var cutoff = std.mem.indexOf(u8, builtin, "(") orelse builtin.len;
 | 
					        var cutoff = std.mem.indexOf(u8, builtin, "(") orelse builtin.len;
 | 
				
			||||||
        temp[i] = types.CompletionItem{
 | 
					        temp[i] = .{
 | 
				
			||||||
            .label = builtin[0..cutoff],
 | 
					            .label = builtin[0..cutoff],
 | 
				
			||||||
            .kind = types.CompletionItemKind.Function,
 | 
					            .kind = .Function,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            .filterText = builtin[1..cutoff],
 | 
					            .filterText = builtin[1..cutoff],
 | 
				
			||||||
            .insertText = builtin[1..],
 | 
					            .insertText = builtin[1..],
 | 
				
			||||||
            .insertTextFormat = types.InsertTextFormat.Snippet,
 | 
					            .insertTextFormat = .Snippet,
 | 
				
			||||||
            .detail = data.builtin_details[i],
 | 
					            .detail = data.builtin_details[i],
 | 
				
			||||||
            .documentation = types.MarkupContent{
 | 
					            .documentation = .{
 | 
				
			||||||
                .kind = types.MarkupKind.Markdown,
 | 
					                .kind = .Markdown,
 | 
				
			||||||
                .value = data.builtin_docs[i]
 | 
					                .value = data.builtin_docs[i],
 | 
				
			||||||
            }
 | 
					            },
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -343,12 +343,12 @@ pub fn processJsonRpc(json: []const u8) !void {
 | 
				
			|||||||
            if (char == '@') {
 | 
					            if (char == '@') {
 | 
				
			||||||
                try send(types.Response{
 | 
					                try send(types.Response{
 | 
				
			||||||
                    .id = .{.Integer = id},
 | 
					                    .id = .{.Integer = id},
 | 
				
			||||||
                    .result = types.ResponseParams{
 | 
					                    .result = .{
 | 
				
			||||||
                        .CompletionList = types.CompletionList{
 | 
					                        .CompletionList = .{
 | 
				
			||||||
                            .isIncomplete = false,
 | 
					                            .isIncomplete = false,
 | 
				
			||||||
                            .items = builtin_completions[0..]
 | 
					                            .items = builtin_completions[0..],
 | 
				
			||||||
                        }
 | 
					                        },
 | 
				
			||||||
                    }
 | 
					                    },
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            } else if (char != '.') {
 | 
					            } else if (char != '.') {
 | 
				
			||||||
                try completeGlobal(id, document);
 | 
					                try completeGlobal(id, document);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user