Skip to content

Commit a918c02

Browse files
authored
HLS for the new generated LSP 2 release (#3621)
1 parent 6ae970e commit a918c02

File tree

194 files changed

+2782
-2597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+2782
-2597
lines changed

cabal.project

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ package *
5656

5757
write-ghc-environment-files: never
5858

59-
index-state: 2023-05-13T12:00:00Z
59+
index-state: 2023-06-17T12:00:00Z
6060

6161
constraints:
6262
-- For GHC 9.4, older versions of entropy fail to build on Windows

configuration-ghc-90.nix

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ let
2424

2525
ghc-lib-parser = hself.callCabal2nix "ghc-lib-parser" inputs.ghc-lib-parser-94 {};
2626

27+
lsp = hself.callCabal2nix "lsp" inputs.lsp {};
28+
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
29+
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};
30+
2731
hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-35 {}) "-fghc-lib";
2832

2933
hls-hlint-plugin = hself.callCabal2nixWithOptions "hls-hlint-plugin"

configuration-ghc-92.nix

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ let
4141

4242
implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.haskell-implicit-hie-cradle { };
4343

44+
lsp = hself.callCabal2nix "lsp" inputs.lsp {};
45+
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
46+
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};
47+
4448
# Re-generate HLS drv excluding some plugins
4549
haskell-language-server =
4650
hself.callCabal2nixWithOptions "haskell-language-server" ./.

configuration-ghc-94.nix

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ let
1717

1818
stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib";
1919

20+
lsp = hself.callCabal2nix "lsp" inputs.lsp {};
21+
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
22+
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};
23+
2024
# Re-generate HLS drv excluding some plugins
2125
haskell-language-server =
2226
hself.callCabal2nixWithOptions "haskell-language-server" ./.

configuration-ghc-96.nix

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ let
5454

5555
stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib";
5656

57+
lsp = hself.callCabal2nix "lsp" inputs.lsp {};
58+
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
59+
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};
60+
5761
# Re-generate HLS drv excluding some plugins
5862
haskell-language-server =
5963
hself.callCabal2nixWithOptions "haskell-language-server" ./.

exe/Main.hs

+28-28
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
{-# LANGUAGE OverloadedStrings #-}
55
module Main(main) where
66

7-
import Control.Arrow ((&&&))
8-
import Control.Monad.IO.Class (liftIO)
9-
import Data.Function ((&))
10-
import Data.Text (Text)
11-
import qualified Development.IDE.Main as GhcideMain
12-
import Development.IDE.Types.Logger (Doc, Priority (Error, Info),
13-
WithPriority (WithPriority, priority),
14-
cfilter, cmapWithPrio,
15-
defaultLayoutOptions,
16-
layoutPretty,
17-
makeDefaultStderrRecorder,
18-
payload, renderStrict,
19-
withDefaultRecorder)
20-
import qualified Development.IDE.Types.Logger as Logger
21-
import qualified HlsPlugins as Plugins
22-
import Ide.Arguments (Arguments (..),
23-
GhcideArguments (..),
24-
getArguments)
25-
import Ide.Main (defaultMain)
26-
import qualified Ide.Main as IdeMain
27-
import Ide.PluginUtils (pluginDescToIdePlugins)
28-
import Ide.Types (PluginDescriptor (pluginNotificationHandlers),
29-
defaultPluginDescriptor,
30-
mkPluginNotificationHandler)
31-
import Language.LSP.Server as LSP
32-
import Language.LSP.Types as LSP
33-
import Prettyprinter (Pretty (pretty), vsep)
7+
import Control.Arrow ((&&&))
8+
import Control.Monad.IO.Class (liftIO)
9+
import Data.Function ((&))
10+
import Data.Text (Text)
11+
import qualified Development.IDE.Main as GhcideMain
12+
import Development.IDE.Types.Logger (Doc, Priority (Error, Info),
13+
WithPriority (WithPriority, priority),
14+
cfilter, cmapWithPrio,
15+
defaultLayoutOptions,
16+
layoutPretty,
17+
makeDefaultStderrRecorder,
18+
payload, renderStrict,
19+
withDefaultRecorder)
20+
import qualified Development.IDE.Types.Logger as Logger
21+
import qualified HlsPlugins as Plugins
22+
import Ide.Arguments (Arguments (..),
23+
GhcideArguments (..),
24+
getArguments)
25+
import Ide.Main (defaultMain)
26+
import qualified Ide.Main as IdeMain
27+
import Ide.PluginUtils (pluginDescToIdePlugins)
28+
import Ide.Types (PluginDescriptor (pluginNotificationHandlers),
29+
defaultPluginDescriptor,
30+
mkPluginNotificationHandler)
31+
import Language.LSP.Protocol.Message as LSP
32+
import Language.LSP.Server as LSP
33+
import Prettyprinter (Pretty (pretty), vsep)
3434

3535
data Log
3636
= LogIdeMain IdeMain.Log
@@ -53,7 +53,7 @@ main = do
5353
-- This plugin just installs a handler for the `initialized` notification, which then
5454
-- picks up the LSP environment and feeds it to our recorders
5555
let lspRecorderPlugin = (defaultPluginDescriptor "LSPRecorderCallback")
56-
{ pluginNotificationHandlers = mkPluginNotificationHandler LSP.SInitialized $ \_ _ _ _ -> do
56+
{ pluginNotificationHandlers = mkPluginNotificationHandler LSP.SMethod_Initialized $ \_ _ _ _ -> do
5757
env <- LSP.getLspEnv
5858
liftIO $ (cb1 <> cb2) env
5959
}

exe/Wrapper.hs

+12-11
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ import Development.IDE.Types.Logger (Doc, Logger (Logger),
5555
import GHC.Stack.Types (emptyCallStack)
5656
import Ide.Plugin.Config (Config)
5757
import Ide.Types (IdePlugins (IdePlugins))
58+
import Language.LSP.Protocol.Message (Method (Method_Initialize),
59+
ResponseError,
60+
SMethod (SMethod_Exit, SMethod_WindowShowMessageRequest),
61+
TRequestMessage)
62+
import Language.LSP.Protocol.Types (MessageActionItem (MessageActionItem),
63+
MessageType (MessageType_Error),
64+
ShowMessageRequestParams (ShowMessageRequestParams),
65+
type (|?) (InL))
5866
import Language.LSP.Server (LspM)
5967
import qualified Language.LSP.Server as LSP
60-
import Language.LSP.Types (MessageActionItem (MessageActionItem),
61-
MessageType (MtError),
62-
Method (Initialize),
63-
RequestMessage,
64-
ResponseError,
65-
SMethod (SExit, SWindowShowMessageRequest),
66-
ShowMessageRequestParams (ShowMessageRequestParams))
6768

6869
-- ---------------------------------------------------------------------
6970

@@ -288,12 +289,12 @@ launchErrorLSP recorder errorMsg = do
288289
-- Forcefully exit
289290
let exit = void $ tryPutMVar clientMsgVar ()
290291

291-
let doInitialize :: LSP.LanguageContextEnv Config -> RequestMessage Initialize -> IO (Either ResponseError (LSP.LanguageContextEnv Config, ()))
292+
let doInitialize :: LSP.LanguageContextEnv Config -> TRequestMessage Method_Initialize -> IO (Either ResponseError (LSP.LanguageContextEnv Config, ()))
292293
doInitialize env _ = do
293294

294295
let restartTitle = "Try to restart"
295-
void $ LSP.runLspT env $ LSP.sendRequest SWindowShowMessageRequest (ShowMessageRequestParams MtError errorMsg (Just [MessageActionItem restartTitle])) $ \case
296-
Right (Just (MessageActionItem title))
296+
void $ LSP.runLspT env $ LSP.sendRequest SMethod_WindowShowMessageRequest (ShowMessageRequestParams MessageType_Error errorMsg (Just [MessageActionItem restartTitle])) $ \case
297+
Right (InL (MessageActionItem title))
297298
| title == restartTitle -> liftIO exit
298299
_ -> pure ()
299300

@@ -314,4 +315,4 @@ launchErrorLSP recorder errorMsg = do
314315
setup
315316

316317
exitHandler :: IO () -> LSP.Handlers (ErrorLSPM c)
317-
exitHandler exit = LSP.notificationHandler SExit $ const $ liftIO exit
318+
exitHandler exit = LSP.notificationHandler SMethod_Exit $ const $ liftIO exit

flake.lock

+45-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+14
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@
4141
flake = false;
4242
};
4343

44+
# not sure if this is the correct way to get lsp* packages in
45+
lsp = {
46+
url = "https://hackage.haskell.org/package/lsp-2.0.0.0/lsp-2.0.0.0.tar.gz";
47+
flake = false;
48+
};
49+
lsp-types = {
50+
url = "https://hackage.haskell.org/package/lsp-types-2.0.0.1/lsp-types-2.0.0.1.tar.gz";
51+
flake = false;
52+
};
53+
lsp-test = {
54+
url = "https://hackage.haskell.org/package/lsp-test-0.15.0.0/lsp-test-0.15.0.0.tar.gz";
55+
flake = false;
56+
};
57+
4458
haskell-unix-compat = {
4559
url = "github:jacobstanley/unix-compat/3f6bd688cb56224955e77245a2649ba99ea32fff";
4660
flake = false;

ghcide-bench/ghcide-bench.cabal

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cabal-version: 3.0
22
build-type: Simple
33
category: Development
44
name: ghcide-bench
5-
version: 2.0.0.0
5+
version: 2.1.0.0
66
license: Apache-2.0
77
license-file: LICENSE
88
author: The Haskell IDE team
@@ -89,6 +89,7 @@ library
8989
safe-exceptions,
9090
shake,
9191
text,
92+
row-types
9293
default-extensions:
9394
BangPatterns
9495
DeriveFunctor
@@ -118,7 +119,7 @@ test-suite test
118119
base,
119120
extra,
120121
ghcide-bench,
121-
lsp-test ^>= 0.14,
122+
lsp-test ^>= 0.15,
122123
tasty,
123124
tasty-hunit >= 0.10,
124125
tasty-rerun,

0 commit comments

Comments
 (0)