Skip to content

Commit 9af376e

Browse files
Inline format call
1 parent a084830 commit 9af376e

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE NamedFieldPuns #-}
66
{-# LANGUAGE OverloadedLabels #-}
77
{-# LANGUAGE OverloadedStrings #-}
8+
{-# LANGUAGE RecordWildCards #-}
89
{-# LANGUAGE TypeApplications #-}
910
{-# LANGUAGE TypeOperators #-}
1011

@@ -77,20 +78,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
7778
$ runExceptT $ cliHandler fileOpts
7879
else do
7980
logWith recorder Debug $ LogCompiledInVersion VERSION_fourmolu
80-
let format fourmoluConfig = ExceptT $
81-
bimap (PluginInternalError . T.pack . show) (InL . makeDiffTextEdit contents)
82-
<$> try @OrmoluException (ormolu config fp' (toInput contents))
83-
where
84-
printerOpts = cfgFilePrinterOpts fourmoluConfig
85-
config =
86-
defaultConfig
87-
{ cfgDynOptions = map DynOption fileOpts
88-
, cfgFixityOverrides = cfgFileFixities fourmoluConfig
89-
, cfgRegion = region
90-
, cfgDebug = False
91-
, cfgPrinterOpts = resolvePrinterOpts [lspPrinterOpts, printerOpts]
92-
}
93-
cfg <-
81+
FourmoluConfig{..} <-
9482
liftIO (loadConfigFile fp') >>= \case
9583
ConfigLoaded file opts -> do
9684
logWith recorder Info $ ConfigPath file
@@ -108,7 +96,17 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
10896
where
10997
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (show err)
11098

111-
mapExceptT liftIO $ format cfg
99+
let config =
100+
defaultConfig
101+
{ cfgDynOptions = map DynOption fileOpts
102+
, cfgFixityOverrides = cfgFileFixities
103+
, cfgRegion = region
104+
, cfgDebug = False
105+
, cfgPrinterOpts = resolvePrinterOpts [lspPrinterOpts, cfgFilePrinterOpts]
106+
}
107+
mapExceptT liftIO $ ExceptT $
108+
bimap (PluginInternalError . T.pack . show) (InL . makeDiffTextEdit contents)
109+
<$> try @OrmoluException (ormolu config fp' (toInput contents))
112110
where
113111
fp' = fromNormalizedFilePath fp
114112
title = "Formatting " <> T.pack (takeFileName fp')

0 commit comments

Comments
 (0)