@@ -28,6 +28,10 @@ import qualified GHC.LanguageExtensions.Type as GHC
2828import Development.IDE.Types.Options
2929import Development.IDE.Types.Location
3030
31+#if MIN_GHC_API_VERSION(8,6,0)
32+import DynamicLoading (initializePlugins)
33+#endif
34+
3135import GHC hiding (parseModule, typecheckModule)
3236import qualified Parser
3337import Lexer
@@ -95,11 +99,23 @@ typecheckModule (IdeDefer defer) packageState deps pm =
9599 runGhcEnv packageState $
96100 catchSrcErrors "typecheck" $ do
97101 setupEnv deps
102+ let modSummary = pm_mod_summary pm
103+ modSummary' <- initPlugins modSummary
98104 (warnings, tcm) <- withWarnings "typecheck" $ \tweak ->
99− GHC.typecheckModule $ demoteIfDefer pm{pm_mod_summary = tweak $ pm_mod_summary pm}
105+ GHC.typecheckModule $ demoteIfDefer pm{pm_mod_summary = tweak modSummary'}
100106 tcm2 <- mkTcModuleResult tcm
101107 return (map unDefer warnings, tcm2)
102108
109+initPlugins :: GhcMonad m => ModSummary -> m ModSummary
110+initPlugins modSummary = do
111+#if MIN_GHC_API_VERSION(8,6,0)
112+ session <- getSession
113+ dflags <- liftIO $ initializePlugins session (ms_hspp_opts modSummary)
114+ return modSummary{ms_hspp_opts = dflags}
115+#else
116+ return modSummary
117+#endif
118+
103119-- | Compile a single type-checked module to a 'CoreModule' value, or
104120-- provide errors.
105121compileModule