@@ -44,13 +44,16 @@ import Language.LSP.Protocol.Message
4444import Language.LSP.Protocol.Types
4545import Language.LSP.Server hiding (defaultConfig )
4646import Ormolu
47- import qualified Paths_fourmolu as Fourmolu
4847import System.Exit
4948import System.FilePath
5049import System.Process.Run (cwd , proc )
5150import System.Process.Text (readCreateProcessWithExitCode )
5251import Text.Read (readMaybe )
5352
53+ #if MIN_VERSION_fourmolu(0,12,0)
54+ import qualified Paths_fourmolu as Fourmolu
55+ #endif
56+
5457descriptor :: Recorder (WithPriority LogEvent ) -> PluginId -> PluginDescriptor IdeState
5558descriptor 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
184192convertDynFlags :: DynFlags -> [String ]
185193convertDynFlags df =
0 commit comments