Skip to content

Commit e0c3f02

Browse files
committed
[ change ] Make Agda-2.6.4.3 build with lsp >= 2 but with dummy handlers
1 parent aaf5268 commit e0c3f02

File tree

3 files changed

+57
-12
lines changed

3 files changed

+57
-12
lines changed

src/Server.hs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,30 @@ run options = do
7474
serverDefn options =
7575
ServerDefinition
7676
{ defaultConfig = initConfig,
77+
#if MIN_VERSION_lsp_types(2,0,0)
78+
onConfigChange = \old newRaw -> (),
79+
-- case JSON.fromJSON newRaw of
80+
-- JSON.Error s -> () -- putStrLn $ pack $ "Cannot parse server configuration: " <> s
81+
-- JSON.Success new -> (),
82+
#else
7783
onConfigurationChange = \old newRaw -> case JSON.fromJSON newRaw of
7884
JSON.Error s -> Left $ pack $ "Cannot parse server configuration: " <> s
7985
JSON.Success new -> Right new,
86+
#endif
8087
doInitialize = \ctxEnv _req -> do
8188
env <- runLspT ctxEnv (createInitEnv options)
8289
switchboard <- Switchboard.new env
8390
Switchboard.setupLanguageContextEnv switchboard ctxEnv
8491
pure $ Right (ctxEnv, env),
85-
staticHandlers = handlers,
86-
interpretHandler = \(ctxEnv, env) ->
87-
Iso (runLspT ctxEnv . runServerM env) liftIO,
92+
-- staticHandlers = handlers,
93+
-- interpretHandler = \(ctxEnv, env) ->
94+
-- Iso (runLspT ctxEnv . runServerM env) liftIO,
8895
options = lspOptions
8996
}
9097

9198
lspOptions :: LSP.Options
9299
#if MIN_VERSION_lsp_types(2,0,0)
93-
lspOptions = defaultOptions { _textDocumentSync = Just syncOptions }
100+
lspOptions = defaultOptions { optTextDocumentSync = Just syncOptions }
94101
#else
95102
lspOptions = defaultOptions { textDocumentSync = Just syncOptions }
96103
#endif
@@ -122,17 +129,23 @@ handlers :: Handlers (ServerM (LspM Config))
122129
handlers = mconcat
123130
[ -- custom methods, not part of LSP
124131
requestHandler agdaCustomMethod $ \ req responder -> do
125-
let RequestMessage _ _i _ params = req
126-
response <- Agda.sendCommand params
127-
responder $ Right response
132+
#if MIN_VERSION_lsp_types(2,0,0)
133+
return ()
134+
#else
135+
let RequestMessage _ _i _ params = req
136+
response <- Agda.sendCommand params
137+
responder $ Right response
138+
#endif
128139
,
129140
-- hover provider
130141
requestHandler hoverMethod $ \ req responder -> do
131-
let
132-
RequestMessage _ _ _ (HoverParams (TextDocumentIdentifier uri) pos _workDone)
133-
= req
134-
result <- Handler.onHover uri pos
135-
responder $ Right result
142+
#if MIN_VERSION_lsp_types(2,0,0)
143+
return ()
144+
#else
145+
let RequestMessage _ _ _ (HoverParams (TextDocumentIdentifier uri) pos _workDone) = req
146+
result <- Handler.onHover uri pos
147+
responder $ Right result
148+
#endif
136149
-- -- syntax highlighting
137150
-- , requestHandler STextDocumentSemanticTokensFull $ \req responder -> do
138151
-- result <- Handler.onHighlight (req ^. (params . textDocument . uri))

stack.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ packages:
88

99
extra-deps:
1010
- Agda-2.6.4.3
11+
- lsp-2.7.0.0@sha256:2a64b40a69fd9638056ca552d5660203019473061cff1d09dccc0c94e40a275c,3834
12+
- lsp-types-2.3.0.0@sha256:ca17a686bda5dc7ff04105ca7081dce5a90bcd050c8800a13efd68b7f0901f1c,34215
13+
- mod-0.2.0.1@sha256:eeb316fef3a8c12f4e83bbeeea748e74d75fca54d4498d574ace92e464adb05a,2409
14+
- row-types-1.0.1.2@sha256:4d4c7cb95d06a32b28ba977852d52a26b4c1f695ef083a6fd874ab6d79933b64,3071
1115

1216
flags:
1317
Agda:

stack.yaml.lock

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@ packages:
1111
size: 42904
1212
original:
1313
hackage: Agda-2.6.4.3
14+
- completed:
15+
hackage: lsp-2.7.0.0@sha256:2a64b40a69fd9638056ca552d5660203019473061cff1d09dccc0c94e40a275c,3834
16+
pantry-tree:
17+
sha256: 630a5e18d7783c35a296268959c8d9348ee6dc94540047ea58146b310d8de941
18+
size: 1120
19+
original:
20+
hackage: lsp-2.7.0.0@sha256:2a64b40a69fd9638056ca552d5660203019473061cff1d09dccc0c94e40a275c,3834
21+
- completed:
22+
hackage: lsp-types-2.3.0.0@sha256:ca17a686bda5dc7ff04105ca7081dce5a90bcd050c8800a13efd68b7f0901f1c,34215
23+
pantry-tree:
24+
sha256: 0bf22e394dc804c8cee74d19a7f38021cfd48a15082b39a14753c037f2a64288
25+
size: 51996
26+
original:
27+
hackage: lsp-types-2.3.0.0@sha256:ca17a686bda5dc7ff04105ca7081dce5a90bcd050c8800a13efd68b7f0901f1c,34215
28+
- completed:
29+
hackage: mod-0.2.0.1@sha256:eeb316fef3a8c12f4e83bbeeea748e74d75fca54d4498d574ace92e464adb05a,2409
30+
pantry-tree:
31+
sha256: d469d7e415c1593f052d3ca647e4085ab759be378d25ca7d2eea0aab0083ce38
32+
size: 590
33+
original:
34+
hackage: mod-0.2.0.1@sha256:eeb316fef3a8c12f4e83bbeeea748e74d75fca54d4498d574ace92e464adb05a,2409
35+
- completed:
36+
hackage: row-types-1.0.1.2@sha256:4d4c7cb95d06a32b28ba977852d52a26b4c1f695ef083a6fd874ab6d79933b64,3071
37+
pantry-tree:
38+
sha256: 6a3617038d3970095100d14d026c396002a115700500cf3004ffb67ae5a75611
39+
size: 1060
40+
original:
41+
hackage: row-types-1.0.1.2@sha256:4d4c7cb95d06a32b28ba977852d52a26b4c1f695ef083a6fd874ab6d79933b64,3071
1442
snapshots:
1543
- completed:
1644
sha256: 5a59b2a405b3aba3c00188453be172b85893cab8ebc352b1ef58b0eae5d248a2

0 commit comments

Comments
 (0)