Skip to content

HLS for the new generated LSP 2 release #3621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 75 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
646c916
Add lsp packages from git till they are released
joyfulmantis May 30, 2023
009c4a0
hls-plugin-api changes for lsp* 2 packages
joyfulmantis May 31, 2023
3a17def
refactor helper functions
joyfulmantis May 31, 2023
b6b6b68
Fix a hlint issue I was responsible for creating
joyfulmantis Jun 1, 2023
9245aba
Separate the helper functions and...
joyfulmantis Jun 1, 2023
658757f
ghcide checkpoint (doesn't compile)
joyfulmantis Jun 1, 2023
082f1e6
ghcide compiles, but 40/351 tests fail
joyfulmantis Jun 3, 2023
33798d9
ghcide: Fix some inaccuracies
joyfulmantis Jun 5, 2023
74a6e34
ghcide-bench compiles
joyfulmantis Jun 5, 2023
ea10046
hls-test-utils compile
joyfulmantis Jun 5, 2023
05da0d8
alternate-number-format compiles
joyfulmantis Jun 5, 2023
9a0bff5
hls-cabal-fmt compiles
joyfulmantis Jun 5, 2023
45458fb
cabal-plugin compiles
joyfulmantis Jun 5, 2023
e2651cf
call-hierarchy compiles
joyfulmantis Jun 5, 2023
adbc9ae
change-type-signature compiles
joyfulmantis Jun 5, 2023
7f3ed6e
class-plugin compiles
joyfulmantis Jun 5, 2023
e723ed2
code-range compiles
joyfulmantis Jun 5, 2023
04b5c14
eval-plugin compiles
joyfulmantis Jun 5, 2023
5e163ca
Update helper functions
joyfulmantis Jun 5, 2023
70dd008
explicit-fixity compiles
joyfulmantis Jun 5, 2023
2030f0e
Update to the latest lsp* changes
joyfulmantis Jun 6, 2023
1c75cd6
explicit-imports compile
joyfulmantis Jun 6, 2023
cc95de4
explicit-fields compile
joyfulmantis Jun 6, 2023
b7d15ea
floskell compiles
joyfulmantis Jun 6, 2023
5e8500d
fourmolu compiles
joyfulmantis Jun 6, 2023
dfc2da8
new orphans and fixes
joyfulmantis Jun 7, 2023
4fc8fec
cabal-fmt compiles
joyfulmantis Jun 7, 2023
c7386e6
refactor-plugin compiles
joyfulmantis Jun 7, 2023
74befec
gadt-plugin compiles
joyfulmantis Jun 7, 2023
7a02858
hlint-plugin compiles
joyfulmantis Jun 7, 2023
5338a41
module-name compiles
joyfulmantis Jun 7, 2023
40afc8a
ormolu-plugin compiles
joyfulmantis Jun 7, 2023
8606cfe
pragmas-plugin compile
joyfulmantis Jun 7, 2023
a144c09
qualify-imported-names compile
joyfulmantis Jun 7, 2023
a97efe4
refine-imports compile
joyfulmantis Jun 7, 2023
34acc00
rename-plugin compiles
joyfulmantis Jun 7, 2023
c231c59
retrie-plugin compiles
joyfulmantis Jun 7, 2023
cd32951
splice-plugin compiles
joyfulmantis Jun 7, 2023
6c32020
stylish-haskell compiles
joyfulmantis Jun 7, 2023
2c3d5fd
exe compiles
joyfulmantis Jun 7, 2023
58605c9
ghc 9.0 codepath fixes
joyfulmantis Jun 8, 2023
a62937f
haddock-comments compile
joyfulmantis Jun 8, 2023
c9997cb
tactics-old compiles
joyfulmantis Jun 8, 2023
3e11e09
functional tests compile
joyfulmantis Jun 8, 2023
5d48528
Cleanup of changes
joyfulmantis Jun 9, 2023
cb5ab6a
stan-plugin compiles
joyfulmantis Jun 9, 2023
bbd2c44
cleanup
joyfulmantis Jun 9, 2023
39ceb5c
revert new-wingman changes as that's dead code
joyfulmantis Jun 9, 2023
9a361d0
Move lsp functions & instances to the lsp package
joyfulmantis Jun 9, 2023
a2920b0
Merge branch 'master' into new-lsp-release
joyfulmantis Jun 9, 2023
b244f3f
overload-record-dot compiles
joyfulmantis Jun 9, 2023
a4f2500
cleanup and implementing michaelpj's suggestions
joyfulmantis Jun 10, 2023
1aa5324
Update lsp* we track
joyfulmantis Jun 12, 2023
4e8d517
Fix bug with hover and follow upstream lsp
joyfulmantis Jun 12, 2023
4b9cbdc
stack fixes
joyfulmantis Jun 12, 2023
abd0bf8
fix stack try 2
joyfulmantis Jun 12, 2023
d201bdc
add row-types to stack extra-deps
joyfulmantis Jun 12, 2023
1a0692e
fix func test and satisfy stack build-depends
joyfulmantis Jun 12, 2023
a3e2736
More making stack happy
joyfulmantis Jun 12, 2023
26b623a
fix hls-code-range test
joyfulmantis Jun 12, 2023
88b3640
tactics-plugin test compiles
joyfulmantis Jun 12, 2023
821ff4b
Merge remote-tracking branch 'upstream/master' into new-lsp-release
joyfulmantis Jun 13, 2023
a483607
fix hls-class-plugin test
joyfulmantis Jun 13, 2023
21aedaa
Merge remote-tracking branch 'upstream/master' into new-lsp-release
joyfulmantis Jun 13, 2023
dc2ea23
fix merge mistake
joyfulmantis Jun 13, 2023
fd1284f
Merge remote-tracking branch 'upstream/master' into new-lsp-release
joyfulmantis Jun 14, 2023
7e53aae
Use official version, and flag and bench fixes
joyfulmantis Jun 14, 2023
46daa19
Fix stack, testing, and flags
joyfulmantis Jun 14, 2023
1a36431
add bytestring constrains to gchide-bench
joyfulmantis Jun 15, 2023
d8a28ee
ghcide-bench fix constraint
joyfulmantis Jun 15, 2023
017dc6b
remove constraint, instead use older exported api
joyfulmantis Jun 15, 2023
456524e
Update to lsp-types 2.0.0.1
joyfulmantis Jun 16, 2023
55a8c75
implement suggestions from michaelpj
joyfulmantis Jun 16, 2023
8cb740f
get nix builds working
joyfulmantis Jun 18, 2023
f6e8516
Merge branch 'master' into new-lsp-release
joyfulmantis Jun 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ package *

write-ghc-environment-files: never

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

constraints:
-- For GHC 9.4, older versions of entropy fail to build on Windows
Expand Down
4 changes: 4 additions & 0 deletions configuration-ghc-90.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ let

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

lsp = hself.callCabal2nix "lsp" inputs.lsp {};
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};

hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-35 {}) "-fghc-lib";

hls-hlint-plugin = hself.callCabal2nixWithOptions "hls-hlint-plugin"
Expand Down
4 changes: 4 additions & 0 deletions configuration-ghc-92.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ let

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

lsp = hself.callCabal2nix "lsp" inputs.lsp {};
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};

# Re-generate HLS drv excluding some plugins
haskell-language-server =
hself.callCabal2nixWithOptions "haskell-language-server" ./.
Expand Down
4 changes: 4 additions & 0 deletions configuration-ghc-94.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ let

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

lsp = hself.callCabal2nix "lsp" inputs.lsp {};
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};

# Re-generate HLS drv excluding some plugins
haskell-language-server =
hself.callCabal2nixWithOptions "haskell-language-server" ./.
Expand Down
4 changes: 4 additions & 0 deletions configuration-ghc-96.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ let

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

lsp = hself.callCabal2nix "lsp" inputs.lsp {};
lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {};
lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {};

# Re-generate HLS drv excluding some plugins
haskell-language-server =
hself.callCabal2nixWithOptions "haskell-language-server" ./.
Expand Down
56 changes: 28 additions & 28 deletions exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
{-# LANGUAGE OverloadedStrings #-}
module Main(main) where

import Control.Arrow ((&&&))
import Control.Monad.IO.Class (liftIO)
import Data.Function ((&))
import Data.Text (Text)
import qualified Development.IDE.Main as GhcideMain
import Development.IDE.Types.Logger (Doc, Priority (Error, Info),
WithPriority (WithPriority, priority),
cfilter, cmapWithPrio,
defaultLayoutOptions,
layoutPretty,
makeDefaultStderrRecorder,
payload, renderStrict,
withDefaultRecorder)
import qualified Development.IDE.Types.Logger as Logger
import qualified HlsPlugins as Plugins
import Ide.Arguments (Arguments (..),
GhcideArguments (..),
getArguments)
import Ide.Main (defaultMain)
import qualified Ide.Main as IdeMain
import Ide.PluginUtils (pluginDescToIdePlugins)
import Ide.Types (PluginDescriptor (pluginNotificationHandlers),
defaultPluginDescriptor,
mkPluginNotificationHandler)
import Language.LSP.Server as LSP
import Language.LSP.Types as LSP
import Prettyprinter (Pretty (pretty), vsep)
import Control.Arrow ((&&&))
import Control.Monad.IO.Class (liftIO)
import Data.Function ((&))
import Data.Text (Text)
import qualified Development.IDE.Main as GhcideMain
import Development.IDE.Types.Logger (Doc, Priority (Error, Info),
WithPriority (WithPriority, priority),
cfilter, cmapWithPrio,
defaultLayoutOptions,
layoutPretty,
makeDefaultStderrRecorder,
payload, renderStrict,
withDefaultRecorder)
import qualified Development.IDE.Types.Logger as Logger
import qualified HlsPlugins as Plugins
import Ide.Arguments (Arguments (..),
GhcideArguments (..),
getArguments)
import Ide.Main (defaultMain)
import qualified Ide.Main as IdeMain
import Ide.PluginUtils (pluginDescToIdePlugins)
import Ide.Types (PluginDescriptor (pluginNotificationHandlers),
defaultPluginDescriptor,
mkPluginNotificationHandler)
import Language.LSP.Protocol.Message as LSP
import Language.LSP.Server as LSP
import Prettyprinter (Pretty (pretty), vsep)

data Log
= LogIdeMain IdeMain.Log
Expand All @@ -53,7 +53,7 @@ main = do
-- This plugin just installs a handler for the `initialized` notification, which then
-- picks up the LSP environment and feeds it to our recorders
let lspRecorderPlugin = (defaultPluginDescriptor "LSPRecorderCallback")
{ pluginNotificationHandlers = mkPluginNotificationHandler LSP.SInitialized $ \_ _ _ _ -> do
{ pluginNotificationHandlers = mkPluginNotificationHandler LSP.SMethod_Initialized $ \_ _ _ _ -> do
env <- LSP.getLspEnv
liftIO $ (cb1 <> cb2) env
}
Expand Down
23 changes: 12 additions & 11 deletions exe/Wrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ import Development.IDE.Types.Logger (Doc, Logger (Logger),
import GHC.Stack.Types (emptyCallStack)
import Ide.Plugin.Config (Config)
import Ide.Types (IdePlugins (IdePlugins))
import Language.LSP.Protocol.Message (Method (Method_Initialize),
ResponseError,
SMethod (SMethod_Exit, SMethod_WindowShowMessageRequest),
TRequestMessage)
import Language.LSP.Protocol.Types (MessageActionItem (MessageActionItem),
MessageType (MessageType_Error),
ShowMessageRequestParams (ShowMessageRequestParams),
type (|?) (InL))
import Language.LSP.Server (LspM)
import qualified Language.LSP.Server as LSP
import Language.LSP.Types (MessageActionItem (MessageActionItem),
MessageType (MtError),
Method (Initialize),
RequestMessage,
ResponseError,
SMethod (SExit, SWindowShowMessageRequest),
ShowMessageRequestParams (ShowMessageRequestParams))

-- ---------------------------------------------------------------------

Expand Down Expand Up @@ -288,12 +289,12 @@ launchErrorLSP recorder errorMsg = do
-- Forcefully exit
let exit = void $ tryPutMVar clientMsgVar ()

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

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

Expand All @@ -314,4 +315,4 @@ launchErrorLSP recorder errorMsg = do
setup

exitHandler :: IO () -> LSP.Handlers (ErrorLSPM c)
exitHandler exit = LSP.notificationHandler SExit $ const $ liftIO exit
exitHandler exit = LSP.notificationHandler SMethod_Exit $ const $ liftIO exit
51 changes: 45 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@
flake = false;
};

# not sure if this is the correct way to get lsp* packages in
lsp = {
url = "https://hackage.haskell.org/package/lsp-2.0.0.0/lsp-2.0.0.0.tar.gz";
flake = false;
};
lsp-types = {
url = "https://hackage.haskell.org/package/lsp-types-2.0.0.1/lsp-types-2.0.0.1.tar.gz";
flake = false;
};
lsp-test = {
url = "https://hackage.haskell.org/package/lsp-test-0.15.0.0/lsp-test-0.15.0.0.tar.gz";
flake = false;
};

haskell-unix-compat = {
url = "github:jacobstanley/unix-compat/3f6bd688cb56224955e77245a2649ba99ea32fff";
flake = false;
Expand Down
5 changes: 3 additions & 2 deletions ghcide-bench/ghcide-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cabal-version: 3.0
build-type: Simple
category: Development
name: ghcide-bench
version: 2.0.0.0
version: 2.1.0.0
license: Apache-2.0
license-file: LICENSE
author: The Haskell IDE team
Expand Down Expand Up @@ -89,6 +89,7 @@ library
safe-exceptions,
shake,
text,
row-types
default-extensions:
BangPatterns
DeriveFunctor
Expand Down Expand Up @@ -118,7 +119,7 @@ test-suite test
base,
extra,
ghcide-bench,
lsp-test ^>= 0.14,
lsp-test ^>= 0.15,
tasty,
tasty-hunit >= 0.10,
tasty-rerun,
Expand Down
Loading