Skip to content

Disable hole fit suggestions when running Wingman #1873

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 19 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
11 changes: 11 additions & 0 deletions plugins/hls-tactics-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ fill hole" code action, *et voila!*
[hls]: https://github.com/haskell/haskell-language-server/releases


## Usage

When enabled, Wingman for Haskell will remove HLS support for hole-fit code
actions. These code actions are provided by GHC and make typechecking extremely
slow in the presence of typed holes. Because Wingman relies so heavily on typed
holes, these features are in great tension.

The solution: we just remove the hole-fit actions. If you'd prefer to use these
actions, you can get them back by compiling HLS without the Wingman plugin.


## Editor Configuration

### Enabling Jump to Hole
Expand Down
9 changes: 8 additions & 1 deletion plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ staticPlugin :: DynFlagsModifications
staticPlugin = mempty
{ dynFlagsModifyGlobal =
\df -> allowEmptyCaseButWithWarning
$ flip gopt_unset Opt_SortBySubsumHoleFits
$ df
{ refLevelHoleFits = Just 0
, maxRefHoleFits = Just 0
, maxValidHoleFits = Just 0
#if __GLASGOW_HASKELL__ >= 808
, staticPlugins = staticPlugins df <> [metaprogrammingPlugin]
#endif
}
#if __GLASGOW_HASKELL__ >= 808
{ staticPlugins = staticPlugins df <> [metaprogrammingPlugin] }
, dynFlagsModifyParser = enableQuasiQuotes
#endif
}
Expand Down
15 changes: 15 additions & 0 deletions test/functional/FunctionalCodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Control.Monad
import Data.Aeson
import qualified Data.HashMap.Strict as HM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import qualified Data.Text as T
import Ide.Plugin.Config
Expand Down Expand Up @@ -397,10 +398,12 @@ redundantImportTests = testGroup "redundant import code actions" [
]
]


typedHoleTests :: TestTree
typedHoleTests = testGroup "typed hole code actions" [
testCase "works" $
runSession hlsCommand fullCaps "test/testdata" $ do
disableWingman
doc <- openDoc "TypedHoles.hs" "haskell"
_ <- waitForDiagnosticsFromSource doc "typecheck"
cas <- getAllCodeActions doc
Expand All @@ -421,6 +424,7 @@ typedHoleTests = testGroup "typed hole code actions" [

, testCase "shows more suggestions" $
runSession hlsCommand fullCaps "test/testdata" $ do
disableWingman
doc <- openDoc "TypedHoles2.hs" "haskell"
_ <- waitForDiagnosticsFromSource doc "typecheck"
cas <- getAllCodeActions doc
Expand Down Expand Up @@ -522,6 +526,17 @@ unusedTermTests = testGroup "unused term code actions" [
all (Just CodeActionRefactorInline ==) kinds @? "All CodeActionRefactorInline"
]

disableWingman :: Session ()
disableWingman =
sendConfigurationChanged $ def
{ plugins = M.fromList [ ("tactics", def { plcGlobalOn = False }) ]
}


sendConfigurationChanged :: Config -> Session ()
sendConfigurationChanged config =
sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config))

noLiteralCaps :: C.ClientCapabilities
noLiteralCaps = def { C._textDocument = Just textDocumentCaps }
where
Expand Down