Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make variable declaration and parameter name hints separately configurable #1453

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ The following options are currently available.
| `enable_import_embedfile_argument_completions` | `bool` | `true` | Whether to enable import/embedFile argument completions |
| `semantic_tokens` | `enum` | `.full` | Set level of semantic tokens. Partial only includes information that requires semantic analysis. |
| `enable_inlay_hints` | `bool` | `true` | Enables inlay hint support when the client also supports it |
| `inlay_hints_show_variable_declaration` | `bool` | `true` | Enable inlay hints for variable declarations |
| `inlay_hints_show_parameter_name` | `bool` | `true` | Enable inlay hints for parameter names |
| `inlay_hints_show_builtin` | `bool` | `true` | Enable inlay hints for builtin functions |
| `inlay_hints_exclude_single_argument` | `bool` | `true` | Don't show inlay hints for single argument calls |
| `inlay_hints_hide_redundant_param_names` | `bool` | `false` | Hides inlay hints when parameter name matches the identifier (e.g. foo: foo) |
Expand Down
10 changes: 10 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
"type": "boolean",
"default": "true"
},
"inlay_hints_show_variable_declaration": {
"description": "Enable inlay hints for variable declarations",
"type": "boolean",
"default": "true"
},
"inlay_hints_show_parameter_name": {
"description": "Enable inlay hints for parameter names",
"type": "boolean",
"default": "true"
},
"inlay_hints_show_builtin": {
"description": "Enable inlay hints for builtin functions",
"type": "boolean",
Expand Down
6 changes: 6 additions & 0 deletions src/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ semantic_tokens: enum {
/// Enables inlay hint support when the client also supports it
enable_inlay_hints: bool = true,

/// Enable inlay hints for variable declarations
inlay_hints_show_variable_declaration: bool = true,

/// Enable inlay hints for parameter names
inlay_hints_show_parameter_name: bool = true,

/// Enable inlay hints for builtin functions
inlay_hints_show_builtin: bool = true,

Expand Down
12 changes: 12 additions & 0 deletions src/config_gen/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@
"type": "bool",
"default": "true"
},
{
"name": "inlay_hints_show_variable_declaration",
"description": "Enable inlay hints for variable declarations",
"type": "bool",
"default": "true"
},
{
"name": "inlay_hints_show_parameter_name",
"description": "Enable inlay hints for parameter names",
"type": "bool",
"default": "true"
},
{
"name": "inlay_hints_show_builtin",
"description": "Enable inlay hints for builtin functions",
Expand Down
9 changes: 7 additions & 2 deletions src/features/inlay_hints.zig
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ fn writeNodeInlayHint(
.async_call,
.async_call_comma,
=> {
if (!builder.config.inlay_hints_show_parameter_name) return;

var params: [1]Ast.Node.Index = undefined;
const call = tree.fullCall(&params, node).?;
try writeCallNodeHint(builder, call);
Expand All @@ -328,17 +330,20 @@ fn writeNodeInlayHint(
.global_var_decl,
.aligned_var_decl,
=> {
if (!builder.config.inlay_hints_show_variable_declaration) return;
try writeVariableDeclHint(builder, node);
},
.builtin_call_two,
.builtin_call_two_comma,
.builtin_call,
.builtin_call_comma,
=> blk: {
=> {
if (!builder.config.inlay_hints_show_parameter_name or !builder.config.inlay_hints_show_builtin) return;

var buffer: [2]Ast.Node.Index = undefined;
const params = ast.builtinCallParams(tree, node, &buffer).?;

if (!builder.config.inlay_hints_show_builtin or params.len == 0) break :blk;
if (params.len == 0) return;

const name = tree.tokenSlice(main_tokens[node]);

Expand Down