Skip to content

Commit 769aa99

Browse files
committed
Delete hlintOn
1 parent ca7499c commit 769aa99

File tree

4 files changed

+17
-36
lines changed

4 files changed

+17
-36
lines changed

docs/configuration.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +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-
- Hlint (`haskell.hlintOn`, default true): whether to enable Hlint support. *Deprecated* as it is equivalent to `haskell.plugin.hlint.globalOn`
4544
- Max completions (`haskell.maxCompletions`, default 40): maximum number of completions sent to the LSP client.
4645
- 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.
4746
- Check parents (`haskell.checkParents`, default `CheckOnSaveAndClose`): when to typecheck reverse dependencies of a file; one of `NeverCheck`, `CheckOnClose`, `CheckOnSaveAndClose`, or `AlwaysCheck`.

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ data Config =
4949
Config
5050
{ checkParents :: CheckParents
5151
, checkProject :: !Bool
52-
, hlintOn :: !Bool
5352
, formattingProvider :: !T.Text
5453
, maxCompletions :: !Int
5554
, plugins :: !(Map.Map T.Text PluginConfig)
@@ -59,7 +58,6 @@ instance Default Config where
5958
def = Config
6059
{ checkParents = CheckOnSave
6160
, checkProject = True
62-
, hlintOn = True
6361
-- , formattingProvider = "brittany"
6462
, formattingProvider = "ormolu"
6563
-- , formattingProvider = "floskell"
@@ -79,7 +77,6 @@ parseConfig defValue = A.withObject "Config" $ \v -> do
7977
Just s -> flip (A.withObject "Config.settings") s $ \o -> Config
8078
<$> (o .:? "checkParents" <|> v .:? "checkParents") .!= checkParents defValue
8179
<*> (o .:? "checkProject" <|> v .:? "checkProject") .!= checkProject defValue
82-
<*> o .:? "hlintOn" .!= hlintOn defValue
8380
<*> o .:? "formattingProvider" .!= formattingProvider defValue
8481
<*> o .:? "maxCompletions" .!= maxCompletions defValue
8582
<*> o .:? "plugin" .!= plugins defValue
@@ -90,7 +87,6 @@ instance A.ToJSON Config where
9087
where
9188
r = object [ "checkParents" .= checkParents
9289
, "checkProject" .= checkProject
93-
, "hlintOn" .= hlintOn
9490
, "formattingProvider" .= formattingProvider
9591
, "maxCompletions" .= maxCompletions
9692
, "plugin" .= plugins

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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 15 additions & 28 deletions
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)

0 commit comments

Comments
 (0)