zls icon indicating copy to clipboard operation
zls copied to clipboard

Proposal: Only show missing fields in autocompletion on struct initialization

Open IntegratedQuantum opened this issue 1 year ago • 2 comments

So right now I'm in the process of learning Vulkan and it has a ton of large configuration structs. Now I would like to know what fields are missing so far and it would be nice if autocomplete would only show missing members. Since it isn't allowed to initialize a field twice it doesn't even make sense to show already present fields.

Current:

Screenshot at 2024-04-08 21-10-34

Proposed:

Screenshot at 2024-04-08 21-10-35

IntegratedQuantum avatar Apr 08 '24 19:04 IntegratedQuantum

The completion tests for struct initialization have some examples of this here.

Techatrix avatar Apr 08 '24 19:04 Techatrix

Initial support in https://github.com/zigtools/zls/tree/nullptrdevs/c012,

Excludes fields/switch cases that precede the current source_index, ie

S{
   .a = 1,
   .b = 2,
   . // ^--- excluded from completions list
   .fields_here = 3,
   .are_shown = 4,
};

llogick avatar Apr 11 '24 03:04 llogick