IntelliJ Scala plugin 2018.2: advanced “Implicit” support, improved patterns autocompletion, semantic highlighting, scalafmt and more

Posted on by Anton Yalyshev

First of all, we want to thank all the contributors who have helped us to implement so many useful new features, bug-fixes, and refactorings. You really inspire us to do our very best work. Your input is greatly appreciated!
Let’s take a look at the new features you’ll find in Scala Plugin 2018.2.

Improved display of Implicit conversions / arguments usage

Now the editor is capable of providing much more useful information about the “implicit” things happening in your code:

  • Scala plugin can show implicit conversions and arguments as inline hints.
  • The Editor also shows hints when an implicit argument is used explicitly.
  • Inline hints provide navigation to the implicit value or function declaration.

IM_1
Note, that sometimes implicit parameters are collapsed to (...). Such folding takes place in case of nested, list of ambiguous arguments, and arguments for conversions.
By the way, ambiguous arguments. We have also re-worked error highlighting. Now, in the same manner, we show places where a function didn’t find an appropriate implicit value, or a set of values is ambiguous.
IM_2
You’ve probably noticed already, that inline hints work in Editor mode. Enable it by
Ctrl + Alt + Shift + “+” hotkey:

  • A second press of the hotkey expands all foldings.
  • Ctrl + Alt + Shift + “-” will collapse all foldings or disable the mode.

Besides the inline hints we’ve also improved:

  • Parameter Info Tooltip (Ctrl/Cmd + P) by adding the implicit parameter;
  • Implicit Arguments Popup (Ctrl/Cmd + Shift + P) now shows type, structure, and location of arguments.

IM_3

Autocompletion: exhaustive pattern matching and pattern completion

The Scala plugin now generates an exhaustive match for sealed types with inheritors, Java Enums, and Scala Enumerations. Together with this, the autocompletion list contains an unapply(...) pattern.
Comp1
Autocompletion in Pattern matching suggests a list of typed patterns for applicable classes and interfaces.
Comp2

Semantic Highlighting support

Now, you can enable semantic highlighting for your project in Preferences/Settings | Editor | Color Scheme | Scala, and assign distinct colors to a function’s parameter, local variable, variable in a pattern-matching case clause, or variable in a sequence comprehension. Then you can scan through a function to track the variable, with no distracting action isolate one of the variables, or switch focus to another variable.
SH

Scalafmt as an alternative to the built-in formatter

The Scalafmt formatter, which used to be its own standalone plugin, is now part of the Scala plugin. It can be configured at Preferences/Settings | Editor | Code Style | Scala. Once the option is set, the reformat action will invoke scalafmt instead of IntelliJ formatter.
Unlike the IntelliJ built-in formatter, scalafmt hasn’t got a lot of Tabs with detailed options, but instead uses a standard way to pass all the settings by a .conf file. If your project contains a .scalafmt.conf file, the IDE will suggest setting scalafmt as the active formatter. But you can also have a .conf file with another name – just specify it in the “Configuration:” setting.
Sometimes scalafmt may be unable to format invalid code. If you want to see warning notifications in the IDE, check this option.
FMT
We have also added the “Reformat on compile” option (enable it in Tab “Other”). The option works for both the IntelliJ built-in and scalafmt formatters.

The release brings lots of other usability enhancements and bug-fixes in Gutter icons, ScalaDoc, and Error highlighting. We would like to say a special thanks to the guys from Wix who improved the Move Refactoring by adding the capability to move object members to another object.
Your feedback is always very welcome. Please do report any bugs you find, and share your ideas, in our issue tracker. Thanks!

Happy developing!

Comments below can no longer be edited.

11 Responses to IntelliJ Scala plugin 2018.2: advanced “Implicit” support, improved patterns autocompletion, semantic highlighting, scalafmt and more

  1. OlegYch says:

    July 25, 2018

    great improvements, thank you

  2. Eldar Nezametdinov says:

    July 26, 2018

    Well done, guys! Amazing features! I waited for this moment many years and now i’m finally happy.

  3. Alex says:

    July 26, 2018

    Where I can find default .scalafmt.conf that are you using in the latest version of the plugin?

  4. Aloisia Davi says:

    July 27, 2018

    Awesome features! Thank you 🙂

  5. AriesDevil says:

    July 31, 2018

    Thanks very.

  6. Scala-дайджест #6 (2 июля – 2 августа) – Scala News says:

    August 8, 2018

    […] IntelliJ Scala plugin 2018.2. Новая версия Scala plugin вышла с просто БОМБИЧЕСКИМИ фичами: спец хинты используемых имплисит-параметров, генерация паттерн-матчинга (для sealed types, Java Enums и Scala Enumerations), поддержка scalafmt. Детали смотрите в блоге, обновиться стоит. […]

  7. Ralph Collett says:

    August 22, 2018

    Do you have a copy of the Color Scheme in your example please?

    • Anton Yalyshev says:

      August 22, 2018

      This Color Scheme is set in the Darcula Theme. It can be chosen at [Preferences | Appearance & Behavior | Appearance]. Semantic Highlighting colors are also default.

  8. Shutao Tang says:

    November 30, 2019

    Hi, I would like to know why scala-plugin(IDEA version is2019.2) removes the functionality that tag the underline of the implicit convertion function.
    For example, for the code (1 to 10).foreach(println) to will be underlined.

    If I press ctrl + Alt + Shift + “+”, then (1 to 10).foreach(println) becomes (1 to 10).foreach(println)

    Best regards! Thanks