5
5
{-# LANGUAGE NamedFieldPuns #-}
6
6
{-# LANGUAGE OverloadedLabels #-}
7
7
{-# LANGUAGE OverloadedStrings #-}
8
+ {-# LANGUAGE RecordWildCards #-}
8
9
{-# LANGUAGE TypeApplications #-}
9
10
{-# LANGUAGE TypeOperators #-}
10
11
@@ -77,20 +78,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
77
78
$ runExceptT $ cliHandler fileOpts
78
79
else do
79
80
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 {.. } <-
94
82
liftIO (loadConfigFile fp') >>= \ case
95
83
ConfigLoaded file opts -> do
96
84
logWith recorder Info $ ConfigPath file
@@ -108,7 +96,17 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
108
96
where
109
97
errorMessage = " Failed to load " <> T. pack f <> " : " <> T. pack (show err)
110
98
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))
112
110
where
113
111
fp' = fromNormalizedFilePath fp
114
112
title = " Formatting " <> T. pack (takeFileName fp')
0 commit comments