@@ -828,22 +828,11 @@ getModIfaceFromDiskAndIndexRule recorder =
828
828
829
829
return (Just x)
830
830
831
- displayTHWarning :: LspT c IO ()
832
- displayTHWarning
833
- | not isWindows && not hostIsDynamic = do
834
- LSP. sendNotification SWindowShowMessage $
835
- ShowMessageParams MtInfo $ T. unwords
836
- [ " This HLS binary does not support Template Haskell."
837
- , " Follow the [instructions](" <> templateHaskellInstructions <> " )"
838
- , " to build an HLS binary with support for Template Haskell."
839
- ]
840
- | otherwise = return ()
841
-
842
- newtype DisplayTHWarning = DisplayTHWarning (IO () )
831
+ newtype DisplayTHWarning = DisplayTHWarning (IO () )
843
832
instance IsIdeGlobal DisplayTHWarning
844
833
845
- getModSummaryRule :: Recorder (WithPriority Log ) -> Rules ()
846
- getModSummaryRule recorder = do
834
+ getModSummaryRule :: LspT Config IO () -> Recorder (WithPriority Log ) -> Rules ()
835
+ getModSummaryRule displayTHWarning recorder = do
847
836
menv <- lspEnv <$> getShakeExtrasRules
848
837
forM_ menv $ \ env -> do
849
838
displayItOnce <- liftIO $ once $ LSP. runLspT env displayTHWarning
@@ -1103,9 +1092,23 @@ data RulesConfig = RulesConfig
1103
1092
checkForImportCycles :: Bool
1104
1093
-- | Disable TH for improved performance in large codebases
1105
1094
, enableTemplateHaskell :: Bool
1095
+ -- | Warning to show when TH is not supported by the current HLS binary
1096
+ , templateHaskellWarning :: LspT Config IO ()
1106
1097
}
1107
1098
1108
- instance Default RulesConfig where def = RulesConfig True True
1099
+ instance Default RulesConfig where
1100
+ def = RulesConfig True True displayTHWarning
1101
+ where
1102
+ displayTHWarning :: LspT c IO ()
1103
+ displayTHWarning
1104
+ | not isWindows && not hostIsDynamic = do
1105
+ LSP. sendNotification SWindowShowMessage $
1106
+ ShowMessageParams MtInfo $ T. unwords
1107
+ [ " This HLS binary does not support Template Haskell."
1108
+ , " Follow the [instructions](" <> templateHaskellInstructions <> " )"
1109
+ , " to build an HLS binary with support for Template Haskell."
1110
+ ]
1111
+ | otherwise = return ()
1109
1112
1110
1113
-- | A rule that wires per-file rules together
1111
1114
mainRule :: Recorder (WithPriority Log ) -> RulesConfig -> Rules ()
@@ -1123,7 +1126,7 @@ mainRule recorder RulesConfig{..} = do
1123
1126
getModIfaceFromDiskRule recorder
1124
1127
getModIfaceFromDiskAndIndexRule recorder
1125
1128
getModIfaceRule recorder
1126
- getModSummaryRule recorder
1129
+ getModSummaryRule templateHaskellWarning recorder
1127
1130
getModuleGraphRule recorder
1128
1131
knownFilesRule recorder
1129
1132
getClientSettingsRule recorder
0 commit comments