RLS should not autocomplete braces and parameter names and types

Normal Functions/Methods

Let’s say that I have this function:

fn my_function_name(foo: a::b::Foo, bar: &c::d::Bar, baz: &mut e::Baz) -> ();

On VS Code, if I start to write my_, IntelliSense menu would show me my_function_name on the list. I then use arrow key to move to the function and press Enter. The following code would appears:

my_function_name(foo: a::b::Foo, bar: &c::d::Bar, baz: &mut e::Baz)

I only want to have my_function_name, but now I have to delete the “foo: a::b::Foo, bar: &c::d::Bar, baz: &mut e::Baz” part from the editor before replacing it with my actual arguments.

And the deletion operation is not simply pressing or del button once. Because only the first parameter is selected, I must you my mouse to select all characters inside the braces before pressing the delete button.

Procedural Macros

The same happens for procedural macros:

Let’s say that I have a macro called rstest_parametrized, obviously its function signature is just like all procedural macros:

fn rstest_parametrized(attr: TokenStream, item: TokenStream) -> TokenStream;

I want to write this:

#[rstest_parametrized(
  a, b, c,
  case(0, 1, 2),
  case(3, 4, 5),
)]
fn my_function(a: i32, b: i32, c: i32) {}

When I start typing [rstest_, rstest_parametrized of course would appear in the auto-complete list, but when I choose it, the following text is written into the editor instead of the one I want:

#[rstest_parametrized(attr: TokenStream, item: TokenStream)]

I, of course, have to delete that highlighted part again and replace it with the right tokens.

Expected behavior

I would like RLS to behave like built-in TypeScript plugin of VS Code:

  • Auto-complete writes only function name to the editor, no parameters.
  • As for parameters, when the editing cursor is placed between the pair of braces, a floating pane shows up with function signature and documentation (This pane is the same pane that shows up when user hovers the mouse over a function name).

Questions

  1. Right now, is it possible to make RLS behaves the way I want?
  2. If (1) is not possible, where do I open an issue for this?

I opened an issue here: https://github.com/rust-lang/rls/issues/1464

With the function autocomplete, it’s meant to be so that you type the name, scroll to it, press tab, then you’ve got the signature, and every time you press tab you scroll through the arguments. Ie, my_fu + Tab (To autocomplete) then my_foo + Tab then my_baz + Tab, etc.

This is not an issue of RLS, it’s an issue of the IDE processing the output of RLS. RLS simply provides the most information it usefully can.

If you want VS Code not to insert the whole call template, check if it allows this, or file a feature request against VS Code.

(The case of proc-macros is arguably quite special and might be an RLS bug.)

1 Like

I know, but I could just type , instead of tab.

Beside, this is one of many way to use, ultilizing for this way limits the others:

  • I want to have autocomplete for my_foo and my_bar, but it only appear in normal circumstance.
  • Variable names are not the only thing to put inside the two braces, there’re also expressions.
  • The way you described get in the way of procedural macro.

And yet TypeScript is different. I also checked all options, none of them appear to change the behavior. It has to be RLS’s fault.

It just has to be!

Maybe Typescript’s language server doesn’t provide this info? VS Code obviously knows that this isn’t just a very long and strange function name, but that there are arguments in there, which it helpfully highlights and allows you to fill in one by one.

3 Likes