@@ -27,8 +27,9 @@ import qualified Language.LSP.Protocol.Types as LSP
2727import qualified Language.LSP.Server as LSP
2828import Monad (ServerM , askModel , catchTCError )
2929import Server.AgdaLibResolver (findAgdaLib )
30+ import Server.AgdaProjectResolver (findAgdaProject )
3031import qualified Server.Model as Model
31- import Server.Model.Monad (WithAgdaFileM , WithAgdaLibM , runWithAgdaFileT , runWithAgdaLibT )
32+ import Server.Model.Monad (WithAgdaFileM , WithAgdaProjectM , runWithAgdaFileT , runWithAgdaProjectT )
3233import qualified Server.Model.Monad as LSP
3334#if MIN_VERSION_Agda(2,7,0)
3435#else
@@ -42,7 +43,7 @@ tryTC handler = (Right <$> handler) `catchTCError` (return . Left)
4243
4344type NotificationHandlerWithAgdaLib
4445 (m :: LSP. Method LSP. ClientToServer LSP. Notification ) =
45- LSP. NormalizedUri -> LSP. TNotificationMessage m -> WithAgdaLibM ()
46+ LSP. NormalizedUri -> LSP. TNotificationMessage m -> WithAgdaProjectM ()
4647
4748notificationHandlerWithAgdaLib ::
4849 (LSP. HasTextDocument (LSP. MessageParams m ) textdoc , LSP. HasUri textdoc LSP. Uri ) =>
@@ -60,13 +61,13 @@ takeOverNotificationHandlerWithAgdaLib ::
6061takeOverNotificationHandlerWithAgdaLib notification handlerWithAgdaLib = do
6162 let uri = notification ^. LSP. params . LSP. textDocument . LSP. uri
6263 normUri = LSP. toNormalizedUri uri
63- agdaLib <- findAgdaLib normUri
64- lift $ LSP. sendNotification LSP. SMethod_WindowLogMessage $ LSP. LogMessageParams LSP. MessageType_Info $ Text. pack $ prettyShow agdaLib
64+ agdaProject <- findAgdaProject uri
65+ lift $ LSP. sendNotification LSP. SMethod_WindowLogMessage $ LSP. LogMessageParams LSP. MessageType_Info $ Text. pack $ prettyShow agdaProject
6566
66- let notificationHandler = runWithAgdaLibT agdaLib . handlerWithAgdaLib normUri
67+ let notificationHandler = runWithAgdaProjectT agdaProject . handlerWithAgdaLib normUri
6768 let handler = tryTC $ notificationHandler notification
6869
69- let onErr = \ err -> runWithAgdaLibT agdaLib $ do
70+ let onErr = \ err -> runWithAgdaProjectT agdaProject $ do
7071 message <- Text. pack . prettyShow <$> TCM. liftTCM (TCM. prettyTCM err)
7172 lift $ LSP. sendNotification LSP. SMethod_WindowShowMessage $ LSP. ShowMessageParams LSP. MessageType_Error message
7273 lift $ LSP. sendNotification LSP. SMethod_WindowLogMessage $ LSP. LogMessageParams LSP. MessageType_Error message
@@ -100,11 +101,11 @@ requestHandlerWithAgdaFile m handlerWithAgdaFile = LSP.requestHandler m $ \req r
100101 let message = " Request for unknown Agda file at URI: " <> LSP. getUri uri
101102 responder $ Left $ LSP. TResponseError (LSP. InR LSP. ErrorCodes_InvalidParams ) message Nothing
102103 Just agdaFile -> do
103- agdaLib <- findAgdaLib normUri
104+ agdaProject <- findAgdaProject uri
104105 let responderWithAgdaFile = lift . responder
105- let handler = tryTC $ runWithAgdaFileT agdaLib agdaFile $ handlerWithAgdaFile req responderWithAgdaFile
106+ let handler = tryTC $ runWithAgdaFileT agdaProject agdaFile $ handlerWithAgdaFile req responderWithAgdaFile
106107
107- let onErr = \ err -> runWithAgdaFileT agdaLib agdaFile $ do
108+ let onErr = \ err -> runWithAgdaFileT agdaProject agdaFile $ do
108109 message <- Text. pack . prettyShow <$> TCM. liftTCM (TCM. prettyTCM err)
109110 lift $ responder $ Left $ LSP. TResponseError (LSP. InL LSP. LSPErrorCodes_RequestFailed ) message Nothing
110111
0 commit comments