Add no_snippets

This commit is contained in:
SuperAuguste 2020-05-07 13:16:04 -04:00
parent 14a2796857
commit 01ff89eea3
2 changed files with 33 additions and 12 deletions

View File

@ -23,6 +23,12 @@ pub fn build(b: *std.build.Builder) !void {
data_version,
);
exe.addBuildOption(
bool,
"no_snippets",
b.option(bool, "no_snippets", "Use regular completion without snippets. Useful for compatibility.") orelse false,
);
exe.addBuildOption(
bool,
"leak_detection",

View File

@ -261,6 +261,20 @@ const builtin_completions = block: {
for (data.builtins) |builtin, i| {
var cutoff = std.mem.indexOf(u8, builtin, "(") orelse builtin.len;
if (build_options.no_snippets) {
temp[i] = .{
.label = builtin[0..cutoff],
.kind = .Function,
.filterText = builtin[1..cutoff],
.insertText = builtin[1..cutoff],
.detail = data.builtin_details[i],
.documentation = .{
.kind = .Markdown,
.value = data.builtin_docs[i],
},
};
} else {
temp[i] = .{
.label = builtin[0..cutoff],
.kind = .Function,
@ -275,6 +289,7 @@ const builtin_completions = block: {
},
};
}
}
break :block temp;
};