never executed always true always false
1 {-# LANGUAGE DataKinds #-}
2
3 module Conjure.LSP.LanguageServer where
4
5 import Language.LSP.Server
6 import qualified Language.LSP.Types as J
7
8 import Conjure.LSP.Handlers.File (unhandled, fileHandlers)
9 import Conjure.LSP.Handlers.Initialize (handleInitialized)
10 import Conjure.Prelude
11 import Conjure.LSP.Handlers.Hover (hoverHandler)
12 import Conjure.LSP.Handlers.DocumentSymbol (docSymbolHandler)
13 import Conjure.LSP.Handlers.SemanticTokens (semanticTokensHandler)
14 import Conjure.LSP.Handlers.Format (formatHandler)
15 import Conjure.LSP.Handlers.Suggestions (suggestionHandler)
16
17 data LSPConfig = LSPConfig {}
18
19 startServer :: LSPConfig -> IO ()
20 startServer _ = do
21 _ <- runServer $ conjureLanguageServer
22 return ()
23
24
25
26 conjureLanguageServer :: ServerDefinition ()
27 conjureLanguageServer =
28 ServerDefinition
29 { onConfigurationChange = const $ pure $ Right ()
30 , doInitialize = \env _req -> pure $ Right env
31 , staticHandlers = handlers
32 , interpretHandler = \env -> Iso (runLspT env) liftIO
33 , options = lspOptions
34 , defaultConfig = def
35 }
36
37 handlers :: Handlers (LspM ())
38 handlers =
39 mconcat $ unhandled ++
40 [ fileHandlers
41 , handleInitialized
42 , hoverHandler
43 , docSymbolHandler
44 , semanticTokensHandler
45 , formatHandler
46 , suggestionHandler
47 ]
48
49
50 syncOptions :: J.TextDocumentSyncOptions
51 syncOptions = J.TextDocumentSyncOptions
52 (Just True)
53 (Just J.TdSyncIncremental)
54 (Just False)
55 (Just False)
56 (Just $ J.InR $ J.SaveOptions $ Just False)
57
58
59 lspOptions :: Options
60 lspOptions = defaultOptions
61 { textDocumentSync = Just syncOptions
62 , executeCommandCommands = Just ["lsp-hello-command"]
63 }