zls icon indicating copy to clipboard operation
zls copied to clipboard

Preserve documentation in C imports

Open TeamPuzel opened this issue 1 year ago • 2 comments

It would be useful if go to definition on symbols imported from C had the option to jump to the C header, not cached Zig translation. One use case for this is to see comments documenting the symbol, since comments are stripped from the zig translation.

Some C libraries, like SDL, even provide documentation comments which languages like Swift preserve correctly (import SDL here is just a clang module, not language specific bindings):

image

It would be a convenient feature to have in zig since it's also a language with C interoperability 🙂

TeamPuzel avatar May 25 '24 09:05 TeamPuzel

If the use case is solely to see comments then zig translate-c could be made to include comments in the generated Zig file (See https://github.com/ziglang/translate-c/issues/135). Is there another use case for goto definition jumping to the C file? Otherwise this issue is just https://github.com/ziglang/translate-c/issues/135.

Techatrix avatar May 25 '24 20:05 Techatrix

Oh I see, I didn't think it would be a compiler issue rather than language server so I didn't find that one, I guess it's probably unnecessary in that case. :)

I'm not sure how useful jumping to C files would be in Zig, that depends on how common it is to work with both languages in one project

TeamPuzel avatar May 26 '24 09:05 TeamPuzel

I am going to close this issue in favor of the Zig issue.

Techatrix avatar Jul 03 '24 16:07 Techatrix