Skip to content

Commit df8fb16

Browse files
committed
v0.2.6.3.0 Build with and embed Agda-2.6.3
This uses CPP, so one can still build with Agda-2.6.2.2 if wanted.
1 parent fa680de commit df8fb16

22 files changed

+206
-60
lines changed

CHANGELOG.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## v0.2.6.3.0 - 2023-11-23
8+
9+
### Changed
10+
- Bundle Agda-2.6.3.
11+
- Builds with `lsp` < 1.7 on GHC 8.10 (LTS 18.28), 9.0 (LTS 19.33), and 9.2 (LTS 20.26),
12+
and with Cabal also on 9.4 and 9.6.
13+
714
## v0.2.6.2.2.1 - 2023-11-21
815

916
### Added
1017

1118
- Building with `lsp-1.6`.
12-
Builds with `lsp` < 1.7 on GHC 8.10 (LTS 18.28), 9.0 (LTS 19.33), and 9.2 (LTS 20.26)
19+
Builds with `lsp` < 1.7 on GHC 8.10 (LTS 18.28), 9.0 (LTS 19.33), and 9.2 (LTS 20.26).
1320

1421
## v0.2.6.2.2 - 2023-11-21
1522

1623
### Changed
1724

18-
- Bundle Agda-2.6.2.2
19-
- Versioning scheme: _x.a.b.c.d.y_ where _a.b.c.d_ is the 4-digit Agda version (2.6.2.2), _x_ is 0 but may be bumped for revolutionary changes to the agda-language-server, and _y_ is for patch releases
20-
- Builds with `lsp` < 1.5 on GHC 8.10 (LTS 18.28) and 9.0 (LTS 19.33)
25+
- Bundle Agda-2.6.2.2.
26+
- Versioning scheme: _x.a.b.c.d.y_ where _a.b.c.d_ is the 4-digit Agda version (2.6.2.2), _x_ is 0 but may be bumped for revolutionary changes to the agda-language-server, and _y_ is for patch releases.
27+
- Builds with `lsp` < 1.5 on GHC 8.10 (LTS 18.28) and 9.0 (LTS 19.33).
2128

2229
## v0.2.1 - 2021-10-25
2330

agda-language-server.cabal

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cabal-version: 1.12
55
-- see: https://github.com/sol/hpack
66

77
name: agda-language-server
8-
version: 0.2.6.2.2.1
8+
version: 0.2.6.3.0
99
synopsis: An implementation of language server protocal (LSP) for Agda 2.
1010
description: Please see the README on GitHub at <https://github.com/agda/agda-language-server#readme>
1111
category: Development
@@ -22,8 +22,9 @@ extra-source-files:
2222
CHANGELOG.md
2323
package.yaml
2424
stack.yaml
25-
stack-8.10.yaml
26-
stack-9.0.yaml
25+
stack-8.10-Agda-2.6.2.2.yaml
26+
stack-9.0-Agda-2.6.2.2.yaml
27+
stack-9.2-Agda-2.6.2.2.yaml
2728

2829
source-repository head
2930
type: git
@@ -66,7 +67,7 @@ library
6667
TypeOperators
6768
ghc-options: -Wincomplete-patterns -Wunused-do-bind -Wunused-foralls -Wwarnings-deprecations -Wwrong-do-bind -Wmissing-fields -Wmissing-methods -Wmissing-pattern-synonym-signatures -Wmissing-signatures -Werror=incomplete-patterns -fno-warn-orphans
6869
build-depends:
69-
Agda ==2.6.2.2
70+
Agda ==2.6.3
7071
, aeson
7172
, base >=4.7 && <5
7273
, bytestring
@@ -93,7 +94,7 @@ executable als
9394
TypeOperators
9495
ghc-options: -Wincomplete-patterns -Wunused-do-bind -Wunused-foralls -Wwarnings-deprecations -Wwrong-do-bind -Wmissing-fields -Wmissing-methods -Wmissing-pattern-synonym-signatures -Wmissing-signatures -threaded -rtsopts -with-rtsopts=-N -Werror=incomplete-patterns -fno-warn-orphans
9596
build-depends:
96-
Agda ==2.6.2.2
97+
Agda ==2.6.3
9798
, aeson
9899
, agda-language-server
99100
, base >=4.7 && <5
@@ -149,7 +150,7 @@ test-suite als-test
149150
TypeOperators
150151
ghc-options: -Wincomplete-patterns -Wunused-do-bind -Wunused-foralls -Wwarnings-deprecations -Wwrong-do-bind -Wmissing-fields -Wmissing-methods -Wmissing-pattern-synonym-signatures -Wmissing-signatures -threaded -rtsopts -with-rtsopts=-N -Werror=incomplete-patterns -fno-warn-orphans
151152
build-depends:
152-
Agda ==2.6.2.2
153+
Agda ==2.6.3
153154
, aeson
154155
, base >=4.7 && <5
155156
, bytestring

package.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: agda-language-server
2-
version: 0.2.6.2.2.1
2+
version: 0.2.6.3.0
33
github: "banacorn/agda-language-server"
44
license: MIT
55
author: "Ting-Gian LUA"
@@ -11,8 +11,9 @@ extra-source-files:
1111
- CHANGELOG.md
1212
- package.yaml
1313
- stack.yaml
14-
- stack-8.10.yaml
15-
- stack-9.0.yaml
14+
- stack-8.10-Agda-2.6.2.2.yaml
15+
- stack-9.0-Agda-2.6.2.2.yaml
16+
- stack-9.2-Agda-2.6.2.2.yaml
1617

1718
# Metadata used when publishing your package
1819
synopsis: An implementation of language server protocal (LSP) for Agda 2.
@@ -30,7 +31,7 @@ default-extensions:
3031

3132
dependencies:
3233
- base >= 4.7 && < 5
33-
- Agda == 2.6.2.2
34+
- Agda == 2.6.3
3435
- aeson
3536
- bytestring
3637
- containers

src/Agda.hs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{-# OPTIONS_GHC -Wno-missing-methods #-}
2+
3+
{-# LANGUAGE CPP #-}
24
{-# LANGUAGE DeriveGeneric #-}
35

46
module Agda
@@ -17,6 +19,9 @@ import Agda.Interaction.Base ( Command
1719
, CommandState(optionsOnReload)
1820
, IOTCM
1921
, initCommandState
22+
#if MIN_VERSION_Agda(2,6,3)
23+
, parseIOTCM
24+
#endif
2025
)
2126
import Agda.Interaction.InteractionTop
2227
( initialiseCommandQueue
@@ -52,6 +57,7 @@ import Agda.VersionCommit ( versionWithCommitInfo )
5257
import Control.Exception ( SomeException
5358
, catch
5459
)
60+
import Control.Monad
5561
import Control.Monad.Except
5662
import Control.Monad.Reader
5763
import Control.Monad.State
@@ -88,7 +94,7 @@ start = do
8894
-- keep reading command
8995
commands <- liftIO $ initialiseCommandQueue (readCommand env)
9096

91-
-- get command line options
97+
-- get command line options
9298
options <- getCommandLineOptions
9399

94100
-- start the loop
@@ -159,31 +165,37 @@ handleCommandReq (CmdReq cmd) = do
159165
provideCommand iotcm
160166
return $ CmdRes Nothing
161167

168+
#if !MIN_VERSION_Agda(2,6,3)
162169
parseIOTCM :: String -> Either String IOTCM
163170
parseIOTCM raw = case listToMaybe $ reads raw of
164171
Just (x, "" ) -> Right x
165172
Just (_, remnent) -> Left $ "not consumed: " ++ remnent
166173
_ -> Left $ "cannot read: " ++ raw
174+
#endif
167175

168176
--------------------------------------------------------------------------------
169177

170178
getCommandLineOptions
171179
:: (HasOptions m, MonadIO m) => ServerM m CommandLineOptions
172180
getCommandLineOptions = do
173-
-- command line options from ARGV
181+
-- command line options from ARGV
174182
argv <- asks (optRawAgdaOptions . envOptions)
175183
-- command line options from agda-mode
176184
config <- asks (configRawAgdaOptions . envConfig)
177-
-- concatenate both
185+
-- concatenate both
178186
let merged = argv <> config
179187

180188
result <- runExceptT $ do
181-
(bs, opts) <- ExceptT $ runOptM $ parseBackendOptions builtinBackends
182-
merged
183-
defaultOptions
189+
let p = parseBackendOptions builtinBackends merged defaultOptions
190+
#if MIN_VERSION_Agda(2,6,3)
191+
let (r, _warns) = runOptM p
192+
(bs, opts) <- ExceptT $ pure r
193+
#else
194+
(bs, opts) <- ExceptT $ runOptM p
195+
#endif
184196
return opts
185197
case result of
186-
-- something bad happened, use the default options instead
198+
-- something bad happened, use the default options instead
187199
Left _ -> commandLineOptions
188200
Right opts -> return opts
189201

src/Agda/Convert.hs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
13
module Agda.Convert where
24

35
import Render ( Block(..), Inlines, renderATop, Render(..) )
@@ -33,10 +35,11 @@ import Agda.Utils.Impossible (__IMPOSSIBLE__)
3335
import Agda.Utils.Maybe (catMaybes)
3436
import Agda.Utils.Null (empty)
3537
import Agda.Utils.Pretty hiding (render)
36-
import Agda.Utils.RangeMap ( IsBasicRangeMap(toList) )
38+
import Agda.Utils.RangeMap ( IsBasicRangeMap(toList) )
3739
import Agda.Utils.String (delimiter)
3840
import Agda.Utils.Time (CPUTime)
3941
import Agda.VersionCommit (versionWithCommitInfo)
42+
import Control.Monad
4043
import Control.Monad.State hiding (state)
4144
import qualified Data.Aeson as JSON
4245
import qualified Data.ByteString.Lazy.Char8 as BS8
@@ -130,7 +133,7 @@ fromHighlightingInfo h remove method modFile =
130133
indirect = liftIO $ writeToTempFile (BS8.unpack (JSON.encode info))
131134

132135
fromDisplayInfo :: DisplayInfo -> TCM IR.DisplayInfo
133-
fromDisplayInfo = \case
136+
fromDisplayInfo = \case
134137
Info_CompilationOk _ ws -> do
135138
-- filter
136139
let filteredWarnings = filterTCWarnings (tcWarnings ws)
@@ -255,8 +258,13 @@ fromDisplayInfo = \case
255258
"Definitions about"
256259
<+> text (List.intercalate ", " $ words names) $$ nest 2 (align 10 hitDocs)
257260
return $ IR.DisplayInfoGeneric "Search About" [Unlabeled (Render.text $ show doc) Nothing Nothing]
261+
#if MIN_VERSION_Agda(2,6,3)
262+
Info_WhyInScope (WhyInScopeData q cwd v xs ms) -> do
263+
doc <- explainWhyInScope (prettyShow q) cwd v xs ms
264+
#else
258265
Info_WhyInScope s cwd v xs ms -> do
259266
doc <- explainWhyInScope s cwd v xs ms
267+
#endif
260268
return $ IR.DisplayInfoGeneric "Scope Info" [Unlabeled (Render.text $ show doc) Nothing Nothing]
261269
Info_Context ii ctx -> do
262270
doc <- localTCState (prettyResponseContexts ii False ctx)
@@ -373,8 +381,8 @@ showInfoError (Info_HighlightingScopeCheckError ii) =
373381
return $ "Highlighting failed to scope check expression in " ++ show ii
374382

375383
explainWhyInScope ::
376-
FilePath ->
377384
String ->
385+
FilePath ->
378386
Maybe LocalVar ->
379387
[AbstractName] ->
380388
[AbstractModule] ->
@@ -577,12 +585,12 @@ renderResponseContext ii (ResponseContextEntry n x (Arg ai expr) letv nis) = wit
577585
-- raw
578586
rawExpr <- prettyATop expr
579587
let rawType = show $ align 10 [(rawAttribute ++ rawCtxName, ":" <+> rawExpr <+> parenSep extras)]
580-
-- rendered
588+
-- rendered
581589
renderedExpr <- renderATop expr
582590
let renderedType = (renderedCtxName <> renderedAttribute) Render.<+> ":" Render.<+> renderedExpr Render.<+> parenSep2 extras2
583591
-- (Render.fsep $ Render.punctuate "," extras)
584592

585-
-- result
593+
-- result
586594
let typeItem = Unlabeled renderedType (Just rawType) Nothing
587595

588596
valueItem <- case letv of

src/Agda/Parser.hs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
{-# LANGUAGE CPP #-}
2+
13
module Agda.Parser where
24

35
--------------------------------------------------------------------------------
46

57
import Agda.Syntax.Parser (parseFile, runPMIO, tokensParser)
68
import Agda.Syntax.Parser.Tokens (Token)
79
import Agda.Syntax.Position (Position' (posPos), PositionWithoutFile, Range, getRange, rEnd', rStart')
10+
#if MIN_VERSION_Agda(2,6,3)
11+
import Agda.Syntax.Position (RangeFile(RangeFile))
12+
#endif
813
import Agda.Utils.FileName (mkAbsolute)
914
import Monad ( ServerM )
1015
import Control.Monad.State
@@ -22,10 +27,22 @@ tokenAt :: LSP.Uri -> Text -> PositionWithoutFile -> ServerM (LspM Config) (Mayb
2227
tokenAt uri source position = case LSP.uriToFilePath uri of
2328
Nothing -> return Nothing
2429
Just filepath -> do
30+
let file =
31+
#if MIN_VERSION_Agda(2,6,3)
32+
RangeFile (mkAbsolute filepath) Nothing
33+
#else
34+
mkAbsolute filepath
35+
#endif
2536
(result, _warnings) <- liftIO $
2637
runPMIO $ do
2738
-- parse the file and get all tokens
28-
(tokens, _fileType) <- parseFile tokensParser (mkAbsolute filepath) (unpack source)
39+
(r, _fileType) <- parseFile tokensParser file (unpack source)
40+
let tokens =
41+
#if MIN_VERSION_Agda(2,6,3)
42+
fst r
43+
#else
44+
r
45+
#endif
2946
-- find the token at the position
3047
return $ find (pointedBy position) tokens
3148
case result of
@@ -54,4 +71,4 @@ tokenAt uri source position = case LSP.uriToFilePath uri of
5471
tokenOffsets :: Token -> Maybe (Int, Int)
5572
tokenOffsets token = do
5673
(start, end) <- startAndEnd (getRange token)
57-
return (fromIntegral (posPos start), fromIntegral (posPos end))
74+
return (fromIntegral (posPos start), fromIntegral (posPos end))

src/Agda/Position.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
13
module Agda.Position
24
( ToOffset(..)
35
, makeToOffset
@@ -31,12 +33,17 @@ import qualified Language.LSP.Types as LSP
3133
-- | LSP Range -> Agda Range
3234
toAgdaRange :: ToOffset -> Text -> LSP.Range -> Range
3335
toAgdaRange table path (LSP.Range start end) = Range
34-
(Strict.Just (AbsolutePath path))
36+
(Strict.Just $ mkRangeFile $ AbsolutePath path)
3537
(Seq.singleton interval)
3638
where
3739
interval :: IntervalWithoutFile
3840
interval = Interval (toAgdaPositionWithoutFile table start)
3941
(toAgdaPositionWithoutFile table end)
42+
#if MIN_VERSION_Agda(2,6,3)
43+
mkRangeFile path = RangeFile path Nothing
44+
#else
45+
mkRangeFile = id
46+
#endif
4047

4148
-- | LSP Position -> Agda PositionWithoutFile
4249
toAgdaPositionWithoutFile :: ToOffset -> LSP.Position -> PositionWithoutFile

src/Render/Common.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
13
module Render.Common where
24

35
import Agda.Syntax.Common
@@ -30,7 +32,11 @@ instance Render NameId where
3032

3133
-- | MetaId
3234
instance Render MetaId where
35+
#if MIN_VERSION_Agda(2,6,3)
36+
render (MetaId n m) = text $ "_" ++ show n ++ "@" ++ show m
37+
#else
3338
render (MetaId n) = text $ "_" ++ show n
39+
#endif
3440

3541
-- | Relevance
3642
instance Render Relevance where

0 commit comments

Comments
 (0)