-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: New inlay hints options
Adds new user configuration for inlay hints, with a fallback to old settings. Also adds separate option for inlay hints inside pattern match.
- Loading branch information
Showing
22 changed files
with
552 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
metals/src/main/scala/scala/meta/internal/metals/InlayHintsOptions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package scala.meta.internal.metals | ||
|
||
case class InlayHintsOptions(options: Map[InlayHintsOption, Boolean]) | ||
extends AnyVal { | ||
def inferredType: Boolean = | ||
options.getOrElse(InlayHintsOption.InferredType, false) | ||
def implicitConversions: Boolean = | ||
options.getOrElse(InlayHintsOption.ImplicitConversions, false) | ||
def implicitArguments: Boolean = | ||
options.getOrElse(InlayHintsOption.ImplicitArguments, false) | ||
def typeParameters: Boolean = | ||
options.getOrElse(InlayHintsOption.TypeParameters, false) | ||
def hintsInPatternMatch: Boolean = | ||
options.getOrElse(InlayHintsOption.HintsInPatternMatch, false) | ||
def areSyntheticsEnabled: Boolean = options.exists(_._2) | ||
} | ||
|
||
object InlayHintsOptions { | ||
def all: InlayHintsOptions = InlayHintsOptions( | ||
Map( | ||
InlayHintsOption.InferredType -> true, | ||
InlayHintsOption.ImplicitConversions -> true, | ||
InlayHintsOption.ImplicitArguments -> true, | ||
InlayHintsOption.TypeParameters -> true, | ||
InlayHintsOption.HintsInPatternMatch -> true, | ||
) | ||
) | ||
} | ||
|
||
sealed trait InlayHintsOption | ||
object InlayHintsOption { | ||
case object InferredType extends InlayHintsOption | ||
case object ImplicitConversions extends InlayHintsOption | ||
case object ImplicitArguments extends InlayHintsOption | ||
case object TypeParameters extends InlayHintsOption | ||
case object HintsInPatternMatch extends InlayHintsOption | ||
def unapply(value: String): Option[InlayHintsOption] = value match { | ||
case "inferredTypes" => Some(InferredType) | ||
case "implicitConversions" => Some(ImplicitConversions) | ||
case "implicitArguments" => Some(ImplicitArguments) | ||
case "typeParameters" => Some(TypeParameters) | ||
case "hintsInPatternMatch" => Some(HintsInPatternMatch) | ||
case _ => None | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.