diff --git a/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala index d6562896224..807ee7ee27b 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala @@ -205,10 +205,6 @@ final class FormattingProvider( tables.dismissedNotifications.ChangeScalafmtVersion .dismiss(24, TimeUnit.HOURS) None - } else if (item == Messages.dontShowAgain) { - tables.dismissedNotifications.ChangeScalafmtVersion - .dismissForever() - None } else None } } @@ -224,16 +220,15 @@ final class FormattingProvider( if ( item == MissingScalafmtConf.createFile || item == MissingScalafmtConf.runDefaults ) { - val toWrite = - if (item == MissingScalafmtConf.createFile) - projectRoot.resolve(defaultScalafmtLocation) - else projectRoot.resolve(Directories.hiddenScalafmt) - Files - .write( - toWrite.toNIO, - initialConfig().getBytes(StandardCharsets.UTF_8), - ) - client.showMessage(MissingScalafmtConf.fixedParams(isCancelled)) + val relative = + if (item == MissingScalafmtConf.createFile) defaultScalafmtLocation + else Directories.hiddenScalafmt + val toWrite = projectRoot.resolve(relative) + Files.write( + toWrite.toNIO, + initialConfig().getBytes(StandardCharsets.UTF_8), + ) + client.showMessage(MissingScalafmtConf.fixedParams(relative)) Some(toWrite) } else if (item == Messages.notNow) { tables.dismissedNotifications.CreateScalafmtFile diff --git a/metals/src/main/scala/scala/meta/internal/metals/Messages.scala b/metals/src/main/scala/scala/meta/internal/metals/Messages.scala index 9536236c2f5..73e935dcac9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Messages.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Messages.scala @@ -17,6 +17,7 @@ import org.eclipse.lsp4j.MessageActionItem import org.eclipse.lsp4j.MessageParams import org.eclipse.lsp4j.MessageType import org.eclipse.lsp4j.ShowMessageRequestParams +import scala.meta.io.RelativePath /** * Constants for requests/dialogues via LSP window/showMessage and window/showMessageRequest. @@ -615,20 +616,20 @@ object Messages { else "" def createFile = new MessageActionItem("Create .scalafmt.conf") - def runDefaults = new MessageActionItem("Run with defaults") + def runDefaults = new MessageActionItem("Run anyway") - def fixedParams(isAgain: Boolean): MessageParams = + def fixedParams(where: RelativePath): MessageParams = new MessageParams( MessageType.Info, - s"Created .scalafmt.conf${tryAgain(isAgain)}.", + s"Created $where.", ) def isCreateScalafmtConf(params: ShowMessageRequestParams): Boolean = params.getMessage == createScalafmtConfMessage def createScalafmtConfMessage: String = - s"Unable to format since this workspace has no .scalafmt.conf file. " + - s"To fix this problem, create an empty .scalafmt.conf and try again." + s"No .scalafmt.conf file detected. " + + s"How would you like to proceed:" def params(): ShowMessageRequestParams = { val params = new ShowMessageRequestParams() @@ -639,7 +640,6 @@ object Messages { createFile, runDefaults, notNow, - dontShowAgain, ).asJava ) params