Skip to content

Commit 158a279

Browse files
committed
Progress reporting
Because why not?
1 parent 1e743a0 commit 158a279

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/Ide/Plugin/Ormolu.hs

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ import GhcPlugins (HscEnv (hsc_dflags))
2626
import Ide.Plugin.Formatter
2727
import Ide.PluginUtils
2828
import Ide.Types
29+
import Language.Haskell.LSP.Core (LspFuncs (withIndefiniteProgress),
30+
ProgressCancellable (Cancellable))
2931
import Language.Haskell.LSP.Types
3032
import Ormolu
33+
import System.FilePath (takeFileName)
3134
import Text.Regex.TDFA.Text ()
3235

3336
-- ---------------------------------------------------------------------
@@ -40,7 +43,7 @@ descriptor plId = (defaultPluginDescriptor plId)
4043
-- ---------------------------------------------------------------------
4144

4245
provider :: FormattingProvider IO
43-
provider _lf ideState typ contents fp _ = do
46+
provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancellable $ do
4447
let
4548
fromDyn :: DynFlags -> IO [DynOption]
4649
fromDyn df =
@@ -75,6 +78,7 @@ provider _lf ideState typ contents fp _ = do
7578
in
7679
ret <$> fmt contents (mkConf fileOpts (rangeRegion sl el))
7780
where
81+
title = T.pack $ "Formatting " <> takeFileName (fromNormalizedFilePath fp)
7882
ret :: Either OrmoluException T.Text -> Either ResponseError (List TextEdit)
7983
ret (Left err) = Left
8084
(responseError (T.pack $ "ormoluCmd: " ++ show err) )

0 commit comments

Comments
 (0)