Doc comments, function completion in structs
This commit is contained in:
parent
e9b5bf433e
commit
20afe9ef3c
29
src/main.zig
29
src/main.zig
@ -316,10 +316,37 @@ fn completeFieldAccess(id: i64, document: *types.TextDocument, position: types.P
|
|||||||
var index: usize = 0;
|
var index: usize = 0;
|
||||||
while (node.iterate(index)) |child_node| {
|
while (node.iterate(index)) |child_node| {
|
||||||
if (analysis.nodeToString(tree, child_node)) |string| {
|
if (analysis.nodeToString(tree, child_node)) |string| {
|
||||||
|
var doc_comments = try analysis.getDocComments(&arena.allocator, tree, child_node);
|
||||||
|
var doc = types.MarkupContent{
|
||||||
|
.kind = .Markdown,
|
||||||
|
.value = doc_comments orelse "",
|
||||||
|
};
|
||||||
|
switch (child_node.id) {
|
||||||
|
.FnProto => {
|
||||||
|
const func = child_node.cast(std.zig.ast.Node.FnProto).?;
|
||||||
|
|
||||||
|
const insert_text = if (config.enable_snippets)
|
||||||
|
try analysis.getFunctionSnippet(&arena.allocator, tree, func)
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
try completions.append(.{
|
try completions.append(.{
|
||||||
.label = string,
|
.label = string,
|
||||||
.kind = .Variable,
|
.kind = .Function,
|
||||||
|
.documentation = doc,
|
||||||
|
.detail = analysis.getFunctionSignature(tree, func),
|
||||||
|
.insertText = insert_text,
|
||||||
|
.insertTextFormat = if (config.enable_snippets) .Snippet else .PlainText,
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
try completions.append(.{
|
||||||
|
.label = string,
|
||||||
|
.kind = .Field,
|
||||||
|
.documentation = doc
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index += 1;
|
index += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user