Skip to content

Commit 9392fb4

Browse files
committed
Minor refactor
1 parent 0d4f98e commit 9392fb4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable
4343
Just df -> liftIO $ convertDynFlags df
4444

4545
let format printerOpts =
46-
first (responseError . ("Fourmolu: " <>) . T.pack . show)
46+
first (mkError . show)
4747
<$> try @OrmoluException (makeDiffTextEdit contents <$> ormolu config fp' (T.unpack contents))
4848
where
4949
config =
5050
defaultConfig
51-
{ cfgDynOptions = fileOpts
51+
{ cfgDynOptions = map DynOption fileOpts
5252
, cfgRegion = region
5353
, cfgDebug = True
5454
, cfgPrinterOpts =
@@ -79,14 +79,15 @@ provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable
7979
where
8080
fp' = fromNormalizedFilePath fp
8181
title = "Formatting " <> T.pack (takeFileName fp')
82+
mkError = responseError . ("Fourmolu: " <>) . T.pack
8283
lspPrinterOpts = mempty{poIndentation = Just $ fromIntegral $ fo ^. tabSize}
8384
region = case typ of
8485
FormatText ->
8586
RegionIndices Nothing Nothing
8687
FormatRange (Range (Position sl _) (Position el _)) ->
8788
RegionIndices (Just $ fromIntegral $ sl + 1) (Just $ fromIntegral $ el + 1)
8889

89-
convertDynFlags :: DynFlags -> IO [DynOption]
90+
convertDynFlags :: Monad m => DynFlags -> m [String]
9091
convertDynFlags df =
9192
let pp = ["-pgmF=" <> p | not (null p)]
9293
p = sPgm_F $ Compat.settings df
@@ -95,4 +96,4 @@ convertDynFlags df =
9596
showExtension = \case
9697
Cpp -> "-XCPP"
9798
x -> "-X" ++ show x
98-
in return $ map DynOption $ pp <> pm <> ex
99+
in return $ pp <> pm <> ex

0 commit comments

Comments
 (0)