Merge pull request #260 from InterplanetaryEngineer/master
Add option for builtin completion insert text
This commit is contained in:
commit
2a57789be8
20
build.zig
20
build.zig
@ -55,10 +55,25 @@ pub fn config(step: *std.build.Step) anyerror!void {
|
||||
} else {
|
||||
std.debug.print("Found zig executable '{s}'\n", .{zig_exe_path.?});
|
||||
}
|
||||
|
||||
const editor = try zinput.askSelectOne("Which code editor do you use?", enum { VSCode, Sublime, Kate, Neovim, Vim8, Emacs, Doom, Other });
|
||||
const snippets = try zinput.askBool("Do you want to enable snippets?");
|
||||
const style = try zinput.askBool("Do you want to enable style warnings?");
|
||||
const semantic_tokens = try zinput.askBool("Do you want to enable semantic highlighting?");
|
||||
const operator_completions = try zinput.askBool("Do you want to enable .* and .? completions");
|
||||
const operator_completions = try zinput.askBool("Do you want to enable .* and .? completions?");
|
||||
const include_at_in_builtins = switch (editor) {
|
||||
.Sublime =>
|
||||
true,
|
||||
.VSCode,
|
||||
.Kate,
|
||||
.Neovim,
|
||||
.Vim8,
|
||||
.Emacs,
|
||||
.Doom =>
|
||||
false,
|
||||
else =>
|
||||
try zinput.askBool("Should the @ sign be included in completions of builtin functions?\nChange this later if `@inc` completes to `include` or `@@include`")
|
||||
};
|
||||
|
||||
var dir = try std.fs.cwd().openDir(builder.exe_dir, .{});
|
||||
defer dir.close();
|
||||
@ -76,11 +91,10 @@ pub fn config(step: *std.build.Step) anyerror!void {
|
||||
.warn_style = style,
|
||||
.enable_semantic_tokens = semantic_tokens,
|
||||
.operator_completions = operator_completions,
|
||||
.include_at_in_builtins = include_at_in_builtins,
|
||||
}, std.json.StringifyOptions{}, out);
|
||||
|
||||
std.debug.warn("Successfully saved configuration options!\n", .{});
|
||||
|
||||
const editor = try zinput.askSelectOne("Which code editor do you use?", enum { VSCode, Sublime, Kate, Neovim, Vim8, Emacs, Doom, Other });
|
||||
std.debug.warn("\n", .{});
|
||||
|
||||
switch (editor) {
|
||||
|
@ -26,6 +26,9 @@ enable_semantic_tokens: bool = true,
|
||||
/// Whether to enable `*` and `?` operators in completion lists
|
||||
operator_completions: bool = true,
|
||||
|
||||
/// Whether the @ sign should be part of the completion of builtins
|
||||
include_at_in_builtins: bool = false,
|
||||
|
||||
/// Skips references to std. This will improve lookup speeds.
|
||||
/// Going to definition however will continue to work
|
||||
skip_std_references: bool = false,
|
||||
|
10
src/main.zig
10
src/main.zig
@ -1026,12 +1026,18 @@ fn completeBuiltin(arena: *std.heap.ArenaAllocator, id: types.RequestId, config:
|
||||
},
|
||||
};
|
||||
|
||||
var insert_text: []const u8 = undefined;
|
||||
if (config.enable_snippets) {
|
||||
builtin_completions.?[idx].insertText = builtin.snippet[1..];
|
||||
insert_text = builtin.snippet;
|
||||
builtin_completions.?[idx].insertTextFormat = .Snippet;
|
||||
} else {
|
||||
builtin_completions.?[idx].insertText = builtin.name[1..];
|
||||
insert_text = builtin.name;
|
||||
}
|
||||
builtin_completions.?[idx].insertText =
|
||||
if (config.include_at_in_builtins)
|
||||
insert_text
|
||||
else
|
||||
insert_text[1..];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user