zls icon indicating copy to clipboard operation
zls copied to clipboard

proposal: allow hovers on inferred struct types

Open emidoots opened this issue 2 years ago • 3 comments

It's extremely common for newcomers to come across code that looks like this and not know what .{} means:

const foo = b.addStaticLibrary(.{
    // ...
});

In some cases, I've seen people prefer writing the full type names in their code and not use inferred types, in order to make ZLS hovers work, e.g.:

const foo = b.addStaticLibrary(std.Build.StaticLibraryOptions{
    // ...
});

Proposal: ZLS should be smart enough to know that a hover on .{} is the same as a hover on StaticLibraryOptions and should show the same contents.

emidoots avatar Nov 01 '23 07:11 emidoots

Are you proposing that as an example, hovering over the . in a .{} should show its result location type similar to this: Screenshot from 2023-11-01 18-42-59 I guess this would also suggest that a go to definition request on the . should bring you to the definition of std.Build.StaticLibraryOptions.

Techatrix avatar Nov 01 '23 17:11 Techatrix

That would be pretty fantastic for the modal editor workflow, where you can't goto the definition of a type referenced in the on-hover definition popup.

InKryption avatar Nov 01 '23 21:11 InKryption

Yep exactly, I agree go-to-def should behave the same

emidoots avatar Nov 01 '23 22:11 emidoots