@@ -286,6 +286,16 @@ ideslave orig mods
286286 do setErrContext b
287287 let msg = (IdeSlave.SymbolAtom "ok", b)
288288 runIO . putStrLn $ IdeSlave.convSExp "return" msg id
289+ Just (IdeSlave.Metavariables cols) ->
290+ do ist <- getIState
291+ let mvs = reverse $ map fst (idris_metavars ist) \\ primDefs
292+ imp <- impShow
293+ let mvarTys = map (delabTy ist) mvs
294+ let res = (IdeSlave.SymbolAtom "ok",
295+ zipWith (\ n (prems, concl) -> (n, prems, concl))
296+ (map (IdeSlave.StringAtom . show) mvs)
297+ (map (sexpGoal ist cols imp [] . getGoal) mvarTys))
298+ runIO . putStrLn $ IdeSlave.convSExp "return" res id
289299 Nothing -> do iPrintError "did not understand")
290300 (\e -> do iPrintError $ show e))
291301 (\e -> do iPrintError $ show e)
@@ -295,6 +305,27 @@ ideslave orig mods
295305 [] -> Left ("Didn't understand name '" ++ s ++ "'")
296306 [n] -> Right $ sUN n
297307 (n:ns) -> Right $ sNS (sUN n) ns
308+ getGoal :: PTerm -> ([(Name, PTerm)], PTerm)
309+ getGoal (PPi _ n t sc) = let (prems, conc) = getGoal sc
310+ in ((n, t):prems, conc)
311+ getGoal tm = ([], tm)
312+ sexpGoal :: IState -> Int -> Bool -> [Name] -> ([(Name, PTerm)], PTerm)
313+ -> ([(String, String, SpanList OutputAnnotation)],
314+ (String, SpanList OutputAnnotation))
315+ sexpGoal ist cols imp ns ([], concl) =
316+ let concl' = displaySpans . renderPretty 0.9 cols . fmap (fancifyAnnots ist) $
317+ pprintPTerm imp (zip ns (repeat False)) [] concl
318+ in ([], concl')
319+ sexpGoal ist cols imp ns ((n, t):ps, concl) =
320+ let n' = case n of
321+ NS (UN nm) ns -> str nm
322+ UN nm | ('_':'_':_) <- str nm -> "_"
323+ | otherwise -> str nm
324+ _ -> "_"
325+ (t', spans) = displaySpans . renderPretty 0.9 cols . fmap (fancifyAnnots ist) $
326+ pprintPTerm imp (zip ns (repeat False)) [] t
327+ rest = sexpGoal ist cols imp (n:ns) (ps, concl)
328+ in ((n', t', spans) : fst rest, snd rest)
298329
299330ideslaveProcess :: FilePath -> Command -> Idris ()
300331ideslaveProcess fn Help = process stdout fn Help