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