Skip to content

Commit 7e36f32

Browse files
Merge branch 'master' into unhandled-exceptions
2 parents 4390a76 + 47f29da commit 7e36f32

File tree

9 files changed

+23
-126
lines changed

9 files changed

+23
-126
lines changed

docs/configuration.md

-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ This option obviously would not make sense for language servers for other langua
4141
Here is a list of the additional settings currently supported by `haskell-language-server`, along with their setting key (you may not need to know this) and default:
4242

4343
- Formatting provider (`haskell.formattingProvider`, default `ormolu`): what formatter to use; one of `floskell`, `ormolu`, `fourmolu`, `stylish-haskell`, or `brittany` (if compiled with the brittany plugin).
44-
- Format on imports (`haskell.formatOnImportOn`, default true): whether to format after adding an import.
45-
- Diagnostics on change (`haskell.diagnosticsOnChange`, default true): (currently unused).
46-
- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets. *Deprecated* as it is equivalent to `haskell.plugin.ghcide-completions.config.snippetsOn`.
47-
- Liquid Haskell (`haskell.liquidOn`, default false): whether to enable Liquid Haskell support (currently unused until the Liquid Haskell support is functional again, see <https://github.com/haskell/haskell-language-server/issues/367>).
48-
- Hlint (`haskell.hlintOn`, default true): whether to enable Hlint support. *Deprecated* as it is equivalent to `haskell.plugin.hlint.globalOn`
4944
- Max completions (`haskell.maxCompletions`, default 40): maximum number of completions sent to the LSP client.
5045
- Check project (`haskell.checkProject`, default true): whether to typecheck the entire project on load. As it is activated by default could drive to bad perfomance in large projects.
5146
- Check parents (`haskell.checkParents`, default `CheckOnSaveAndClose`): when to typecheck reverse dependencies of a file; one of `NeverCheck`, `CheckOnClose`, `CheckOnSaveAndClose`, or `AlwaysCheck`.

haskell-language-server.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ test-suite func-test
451451
Format
452452
FunctionalBadProject
453453
FunctionalCodeAction
454-
FunctionalLiquid
455454
HieBios
456455
Highlight
457456
Progress

hls-plugin-api/src/Ide/Plugin/Config.hs

+5-21
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,17 @@ data CheckParents
4747
-- will be surprises relating to config options being ignored, initially though.
4848
data Config =
4949
Config
50-
{ checkParents :: CheckParents
51-
, checkProject :: !Bool
52-
, hlintOn :: !Bool
53-
, diagnosticsOnChange :: !Bool
54-
, liquidOn :: !Bool
55-
, formatOnImportOn :: !Bool
56-
, formattingProvider :: !T.Text
57-
, maxCompletions :: !Int
58-
, plugins :: !(Map.Map T.Text PluginConfig)
50+
{ checkParents :: CheckParents
51+
, checkProject :: !Bool
52+
, formattingProvider :: !T.Text
53+
, maxCompletions :: !Int
54+
, plugins :: !(Map.Map T.Text PluginConfig)
5955
} deriving (Show,Eq)
6056

6157
instance Default Config where
6258
def = Config
6359
{ checkParents = CheckOnSave
6460
, checkProject = True
65-
, hlintOn = True
66-
, diagnosticsOnChange = True
67-
, liquidOn = False
68-
, formatOnImportOn = True
6961
-- , formattingProvider = "brittany"
7062
, formattingProvider = "ormolu"
7163
-- , formattingProvider = "floskell"
@@ -85,10 +77,6 @@ parseConfig defValue = A.withObject "Config" $ \v -> do
8577
Just s -> flip (A.withObject "Config.settings") s $ \o -> Config
8678
<$> (o .:? "checkParents" <|> v .:? "checkParents") .!= checkParents defValue
8779
<*> (o .:? "checkProject" <|> v .:? "checkProject") .!= checkProject defValue
88-
<*> o .:? "hlintOn" .!= hlintOn defValue
89-
<*> o .:? "diagnosticsOnChange" .!= diagnosticsOnChange defValue
90-
<*> o .:? "liquidOn" .!= liquidOn defValue
91-
<*> o .:? "formatOnImportOn" .!= formatOnImportOn defValue
9280
<*> o .:? "formattingProvider" .!= formattingProvider defValue
9381
<*> o .:? "maxCompletions" .!= maxCompletions defValue
9482
<*> o .:? "plugin" .!= plugins defValue
@@ -99,10 +87,6 @@ instance A.ToJSON Config where
9987
where
10088
r = object [ "checkParents" .= checkParents
10189
, "checkProject" .= checkProject
102-
, "hlintOn" .= hlintOn
103-
, "diagnosticsOnChange" .= diagnosticsOnChange
104-
, "liquidOn" .= liquidOn
105-
, "formatOnImportOn" .= formatOnImportOn
10690
, "formattingProvider" .= formattingProvider
10791
, "maxCompletions" .= maxCompletions
10892
, "plugin" .= plugins

plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ rules :: PluginId -> Rules ()
167167
rules plugin = do
168168
define $ \GetHlintDiagnostics file -> do
169169
config <- getClientConfigAction def
170-
let pluginConfig = configForPlugin config plugin
171-
let hlintOn' = hlintOn config && plcGlobalOn pluginConfig && plcDiagnosticsOn pluginConfig
172-
ideas <- if hlintOn' then getIdeas file else return (Right [])
170+
let hlintOn = pluginEnabledConfig plcDiagnosticsOn plugin config
171+
ideas <- if hlintOn then getIdeas file else return (Right [])
173172
return (diagnostics file ideas, Just ())
174173

175174
defineNoFile $ \GetHlintSettings -> do

plugins/hls-hlint-plugin/test/Main.hs

+15-28
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import Data.List (find)
1212
import qualified Data.Map as Map
1313
import Data.Maybe (fromJust, isJust)
1414
import qualified Data.Text as T
15-
import Ide.Plugin.Config (Config (..), PluginConfig (..),
16-
hlintOn)
15+
import Ide.Plugin.Config (Config (..), PluginConfig (..))
1716
import qualified Ide.Plugin.Config as Plugin
1817
import qualified Ide.Plugin.Hlint as HLint
1918
import qualified Language.LSP.Types.Lens as L
@@ -251,40 +250,24 @@ suggestionsTests =
251250
, "a = id @Int 1"
252251
]
253252

253+
254254
configTests :: TestTree
255255
configTests = testGroup "hlint plugin config" [
256256

257-
testCase "changing hlintOn configuration enables or disables hlint diagnostics" $ runHlintSession "" $ do
258-
let config = def { hlintOn = True }
259-
sendConfigurationChanged (toJSON config)
260-
261-
doc <- openDoc "Base.hs" "haskell"
262-
testHlintDiagnostics doc
263-
264-
let config' = def { hlintOn = False }
265-
sendConfigurationChanged (toJSON config')
266-
267-
diags' <- waitForDiagnosticsFrom doc
268-
269-
liftIO $ noHlintDiagnostics diags'
270-
271-
, testCase "changing hlint plugin configuration enables or disables hlint diagnostics" $ runHlintSession "" $ do
272-
let config = def { hlintOn = True }
273-
sendConfigurationChanged (toJSON config)
257+
testCase "changing hlint plugin configuration enables or disables hlint diagnostics" $ runHlintSession "" $ do
258+
enableHlint
274259

275260
doc <- openDoc "Base.hs" "haskell"
276261
testHlintDiagnostics doc
277262

278-
let config' = pluginGlobalOn config "hlint" False
279-
sendConfigurationChanged (toJSON config')
263+
disableHlint
280264

281265
diags' <- waitForDiagnosticsFrom doc
282266

283267
liftIO $ noHlintDiagnostics diags'
284268

285269
, testCase "adding hlint flags to plugin configuration removes hlint diagnostics" $ runHlintSession "" $ do
286-
let config = def { hlintOn = True }
287-
sendConfigurationChanged (toJSON config)
270+
enableHlint
288271

289272
doc <- openDoc "Base.hs" "haskell"
290273
testHlintDiagnostics doc
@@ -297,8 +280,7 @@ configTests = testGroup "hlint plugin config" [
297280
liftIO $ noHlintDiagnostics diags'
298281

299282
, testCase "adding hlint flags to plugin configuration adds hlint diagnostics" $ runHlintSession "" $ do
300-
let config = def { hlintOn = True }
301-
sendConfigurationChanged (toJSON config)
283+
enableHlint
302284

303285
doc <- openDoc "Generalise.hs" "haskell"
304286

@@ -341,14 +323,19 @@ pluginGlobalOn config pid state = config'
341323
hlintConfigWithFlags :: [T.Text] -> Config
342324
hlintConfigWithFlags flags =
343325
def
344-
{ hlintOn = True
345-
, Plugin.plugins = Map.fromList [("hlint",
346-
def { Plugin.plcConfig = unObject $ object ["flags" .= flags] }
326+
{ Plugin.plugins = Map.fromList [("hlint",
327+
def { Plugin.plcGlobalOn = True, Plugin.plcConfig = unObject $ object ["flags" .= flags] }
347328
)] }
348329
where
349330
unObject (Object obj) = obj
350331
unObject _ = undefined
351332

333+
enableHlint :: Session ()
334+
enableHlint = sendConfigurationChanged $ toJSON $ def { Plugin.plugins = Map.fromList [ ("hlint", def { Plugin.plcGlobalOn = True }) ] }
335+
336+
disableHlint :: Session ()
337+
disableHlint = sendConfigurationChanged $ toJSON $ def { Plugin.plugins = Map.fromList [ ("hlint", def { Plugin.plcGlobalOn = False }) ] }
338+
352339
-- We have two main code paths in the plugin depending on how hlint interacts with ghc:
353340
-- * One when hlint uses ghc-lib (all ghc versions but the last version supported by hlint)
354341
-- * Another one when hlint uses directly ghc (only one version, which not have to be the last version supported by ghcide)

test/functional/Diagnostic.hs

-25
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
module Diagnostic (tests) where
44

55
import Control.Lens hiding (List)
6-
import Data.Aeson (toJSON)
7-
import qualified Data.Default
8-
import Ide.Plugin.Config
96
import qualified Language.LSP.Types.Lens as LSP
107
import Test.Hls
118
import Test.Hls.Command
@@ -15,7 +12,6 @@ import Test.Hls.Command
1512
tests :: TestTree
1613
tests = testGroup "diagnostics providers" [
1714
basicTests
18-
, saveTests
1915
, warningTests
2016
]
2117

@@ -41,24 +37,3 @@ warningTests = testGroup "Warnings are warnings" [
4137
liftIO $ diag ^. LSP.severity @?= Just DsWarning
4238
]
4339

44-
saveTests :: TestTree
45-
saveTests = testGroup "only diagnostics on save" [
46-
ignoreTestBecause "diagnosticsOnChange parameter is not supported right now" $ testCase "Respects diagnosticsOnChange setting" $
47-
runSession hlsCommandExamplePlugin codeActionSupportCaps "test/testdata" $ do
48-
let config = Data.Default.def { diagnosticsOnChange = False } :: Config
49-
sendConfigurationChanged (toJSON config)
50-
doc <- openDoc "Hover.hs" "haskell"
51-
diags <- waitForDiagnosticsFrom doc
52-
53-
liftIO $ do
54-
length diags @?= 0
55-
56-
let te = TextEdit (Range (Position 0 0) (Position 0 13)) ""
57-
_ <- applyEdit doc te
58-
skipManyTill loggingNotification noDiagnostics
59-
60-
sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing)
61-
diags2 <- waitForDiagnosticsFrom doc
62-
liftIO $
63-
length diags2 @?= 1
64-
]

test/functional/FunctionalLiquid.hs

-31
This file was deleted.

test/functional/Main.hs

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Diagnostic
99
import Format
1010
import FunctionalBadProject
1111
import FunctionalCodeAction
12-
import FunctionalLiquid
1312
import HieBios
1413
import Highlight
1514
import Progress
@@ -31,7 +30,6 @@ main = defaultTestRunner
3130
, ignoreInEnv [HostOS Windows, GhcVer GHC90] "Tests gets stuck in ci" $ Format.tests
3231
, FunctionalBadProject.tests
3332
, FunctionalCodeAction.tests
34-
, FunctionalLiquid.tests
3533
, HieBios.tests
3634
, Highlight.tests
3735
, ignoreInEnv [HostOS Windows, GhcVer GHC90] "Tests gets stuck in ci" $ Progress.tests

test/functional/Progress.hs

+1-10
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ module Progress (tests) where
99

1010
import Control.Lens hiding ((.=))
1111
import Data.Aeson (Value, decode, encode, object,
12-
toJSON, (.=))
12+
(.=))
1313
import Data.List (delete)
1414
import Data.Maybe (fromJust)
1515
import Data.Text (Text, pack)
16-
import Ide.Plugin.Config
1716
import Language.LSP.Types.Capabilities
1817
import qualified Language.LSP.Types.Lens as L
1918
import System.FilePath ((</>))
@@ -52,14 +51,6 @@ tests =
5251
expectProgressReports ["Setting up testdata (for Format.hs)", "Processing", "Indexing"]
5352
_ <- sendRequest STextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing)
5453
expectProgressReports ["Formatting Format.hs"]
55-
, ignoreTestBecause "no liquid Haskell support" $
56-
testCase "liquid haskell plugin sends progress notifications" $ do
57-
runSession hlsCommand progressCaps "test/testdata" $ do
58-
doc <- openDoc "liquid/Evens.hs" "haskell"
59-
let config = def{liquidOn = True, hlintOn = False}
60-
sendConfigurationChanged (toJSON config)
61-
sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing)
62-
expectProgressReports ["Running Liquid Haskell on Evens.hs"]
6354
]
6455

6556
formatLspConfig :: Value -> Value

0 commit comments

Comments
 (0)