@@ -1,6 +1,6 @@
1{-# LANGUAGE FlexibleInstances, IncoherentInstances, PatternGuards #-}
1{-# LANGUAGE FlexibleInstances, IncoherentInstances, PatternGuards #-}
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
5import Text.Printf
5import Text.Printf
6import Numeric
6import Numeric
@@ -130,6 +130,8 @@ quotedChar = try (string "\\\\" >> return '\\')
130parseSExp :: String -> Result SExp
130parseSExp :: String -> Result SExp
131parseSExp = parseString pSExp (Directed (UTF8.fromString "(unknown)") 0 0 0 0)
131parseSExp = parseString pSExp (Directed (UTF8.fromString "(unknown)") 0 0 0 0)
133+data Opt = ShowImpl | ErrContext deriving Show
133data IdeSlaveCommand = REPLCompletions String
135data IdeSlaveCommand = REPLCompletions String
134 | Interpret String
136 | Interpret String
135 | TypeOf String
137 | TypeOf String
@@ -142,6 +144,8 @@ data IdeSlaveCommand = REPLCompletions String
142 | LoadFile String
144 | LoadFile String
143 | DocsFor String
145 | DocsFor String
144 | Apropos String
146 | Apropos String
145 deriving Show
149 deriving Show
147sexpToCommand :: SExp -> Maybe IdeSlaveCommand
151sexpToCommand :: SExp -> Maybe IdeSlaveCommand
@@ -161,6 +165,10 @@ sexpToCommand (SexpList [SymbolAtom "proof-search", IntegerAtom line, StringAtom
161 _ -> Nothing)
165 _ -> Nothing)
162sexpToCommand (SexpList [SymbolAtom "docs-for", StringAtom name]) = Just (DocsFor name)
166sexpToCommand (SexpList [SymbolAtom "docs-for", StringAtom name]) = Just (DocsFor name)
163sexpToCommand (SexpList [SymbolAtom "apropos", StringAtom search]) = Just (Apropos search)
167sexpToCommand (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
164sexpToCommand _ = Nothing
172sexpToCommand _ = Nothing
166parseMessage :: String -> Either Err (SExp, Integer)
174parseMessage :: String -> Either Err (SExp, Integer)