@@ -24,9 +24,11 @@ import Control.Monad.Trans.Except (ExceptT (..), mapExceptT,
2424import Control.Monad.IO.Class (MonadIO (liftIO ))
2525import Control.Monad.Trans.Class (MonadTrans (lift ))
2626import Data.Bifunctor (bimap )
27+ import Data.List (intercalate )
2728import Data.Maybe (catMaybes )
2829import Data.Text (Text )
2930import qualified Data.Text as T
31+ import Data.Version (Version , showVersion )
3032import Development.IDE hiding (pluginHandlers )
3133import Development.IDE.GHC.Compat as Compat hiding (Cpp , Warning ,
3234 hang , vcat )
@@ -42,6 +44,7 @@ import Language.LSP.Protocol.Message
4244import Language.LSP.Protocol.Types
4345import Language.LSP.Server hiding (defaultConfig )
4446import Ormolu
47+ import qualified Paths_fourmolu as Fourmolu
4548import System.Exit
4649import System.FilePath
4750import System.Process.Run (cwd , proc )
@@ -75,6 +78,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
7578 (pure . Left . PluginInternalError . T. pack . show )
7679 $ runExceptT $ cliHandler fileOpts
7780 else do
81+ logWith recorder Info $ LogBuiltinVersion Fourmolu. version
7882 let format fourmoluConfig = ExceptT $
7983 bimap (PluginInternalError . T. pack . show ) (InL . makeDiffTextEdit contents)
8084#if MIN_VERSION_fourmolu(0,11,0)
@@ -129,9 +133,11 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
129133 " fourmolu" : v : _ <- pure $ T. words out
130134 traverse (readMaybe @ Int . T. unpack) $ T. splitOn " ." v
131135 case version of
132- Just v -> pure CLIVersionInfo
133- { noCabal = v >= [0 , 7 ]
134- }
136+ Just v -> do
137+ logWith recorder Info $ LogExternalVersion v
138+ pure CLIVersionInfo
139+ { noCabal = v >= [0 , 7 ]
140+ }
135141 Nothing -> do
136142 logWith recorder Warning $ NoVersion out
137143 pure CLIVersionInfo
@@ -161,6 +167,8 @@ data LogEvent
161167 | ConfigPath FilePath
162168 | NoConfigPath [FilePath ]
163169 | StdErr Text
170+ | LogBuiltinVersion Version
171+ | LogExternalVersion [Int ]
164172 deriving (Show )
165173
166174instance Pretty LogEvent where
@@ -170,6 +178,8 @@ instance Pretty LogEvent where
170178 NoConfigPath ps -> " No " <> pretty configFileName <> " found in any of:"
171179 <> line <> indent 2 (vsep (map (pretty . show ) ps))
172180 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)
173183
174184convertDynFlags :: DynFlags -> [String ]
175185convertDynFlags df =
0 commit comments