@@ -1,6 +1,6 @@
11{-# LANGUAGE FlexibleInstances, IncoherentInstances, PatternGuards #-}
22
3−module Idris.IdeSlave(parseMessage, convSExp, IdeSlaveCommand(..), sexpToCommand, toSExp, SExp(..), SExpable) where
3+module Idris.IdeSlave(parseMessage, convSExp, IdeSlaveCommand(..), sexpToCommand, toSExp, SExp(..), SExpable, Opt(..)) where
44
55import Text.Printf
66import Numeric
@@ -130,6 +130,8 @@ quotedChar = try (string "\\\\" >> return '\\')
130130parseSExp :: String -> Result SExp
131131parseSExp = parseString pSExp (Directed (UTF8.fromString "(unknown)") 0 0 0 0)
132132
133+data Opt = ShowImpl | ErrContext deriving Show
134+
133135data IdeSlaveCommand = REPLCompletions String
134136 | Interpret String
135137 | TypeOf String
@@ -142,6 +144,8 @@ data IdeSlaveCommand = REPLCompletions String
142144 | LoadFile String
143145 | DocsFor String
144146 | Apropos String
147+ | GetOpts
148+ | SetOpt Opt Bool
145149 deriving Show
146150
147151sexpToCommand :: SExp -> Maybe IdeSlaveCommand
@@ -161,6 +165,10 @@ sexpToCommand (SexpList [SymbolAtom "proof-search", IntegerAtom line, StringAtom
161165 _ -> Nothing)
162166sexpToCommand (SexpList [SymbolAtom "docs-for", StringAtom name]) = Just (DocsFor name)
163167sexpToCommand (SexpList [SymbolAtom "apropos", StringAtom search]) = Just (Apropos search)
168+sexpToCommand (SymbolAtom "get-options") = Just GetOpts
169+sexpToCommand (SexpList [SymbolAtom "set-option", SymbolAtom s, BoolAtom b])
170+ | Just opt <- lookup s opts = Just (SetOpt opt b)
171+ where opts = [("show-implicits", ShowImpl), ("error-context", ErrContext)] --TODO support more
164172sexpToCommand _ = Nothing
165173
166174parseMessage :: String -> Either Err (SExp, Integer)