Skip to content

Commit 84936ab

Browse files
committed
Migrate language server initialization
1 parent 8d4529f commit 84936ab

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎app/Main.hs‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ runLanguageServer = do
2525
state <- newLSStateVar
2626
S.runServerWithHandles logger logger stdin stdout $ S.ServerDefinition
2727
{ S.defaultConfig = def
28-
, S.onConfigurationChange = \_old v -> case A.fromJSON v of
28+
, S.parseConfig = \_old v -> case A.fromJSON v of
2929
A.Error e -> Left $ T.pack e
3030
A.Success cfg -> Right (cfg :: CFG.Config)
31+
, S.configSection = "curry"
32+
-- TODO: Handle configuration changes (ideally from here, not in the didChangeConfiguration handler)
33+
-- See https://hackage.haskell.org/package/lsp-2.7.0.0/docs/Language-LSP-Server.html#t:ServerDefinition
34+
, S.onConfigChange = const $ pure ()
3135
, S.doInitialize = const . pure . Right
3236
, S.staticHandlers = handlers
3337
, S.interpretHandler = \env -> S.Iso (\lsm -> runLSM lsm state env) liftIO
3438
, S.options = S.defaultOptions
35-
{ S.textDocumentSync = Just syncOptions
36-
, S.completionTriggerCharacters = Just ['.']
37-
, S.signatureHelpTriggerCharacters = Just [' ', '(', ')']
38-
, S.executeCommandCommands = Just $ fst <$> commands
39-
, S.serverInfo = Just $ J.ServerInfo "Curry Language Server" Nothing
39+
{ S.optTextDocumentSync = Just syncOptions
40+
, S.optCompletionTriggerCharacters = Just ['.']
41+
, S.optSignatureHelpTriggerCharacters = Just [' ', '(', ')']
42+
, S.optExecuteCommandCommands = Just $ fst <$> commands
43+
, S.optServerInfo = Just $ J.ServerInfo "Curry Language Server" Nothing
4044
}
4145
}
4246
where
@@ -50,7 +54,7 @@ runLanguageServer = do
5054
logger = LogAction $ const $ return ()
5155
syncOptions = J.TextDocumentSyncOptions
5256
(Just True) -- open/close notifications
53-
(Just J.TdSyncIncremental) -- changes
57+
(Just J.TextDocumentSyncKind_Incremental) -- changes
5458
(Just False) -- will save
5559
(Just False) -- will save (wait until requests are sent to server)
5660
(Just $ J.InR $ J.SaveOptions $ Just False) -- save

‎src/Curry/LanguageServer/Handlers.hs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import Curry.LanguageServer.Handlers.Workspace.Command (executeCommandHandler)
1414
import Curry.LanguageServer.Handlers.Workspace.Notifications (didChangeConfigurationHandler)
1515
import Curry.LanguageServer.Handlers.Workspace.Symbol (workspaceSymbolHandler)
1616
import Curry.LanguageServer.Monad (LSM)
17+
import qualified Language.LSP.Protocol.Types as J
1718
import qualified Language.LSP.Server as S
1819

19-
handlers :: S.Handlers LSM
20-
handlers = mconcat
20+
handlers :: J.ClientCapabilities -> S.Handlers LSM
21+
handlers _caps = mconcat
2122
[ -- Request handlers
2223
completionHandler
2324
, executeCommandHandler

0 commit comments

Comments
 (0)