zls icon indicating copy to clipboard operation
zls copied to clipboard

Feature Request: Add completions for re-exported functions

Open SpexGuy opened this issue 4 years ago • 1 comments

A common pattern in bindings to C code goes like this:

const Handle = opaque {
    pub const setValue = lib_Handle_setValue;
    pub fn setArrayValues(self: *Handle, values: []u32) void {
        lib_Handle_setArrayValues(self, values.ptr, values.len);
    }
    
    extern fn lib_Handle_setValue(self: *Handle, val: u32) void;
    extern fn lib_Handle_setArrayValues(self: *Handle, values: ?[*]u32, len: usize) void;
};

Here two C functions have been bound to the Handle type for more convenient use. setArrayValues is a proper wrapper, in order to use a slice parameter. But setValue does not need any signature modification, so it has been exported directly under a new name. Unfortunately, ZLS cannot recognize this pattern. Autocomplete on a handle pointer will suggest setArrayValues but not setValue. It would be very convenient if ZLS could recognize these sorts of pass-through member functions and add them to the autocomplete list.

SpexGuy avatar Nov 29 '21 18:11 SpexGuy

root problem here is picking up functions that are const decls rather than fn decls. which is preparation for 1717 and I can +1 on wanting

nektro avatar Nov 29 '21 18:11 nektro