Skip to content

Commit d07f8f8

Browse files
committed
Fix completion snippets
1 parent 50b75e4 commit d07f8f8

File tree

1 file changed

+20
-3
lines changed
  • ghcide/src/Development/IDE/Plugin/Completions

1 file changed

+20
-3
lines changed

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import Data.Ord (Down (Down))
3535
import qualified Data.Set as Set
3636
import Development.IDE.Core.Compile
3737
import Development.IDE.Core.PositionMapping
38-
import Development.IDE.GHC.Compat as GHC hiding (ppr)
38+
import Development.IDE.GHC.Compat hiding (ppr)
39+
import qualified Development.IDE.GHC.Compat as GHC
3940
import Development.IDE.GHC.Compat.Util
4041
import Development.IDE.GHC.Error
4142
import Development.IDE.GHC.Util
@@ -46,6 +47,15 @@ import Development.IDE.Spans.LocalBindings
4647
import Development.IDE.Types.Exports
4748
import Development.IDE.Types.HscEnvEq
4849
import Development.IDE.Types.Options
50+
51+
#if MIN_VERSION_ghc(9,2,0)
52+
import GHC.Plugins (Depth (AllTheWay),
53+
defaultSDocContext,
54+
mkUserStyle,
55+
neverQualify,
56+
renderWithContext,
57+
sdocStyle)
58+
#endif
4959
import Ide.PluginUtils (mkLspCommand)
5060
import Ide.Types (CommandId (..),
5161
PluginId)
@@ -254,10 +264,16 @@ mkNameCompItem doc thingParent origName provenance thingType isInfix docs !imp =
254264
(TyVarTy _) -> noParensSnippet
255265
(LitTy _) -> noParensSnippet
256266
(TyConApp _ []) -> noParensSnippet
257-
_ -> snippetText i ("(" <> showGhc t <> ")")
267+
_ -> snippetText i ("(" <> showForSnippet t <> ")")
258268
where
259-
noParensSnippet = snippetText i (showGhc t)
269+
noParensSnippet = snippetText i (showForSnippet t)
260270
snippetText i t = "${" <> T.pack (show i) <> ":" <> t <> "}"
271+
#if MIN_VERSION_ghc(9,2,0)
272+
showForSnippet x = T.pack $ renderWithContext ctxt $ GHC.ppr x -- FIXme
273+
ctxt = defaultSDocContext{sdocStyle = mkUserStyle neverQualify AllTheWay}
274+
#else
275+
showForSnippet x = showGhc x
276+
#endif
261277
getArgs :: Type -> [Type]
262278
getArgs t
263279
| isPredTy t = []
@@ -277,6 +293,7 @@ mkNameCompItem doc thingParent origName provenance thingType isInfix docs !imp =
277293
#endif
278294
| otherwise = []
279295

296+
280297
mkModCompl :: T.Text -> CompletionItem
281298
mkModCompl label =
282299
CompletionItem label (Just CiModule) Nothing Nothing

0 commit comments

Comments
 (0)