diff --git a/src/Server.zig b/src/Server.zig index e09874b..d71f133 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -2565,6 +2565,7 @@ pub fn init( ) !Server { // TODO replace global with something like an Analyser struct // which contains using_trail & resolve_trail and place it inside Server + // see: https://github.com/zigtools/zls/issues/536 analysis.init(allocator); var server: Server = .{ diff --git a/tests/context.zig b/tests/context.zig index 59c58b4..d31e308 100644 --- a/tests/context.zig +++ b/tests/context.zig @@ -84,4 +84,4 @@ pub const Context = struct { try std.testing.expectEqualStrings(expected, result_json); } -}; \ No newline at end of file +}; diff --git a/tests/sessions.zig b/tests/sessions.zig index 619e24d..b2ee3ac 100644 --- a/tests/sessions.zig +++ b/tests/sessions.zig @@ -73,6 +73,23 @@ test "Self-referential definition" { ); } +// This test as written depends on the configuration in the *host* machines zls.json, if `enable_snippets` is true then +// the insert text is "w()" if it is false it is "w" +// +// test "Missing return type" { +// var server = try Server.start(initialize_msg, null); +// defer server.shutdown(); + +// try server.request("textDocument/didOpen", +// \\{"textDocument":{"uri":"file:///test.zig","languageId":"zig","version":420,"text":"fn w() {}\nc"}} +// , null); +// try server.request("textDocument/completion", +// \\{"textDocument":{"uri":"file:///test.zig"}, "position":{"line":1,"character":1}} +// , +// \\{"isIncomplete":false,"items":[{"label":"w","kind":3,"textEdit":null,"filterText":null,"insertText":"w","insertTextFormat":1,"detail":"fn","documentation":null}]} +// ); +// } + test "Pointer and optional deref" { var ctx = try Context.init(); defer ctx.deinit(); @@ -86,3 +103,18 @@ test "Pointer and optional deref" { \\{"isIncomplete":false,"items":[{"label":"data","labelDetails":{"detail":"","description":"i32 ","sortText":null},"kind":5,"detail":"data","sortText":"3_data","filterText":null,"insertText":"data","insertTextFormat":1,"documentation":null}]} ); } + +// not fixed yet! +// test "Self-referential import" { +// var ctx = try Context.init(); +// defer ctx.deinit(); +// +// try ctx.request("textDocument/didOpen", +// \\{"textDocument":{"uri":"file:///test.zig","languageId":"zig","version":420,"text":"const a = @import(\"test.zig\").a;\nc"}} +// , null); +// try ctx.request("textDocument/completion", +// \\{"textDocument":{"uri":"file:///test.zig"}, "position":{"line":1,"character":1}} +// , +// \\{"isIncomplete":false,"items":[]} +// ); +// }