on master help sign in
Support :l in server to allow editing multiple files
386e2a5Edwin Brady
contribs/idriscasesplit.vim+2−1
@@ -1,5 +1,6 @@
1function IdrisReload()
1function IdrisReload()
2+ let file = expand("%")
2− let tc = system("idris --client :r")
3+ let tc = system("idris --client :l " . file)
3 if (! (tc is ""))
4 if (! (tc is ""))
4 echo tc
5 echo tc
5 endif
6 endif
src/Idris/REPL.hs+22−18
@@ -113,35 +113,39 @@ startServer orig stvar fn_in = do tid <- runIO $ forkOS serverLoop
113 serverLoop = withSocketsDo $
113 serverLoop = withSocketsDo $
114 do sock <- listenOn $ PortNumber 4294
114 do sock <- listenOn $ PortNumber 4294
115 i <- readMVar stvar
115 i <- readMVar stvar
116− loop i sock
116+ loop fn i sock
117
117
118 fn = case fn_in of
118 fn = case fn_in of
119 (f:_) -> f
119 (f:_) -> f
120 _ -> ""
120 _ -> ""
121
121
122+ loop fn ist sock
122− loop ist sock = do (h,host,_) <- accept sock
123+ = do (h,host,_) <- accept sock
123− if (host == "localhost" ||
124+ if (host == "localhost" ||
124− host == "127.0.0.1") then do
125+ host == "127.0.0.1")
126+ then do
125− cmd <- hGetLine h
127+ cmd <- hGetLine h
126− takeMVar stvar
128+ takeMVar stvar
127− ist' <- processNetCmd stvar orig ist h fn cmd
129+ (ist', fn) <- processNetCmd stvar orig ist h fn cmd
128− putMVar stvar ist'
130+ putMVar stvar ist'
129− hClose h
131+ hClose h
130− loop ist' sock
132+ loop fn ist' sock
131− else hClose h
133+ else hClose h
132
134
133processNetCmd :: MVar IState ->
135processNetCmd :: MVar IState ->
134− IState -> IState -> Handle -> FilePath -> String -> IO IState
136+ IState -> IState -> Handle -> FilePath -> String ->
137+ IO (IState, FilePath)
135processNetCmd stvar orig i h fn cmd
138processNetCmd stvar orig i h fn cmd
136 = do res <- case parseCmd i "(net)" cmd of
139 = do res <- case parseCmd i "(net)" cmd of
137 Failure err -> return (Left (Msg " invalid command"))
140 Failure err -> return (Left (Msg " invalid command"))
138 Success c -> runErrorT $ evalStateT (processNet fn c) i
141 Success c -> runErrorT $ evalStateT (processNet fn c) i
139 case res of
142 case res of
140− Right ist -> return ist
143+ Right x -> return x
141 Left err -> do hPutStrLn h (show err)
144 Left err -> do hPutStrLn h (show err)
142− return i
145+ return (i, fn)
143 where
146 where
144− processNet fn Reload =
147+ processNet fn Reload = processNet fn (Load fn)
148+ processNet fn (Load f) =
145 do let ist = orig { idris_options = idris_options i
149 do let ist = orig { idris_options = idris_options i
146 , idris_colourTheme = idris_colourTheme i
150 , idris_colourTheme = idris_colourTheme i
147 , idris_colourRepl = False
151 , idris_colourRepl = False
@@ -151,12 +155,12 @@ processNetCmd stvar orig i h fn cmd
151 setOutH h
155 setOutH h
152 setQuiet True
156 setQuiet True
153 setVerbose False
157 setVerbose False
154− mods <- loadInputs h [fn]
158+ mods <- loadInputs h [f]
155 ist <- getIState
159 ist <- getIState
156− return ist
160+ return (ist, f)
157 processNet fn c = do process h fn c
161 processNet fn c = do process h fn c
158 ist <- getIState
162 ist <- getIState
159− return ist
163+ return (ist, fn)
160
164
161-- | Run a command on the server on localhost
165-- | Run a command on the server on localhost
162runClient :: String -> IO ()
166runClient :: String -> IO ()