@@ -18,14 +18,29 @@ import qualified Data.Aeson as JSON
1818import Data.Text ( pack )
1919import GHC.IO.IOMode ( IOMode (ReadWriteMode ) )
2020import Language.LSP.Server hiding ( Options )
21- import Language.LSP.Types hiding ( Options (.. )
21+ #if MIN_VERSION_lsp(2,0,0)
22+ import Language.LSP.Protocol.Message ( pattern RequestMessage
23+ , SMethod ( SMethod_CustomMethod , SMethod_TextDocumentHover )
24+ )
25+ import Language.LSP.Protocol.Types ( TextDocumentSyncOptions (.. )
26+ , TextDocumentSyncKind ( TextDocumentSyncKind_Incremental )
27+ , ServerCapabilities (_textDocumentSync )
28+ , SaveOptions ( SaveOptions )
29+ , pattern TextDocumentIdentifier
30+ , pattern HoverParams
31+ , pattern InR
32+ )
33+ #else
34+ import Language.LSP.Types
35+ hiding ( Options (.. )
2236 , TextDocumentSyncClientCapabilities (.. )
2337 )
38+ #endif
2439import Monad
2540import qualified Network.Simple.TCP as TCP
2641import Network.Socket ( socketToHandle )
2742import qualified Switchboard
28- import Switchboard ( Switchboard )
43+ import Switchboard ( Switchboard , agdaCustomMethod )
2944
3045import qualified Server.Handler as Handler
3146
@@ -73,7 +88,11 @@ run options = do
7388 }
7489
7590 lspOptions :: LSP. Options
91+ #if MIN_VERSION_lsp_types(2,0,0)
92+ lspOptions = defaultOptions { _textDocumentSync = Just syncOptions }
93+ #else
7694 lspOptions = defaultOptions { textDocumentSync = Just syncOptions }
95+ #endif
7796
7897 -- these `TextDocumentSyncOptions` are essential for receiving notifications from the client
7998 syncOptions :: TextDocumentSyncOptions
@@ -85,7 +104,11 @@ run options = do
85104 }
86105
87106 changeOptions :: TextDocumentSyncKind
107+ #if MIN_VERSION_lsp_types(2,0,0)
108+ changeOptions = TextDocumentSyncKind_Incremental
109+ #else
88110 changeOptions = TdSyncIncremental
111+ #endif
89112
90113 -- includes the document content on save, so that we don't have to read it from the disk
91114 saveOptions :: SaveOptions
@@ -95,13 +118,13 @@ run options = do
95118handlers :: Handlers (ServerM (LspM Config ))
96119handlers = mconcat
97120 [ -- custom methods, not part of LSP
98- requestHandler ( SCustomMethod " agda " ) $ \ req responder -> do
121+ requestHandler agdaCustomMethod $ \ req responder -> do
99122 let RequestMessage _ _i _ params = req
100123 response <- Agda. sendCommand params
101124 responder $ Right response
102125 ,
103126 -- hover provider
104- requestHandler STextDocumentHover $ \ req responder -> do
127+ requestHandler hoverMethod $ \ req responder -> do
105128 let
106129 RequestMessage _ _ _ (HoverParams (TextDocumentIdentifier uri) pos _workDone)
107130 = req
@@ -112,3 +135,9 @@ handlers = mconcat
112135 -- result <- Handler.onHighlight (req ^. (params . textDocument . uri))
113136 -- responder result
114137 ]
138+ where
139+ #if MIN_VERSION_lsp_types(2,0,0)
140+ hoverMethod = SMethod_TextDocumentHover
141+ #else
142+ hoverMethod = STextDocumentHover
143+ #endif
0 commit comments