Skip to content

Commit 0c21b0d

Browse files
committed
Reformat
1 parent 9392fb4 commit 0c21b0d

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

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

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,40 @@ provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable
4141
fileOpts <- case hsc_dflags . hscEnv <$> ghc of
4242
Nothing -> return []
4343
Just df -> liftIO $ convertDynFlags df
44-
45-
let format printerOpts =
46-
first (mkError . show)
47-
<$> try @OrmoluException (makeDiffTextEdit contents <$> ormolu config fp' (T.unpack contents))
48-
where
49-
config =
50-
defaultConfig
51-
{ cfgDynOptions = map DynOption fileOpts
52-
, cfgRegion = region
53-
, cfgDebug = True
54-
, cfgPrinterOpts =
55-
fillMissingPrinterOpts
56-
(printerOpts <> lspPrinterOpts)
57-
defaultPrinterOpts
58-
}
59-
60-
liftIO (loadConfigFile fp') >>= \case
61-
ConfigLoaded file opts -> liftIO $ do
62-
putStrLn $ "Loaded Fourmolu config from: " <> file
63-
format opts
64-
ConfigNotFound searchDirs -> liftIO $ do
65-
putStrLn
66-
. unlines
67-
$ ("No " ++ show configFileName ++ " found in any of:") :
68-
map (" " ++) searchDirs
69-
format mempty
70-
ConfigParseError f (_, err) -> do
71-
sendNotification SWindowShowMessage $
72-
ShowMessageParams
73-
{ _xtype = MtError
74-
, _message = errorMessage
75-
}
76-
return . Left $ responseError errorMessage
77-
where
78-
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack err
44+
do
45+
let format printerOpts =
46+
first (mkError . show)
47+
<$> try @OrmoluException (makeDiffTextEdit contents <$> ormolu config fp' (T.unpack contents))
48+
where
49+
config =
50+
defaultConfig
51+
{ cfgDynOptions = map DynOption fileOpts
52+
, cfgRegion = region
53+
, cfgDebug = True
54+
, cfgPrinterOpts =
55+
fillMissingPrinterOpts
56+
(printerOpts <> lspPrinterOpts)
57+
defaultPrinterOpts
58+
}
59+
in liftIO (loadConfigFile fp') >>= \case
60+
ConfigLoaded file opts -> liftIO $ do
61+
putStrLn $ "Loaded Fourmolu config from: " <> file
62+
format opts
63+
ConfigNotFound searchDirs -> liftIO $ do
64+
putStrLn
65+
. unlines
66+
$ ("No " ++ show configFileName ++ " found in any of:") :
67+
map (" " ++) searchDirs
68+
format mempty
69+
ConfigParseError f (_, err) -> do
70+
sendNotification SWindowShowMessage $
71+
ShowMessageParams
72+
{ _xtype = MtError
73+
, _message = errorMessage
74+
}
75+
return . Left $ responseError errorMessage
76+
where
77+
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack err
7978
where
8079
fp' = fromNormalizedFilePath fp
8180
title = "Formatting " <> T.pack (takeFileName fp')

0 commit comments

Comments
 (0)