Metals: Complete keywords

Created on 29 Apr 2019  路  6Comments  路  Source: scalameta/metals

Is your feature request related to a problem? Please describe.

In vscode, when I intend to type super.postStop(), but for example a variable called supervisorStrategy is also in scope, super. will expand to supervisorStrategy..

Describe the solution you'd like

If super would be present in the list of auto-completions, I could just select that (or keep typing).

Describe alternatives you've considered

An alternative solution to my immediate frustration could be to change vscode not to expand the first autocomplete option when a '.' is typed. That would probably be ~both harder to achieve and~ less convenient for the user compared to making sure 'super' can also be autocompleted, though.

Most helpful comment

Me and @markus1189 took a stab at this issue at the flatMap(Oslo) spree and I'm hopeful we'll have this fixed for the next release.

All 6 comments

Thanks for reporting! I agree this behavior can be quite annoying and I think it applies to all keywords, not only super.

An alternative solution to my immediate frustration could be to change vscode not to expand the first autocomplete option when a '.' is typed.

This is actually easy to implement since Metals explicitly registers . as a "commit character". We could either

  • disable commit characters, easy to implement but results in maybe suboptimal UX
  • implement completions for keywords, harder to implement but results in hopefully better user experience

I've caught myself trying to complete keywords like extends so I'm personally leaning towards the second solution 馃

A (not so great) workaround is to type a space character to avoid the commit character, then backspace and write .

implement completions for keywords, harder to implement but results in hopefully better user experience

Perhaps a primitive implementation could just add completions for all common keywords regardless of context?

This approach would produce noisy results, for example case and finally would appear everywhere. We already have the syntax tree and can filter out which keywords are valid there, it's not a major challenge, just takes a bit of time to implement and test 馃槈

Me and @markus1189 took a stab at this issue at the flatMap(Oslo) spree and I'm hopeful we'll have this fixed for the next release.

Fixed in #712

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tanishiking picture tanishiking  路  4Comments

oscarvarto picture oscarvarto  路  3Comments

tpolecat picture tpolecat  路  3Comments

olafurpg picture olafurpg  路  4Comments

laughedelic picture laughedelic  路  3Comments