Skip to content

Commit fe60c52

Browse files
committed
WIP: migrate to lsp-2 (does not build yet)
1 parent b00a86f commit fe60c52

File tree

10 files changed

+80
-29
lines changed

10 files changed

+80
-29
lines changed

agda-language-server.cabal

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ library
8383
, base >=4.7 && <5
8484
, bytestring
8585
, containers
86-
, lsp <2
87-
, lsp-types <2
86+
, lsp
87+
, lsp-types
8888
, mtl
8989
, network
9090
, network-simple
@@ -125,8 +125,8 @@ executable als
125125
, base >=4.7 && <5
126126
, bytestring
127127
, containers
128-
, lsp <2
129-
, lsp-types <2
128+
, lsp
129+
, lsp-types
130130
, mtl
131131
, network
132132
, network-simple
@@ -194,8 +194,8 @@ test-suite als-test
194194
, base >=4.7 && <5
195195
, bytestring
196196
, containers
197-
, lsp <2
198-
, lsp-types <2
197+
, lsp
198+
, lsp-types
199199
, mtl
200200
, network
201201
, network-simple

package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ dependencies:
5555
- aeson
5656
- bytestring
5757
- containers
58-
- lsp-types < 2
59-
- lsp < 2
58+
- lsp-types
59+
- lsp
6060
- mtl
6161
- network
6262
- network-simple

src/Agda/Parser.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import Data.Maybe (fromMaybe)
1818
import Data.Text (Text, unpack)
1919
import qualified Data.Text as Text
2020
import Language.LSP.Server (LspM)
21-
import qualified Language.LSP.Types as LSP
21+
#if MIN_VERSION_lsp(2,0,0)
22+
import qualified Language.LSP.Protocol.Types as LSP
23+
#else
24+
import qualified Language.LSP.Types as LSP
25+
#endif
2226
import Options (Config)
2327

2428
--------------------------------------------------------------------------------

src/Agda/Position.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import qualified Data.Sequence as Seq
2222
import qualified Data.Strict.Maybe as Strict
2323
import Data.Text ( Text )
2424
import qualified Data.Text as Text
25+
#if MIN_VERSION_lsp(2,0,0)
26+
import qualified Language.LSP.Protocol.Types as LSP
27+
#else
2528
import qualified Language.LSP.Types as LSP
29+
#endif
2630

2731
-- Note: LSP srclocs are 0-base
2832
-- Agda srclocs are 1-base

src/Monad.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE FlexibleContexts #-}
3+
24
module Monad where
35

46
import Agda.IR
@@ -25,7 +27,11 @@ import Data.Maybe ( isJust )
2527
import Language.LSP.Server ( MonadLsp
2628
, getConfig
2729
)
30+
#if MIN_VERSION_lsp(2,0,0)
31+
import qualified Language.LSP.Protocol.Types as LSP
32+
#else
2833
import qualified Language.LSP.Types as LSP
34+
#endif
2935
import Options
3036

3137
--------------------------------------------------------------------------------

src/Server/Handler.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ import Data.Text ( Text
5555
import qualified Data.Text as Text
5656
import Language.LSP.Server ( LspM )
5757
import qualified Language.LSP.Server as LSP
58+
#if MIN_VERSION_lsp(2,0,0)
59+
import qualified Language.LSP.Protocol.Types as LSP
60+
#else
5861
import qualified Language.LSP.Types as LSP
62+
#endif
5963
import qualified Language.LSP.VFS as VFS
6064
import Monad
6165
import Options ( Config
@@ -140,7 +144,13 @@ onHover uri pos = do
140144

141145
fromHighlightingInfo :: IR.HighlightingInfo -> LSP.SemanticTokenAbsolute
142146
fromHighlightingInfo (IR.HighlightingInfo start end aspects isTokenBased note defSrc)
143-
= LSP.SemanticTokenAbsolute 1 1 3 LSP.SttKeyword []
147+
= LSP.SemanticTokenAbsolute 1 1 3 kw []
148+
where
149+
#if MIN_VERSION_lsp_types(2,0,0)
150+
kw = LSP.SemanticTokenTypes_Keyword
151+
#else
152+
kw = LSP.SttKeyword
153+
#endif
144154

145155
-- HighlightingInfo
146156
-- Int -- starting offset

src/Switchboard.hs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE PolyKinds #-}
3+
4+
#if MIN_VERSION_lsp_types(2,0,0)
5+
{-# LANGUAGE DataKinds #-}
6+
{-# LANGUAGE TypeApplications #-}
7+
#endif
8+
19
module Switchboard (Switchboard, new, setupLanguageContextEnv, destroy) where
210

311
import Monad
@@ -9,7 +17,14 @@ import qualified Agda
917
import qualified Data.Aeson as JSON
1018
import qualified Data.Text.IO as Text
1119
import Language.LSP.Server
12-
import Language.LSP.Types hiding (TextDocumentSyncClientCapabilities (..))
20+
#if MIN_VERSION_lsp(2,0,0)
21+
import Data.Proxy (Proxy(Proxy))
22+
import Language.LSP.Protocol.Message
23+
import Language.LSP.Protocol.Types
24+
#else
25+
import Language.LSP.Types
26+
#endif
27+
hiding (TextDocumentSyncClientCapabilities (..))
1328
import Data.IORef
1429
import Options (Config)
1530

@@ -62,6 +77,13 @@ keepSendindResponse env ctxEnvIORef = forever $ do
6277
callback <- liftIO $ ResponseController.dispatch (envResponseController env)
6378

6479
let value = JSON.toJSON response
65-
sendRequest (SCustomMethod "agda") value $ \_result -> liftIO $ do
80+
sendRequest agdaCustomMethod value $ \_result -> liftIO $ do
6681
-- writeChan (envLogChan env) $ "[Response] >>>> " <> pack (show value)
6782
callback ()
83+
84+
agdaCustomMethod =
85+
#if MIN_VERSION_lsp_types(2,0,0)
86+
SMethod_CustomMethod (Proxy @"agda")
87+
#else
88+
SCustomMethod "agda"
89+
#endif

stack-9.2-Agda-2.6.4.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resolver: lts-20.26
2+
compiler: ghc-9.2.8
3+
# Allow a newer minor version of GHC than the snapshot specifies
4+
compiler-check: newer-minor
5+
6+
packages:
7+
- .
8+
9+
extra-deps:
10+
- Agda-2.6.4
11+
12+
flags:
13+
Agda:
14+
# optimise-heavily: true
15+
enable-cluster-counting: true

stack.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
resolver: lts-20.26
2-
compiler: ghc-9.2.8
1+
resolver: lts-21.22
2+
compiler: ghc-9.4.8
33
# Allow a newer minor version of GHC than the snapshot specifies
44
compiler-check: newer-minor
55

66
packages:
77
- .
88

9-
extra-deps:
10-
- Agda-2.6.4
11-
129
flags:
1310
Agda:
1411
# optimise-heavily: true

stack.yaml.lock

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33
# For more information, please see the documentation at:
44
# https://docs.haskellstack.org/en/stable/lock_files
55

6-
packages:
7-
- completed:
8-
hackage: Agda-2.6.4@sha256:298bc3b261ad034bf4ee788834a4d296aa5c2f6ea17ac4bef44e3daea53a7cd8,28443
9-
pantry-tree:
10-
sha256: 6c811b2ff8aa666ba301666e87d9234993d841dd370d47f8398379cd943e47bb
11-
size: 42645
12-
original:
13-
hackage: Agda-2.6.4
6+
packages: []
147
snapshots:
158
- completed:
16-
sha256: 5a59b2a405b3aba3c00188453be172b85893cab8ebc352b1ef58b0eae5d248a2
17-
size: 650475
18-
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/26.yaml
19-
original: lts-20.26
9+
sha256: afd5ba64ab602cabc2d3942d3d7e7dd6311bc626dcb415b901eaf576cb62f0ea
10+
size: 640060
11+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/22.yaml
12+
original: lts-21.22

0 commit comments

Comments
 (0)