Skip to content

Commit 8dfb753

Browse files
July541fendor
authored andcommitted
Log fourmolu version
1 parent 0555b5d commit 8dfb753

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ library
3232
build-depends:
3333
, base >=4.12 && <5
3434
, filepath
35-
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 || ^>= 0.10 || ^>= 0.11 || ^>= 0.12
35+
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 || ^>= 0.10 || ^>= 0.11 || ^>= 0.12 || ^>= 0.13
3636
, ghc
3737
, ghc-boot-th
3838
, ghcide == 2.1.0.0

plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ import Language.LSP.Protocol.Message
4444
import Language.LSP.Protocol.Types
4545
import Language.LSP.Server hiding (defaultConfig)
4646
import Ormolu
47-
import qualified Paths_fourmolu as Fourmolu
4847
import System.Exit
4948
import System.FilePath
5049
import System.Process.Run (cwd, proc)
5150
import System.Process.Text (readCreateProcessWithExitCode)
5251
import Text.Read (readMaybe)
5352

53+
#if MIN_VERSION_fourmolu(0,12,0)
54+
import qualified Paths_fourmolu as Fourmolu
55+
#endif
56+
5457
descriptor :: Recorder (WithPriority LogEvent) -> PluginId -> PluginDescriptor IdeState
5558
descriptor recorder plId =
5659
(defaultPluginDescriptor plId)
@@ -78,7 +81,11 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
7881
(pure . Left . PluginInternalError . T.pack . show)
7982
$ runExceptT $ cliHandler fileOpts
8083
else do
81-
logWith recorder Info $ LogBuiltinVersion Fourmolu.version
84+
#if MIN_VERSION_fourmolu(0,12,0)
85+
logWith recorder Info $ LogBuiltinVersion $ Just Fourmolu.version
86+
#else
87+
logWith recorder Info $ LogBuiltinVersion Nothing
88+
#endif
8289
let format fourmoluConfig = ExceptT $
8390
bimap (PluginInternalError . T.pack . show) (InL . makeDiffTextEdit contents)
8491
#if MIN_VERSION_fourmolu(0,11,0)
@@ -139,6 +146,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
139146
{ noCabal = v >= [0, 7]
140147
}
141148
Nothing -> do
149+
logWith recorder Info $ LogExternalVersion []
142150
logWith recorder Warning $ NoVersion out
143151
pure CLIVersionInfo
144152
{ noCabal = True
@@ -167,7 +175,7 @@ data LogEvent
167175
| ConfigPath FilePath
168176
| NoConfigPath [FilePath]
169177
| StdErr Text
170-
| LogBuiltinVersion Version
178+
| LogBuiltinVersion (Maybe Version)
171179
| LogExternalVersion [Int]
172180
deriving (Show)
173181

@@ -178,8 +186,8 @@ instance Pretty LogEvent where
178186
NoConfigPath ps -> "No " <> pretty configFileName <> " found in any of:"
179187
<> line <> indent 2 (vsep (map (pretty . show) ps))
180188
StdErr t -> "Fourmolu stderr:" <> line <> indent 2 (pretty t)
181-
LogBuiltinVersion v -> "Using builtin fourmolu-" <> pretty (showVersion v)
182-
LogExternalVersion v -> "Using external fourmolu-" <> pretty (intercalate "." $ map show v)
189+
LogBuiltinVersion v -> "Using builtin fourmolu" <> pretty (maybe "" showVersion v)
190+
LogExternalVersion v -> "Using external fourmolu" <> pretty (intercalate "." $ map show v)
183191

184192
convertDynFlags :: DynFlags -> [String]
185193
convertDynFlags df =

0 commit comments

Comments
 (0)