add enable_autofix option

This commit is contained in:
Techatrix 2022-09-24 21:30:36 +02:00
parent 40c28d7a64
commit cfb7c16de0
5 changed files with 13 additions and 0 deletions

View File

@ -103,6 +103,7 @@ The following options are currently available.
| --- | --- | --- | --- |
| `enable_snippets` | `bool` | `false` | Enables snippet completions when the client also supports them. |
| `enable_ast_check_diagnostics` | `bool` | `true`| Whether to enable ast-check diagnostics |
| `enable_autofix` | `bool` | `false`| Whether to automatically fix errors on save. Currently supports adding and removing discards. |
| `enable_import_embedfile_argument_completions` | `bool` | `false` | Whether to enable import/embedFile argument completions |
| `zig_lib_path` | `?[]const u8` | `null` | zig library path, e.g. `/path/to/zig/lib/zig`, used to analyze std library imports. |
| `zig_exe_path` | `?[]const u8` | `null` | zig executable path, e.g. `/path/to/zig/zig`, used to run the custom build runner. If `null`, zig is looked up in `PATH`. Will be used to infer the zig standard library path if none is provided. |

View File

@ -14,6 +14,11 @@
"type": "boolean",
"default": "true"
},
"enable_autofix": {
"description": "Whether to automatically fix errors on save. Currently supports adding and removing discards.",
"type": "boolean",
"default": "false"
},
"enable_import_embedfile_argument_completions": {
"description": "Whether to enable import/embedFile argument completions",
"type": "boolean",

View File

@ -16,6 +16,10 @@ enable_snippets: bool = false,
/// Whether to enable ast-check diagnostics
enable_ast_check_diagnostics: bool = true,
/// Whether to automatically fix errors on save.
/// Currently supports adding and removing discards.
enable_autofix: bool = false,
/// Whether to enable import/embedFile argument completions (NOTE: these are triggered manually as updating the autotrigger characters may cause issues)
enable_import_embedfile_argument_completions: bool = false,

View File

@ -289,6 +289,7 @@ pub const Configuration = struct {
settings: struct {
enable_snippets: ?bool,
enable_ast_check_diagnostics: ?bool,
enable_autofix: ?bool,
enable_import_embedfile_argument_completions: ?bool,
zig_lib_path: ?[]const u8,
zig_exe_path: ?[]const u8,

View File

@ -171,6 +171,7 @@ pub fn wizard(allocator: std.mem.Allocator) !void {
const editor = try askSelectOne("Which code editor do you use?", enum { VSCode, Sublime, Kate, Neovim, Vim8, Emacs, Doom, Spacemacs, Helix, Other });
const snippets = try askBool("Do you want to enable snippets?");
const ast_check = try askBool("Do you want to enable ast-check diagnostics?");
const autofix = try askBool("Do you want to zls to automatically try to fix errors on save? (supports adding & removing discards)");
const ief_apc = try askBool("Do you want to enable @import/@embedFile argument path completion?");
const style = try askBool("Do you want to enable style warnings?");
const semantic_tokens = try askBool("Do you want to enable semantic highlighting?");
@ -193,6 +194,7 @@ pub fn wizard(allocator: std.mem.Allocator) !void {
.zig_exe_path = zig_exe_path,
.enable_snippets = snippets,
.enable_ast_check_diagnostics = ast_check,
.enable_autofix = autofix,
.enable_import_embedfile_argument_completions = ief_apc,
.warn_style = style,
.enable_semantic_tokens = semantic_tokens,