zls
zls copied to clipboard
sort completions based on the result location type at the current cursor position
In the following code snippet, in which order should the completions be ordered?
const large_number: u64 = 0;
const small_number: u32 = 0;
const byte: u8 = 0;
const string: []const u8 = "";
fn foo(_: u32) u32 {}
test {
foo(<cursor>);
}
byte, small_number and foo() should come first because only they can coerce to the result location type u32.
const some_variable: u32 = 5;
const some_type: type = u32;
const T: <cursor> = undefined;
some_type should come first because it can coerce to the result location type type.
I can imagine many possible sorting rules on how to use RLS to improve completion and this example is just one of many.