diff --git a/docs/configuration.md b/docs/configuration.md index 169a722475..f6f1c1f672 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -41,11 +41,6 @@ This option obviously would not make sense for language servers for other langua 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: - 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). -- Format on imports (`haskell.formatOnImportOn`, default true): whether to format after adding an import. -- Diagnostics on change (`haskell.diagnosticsOnChange`, default true): (currently unused). -- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets. *Deprecated* as it is equivalent to `haskell.plugin.ghcide-completions.config.snippetsOn`. -- Liquid Haskell (`haskell.liquidOn`, default false): whether to enable Liquid Haskell support (currently unused until the Liquid Haskell support is functional again, see ). -- Hlint (`haskell.hlintOn`, default true): whether to enable Hlint support. *Deprecated* as it is equivalent to `haskell.plugin.hlint.globalOn` - Max completions (`haskell.maxCompletions`, default 40): maximum number of completions sent to the LSP client. - 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. - Check parents (`haskell.checkParents`, default `CheckOnSaveAndClose`): when to typecheck reverse dependencies of a file; one of `NeverCheck`, `CheckOnClose`, `CheckOnSaveAndClose`, or `AlwaysCheck`. diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index def82048f4..f0c1807906 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -451,7 +451,6 @@ test-suite func-test Format FunctionalBadProject FunctionalCodeAction - FunctionalLiquid HieBios Highlight Progress diff --git a/hls-plugin-api/src/Ide/Plugin/Config.hs b/hls-plugin-api/src/Ide/Plugin/Config.hs index 6a286a5191..00dcb4b335 100644 --- a/hls-plugin-api/src/Ide/Plugin/Config.hs +++ b/hls-plugin-api/src/Ide/Plugin/Config.hs @@ -47,25 +47,17 @@ data CheckParents -- will be surprises relating to config options being ignored, initially though. data Config = Config - { checkParents :: CheckParents - , checkProject :: !Bool - , hlintOn :: !Bool - , diagnosticsOnChange :: !Bool - , liquidOn :: !Bool - , formatOnImportOn :: !Bool - , formattingProvider :: !T.Text - , maxCompletions :: !Int - , plugins :: !(Map.Map T.Text PluginConfig) + { checkParents :: CheckParents + , checkProject :: !Bool + , formattingProvider :: !T.Text + , maxCompletions :: !Int + , plugins :: !(Map.Map T.Text PluginConfig) } deriving (Show,Eq) instance Default Config where def = Config { checkParents = CheckOnSave , checkProject = True - , hlintOn = True - , diagnosticsOnChange = True - , liquidOn = False - , formatOnImportOn = True -- , formattingProvider = "brittany" , formattingProvider = "ormolu" -- , formattingProvider = "floskell" @@ -85,10 +77,6 @@ parseConfig defValue = A.withObject "Config" $ \v -> do Just s -> flip (A.withObject "Config.settings") s $ \o -> Config <$> (o .:? "checkParents" <|> v .:? "checkParents") .!= checkParents defValue <*> (o .:? "checkProject" <|> v .:? "checkProject") .!= checkProject defValue - <*> o .:? "hlintOn" .!= hlintOn defValue - <*> o .:? "diagnosticsOnChange" .!= diagnosticsOnChange defValue - <*> o .:? "liquidOn" .!= liquidOn defValue - <*> o .:? "formatOnImportOn" .!= formatOnImportOn defValue <*> o .:? "formattingProvider" .!= formattingProvider defValue <*> o .:? "maxCompletions" .!= maxCompletions defValue <*> o .:? "plugin" .!= plugins defValue @@ -99,10 +87,6 @@ instance A.ToJSON Config where where r = object [ "checkParents" .= checkParents , "checkProject" .= checkProject - , "hlintOn" .= hlintOn - , "diagnosticsOnChange" .= diagnosticsOnChange - , "liquidOn" .= liquidOn - , "formatOnImportOn" .= formatOnImportOn , "formattingProvider" .= formattingProvider , "maxCompletions" .= maxCompletions , "plugin" .= plugins diff --git a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs index 15c06e9b48..27a5846f4d 100644 --- a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs +++ b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs @@ -167,9 +167,8 @@ rules :: PluginId -> Rules () rules plugin = do define $ \GetHlintDiagnostics file -> do config <- getClientConfigAction def - let pluginConfig = configForPlugin config plugin - let hlintOn' = hlintOn config && plcGlobalOn pluginConfig && plcDiagnosticsOn pluginConfig - ideas <- if hlintOn' then getIdeas file else return (Right []) + let hlintOn = pluginEnabledConfig plcDiagnosticsOn plugin config + ideas <- if hlintOn then getIdeas file else return (Right []) return (diagnostics file ideas, Just ()) defineNoFile $ \GetHlintSettings -> do diff --git a/plugins/hls-hlint-plugin/test/Main.hs b/plugins/hls-hlint-plugin/test/Main.hs index 58aa71d4e1..acb46947e6 100644 --- a/plugins/hls-hlint-plugin/test/Main.hs +++ b/plugins/hls-hlint-plugin/test/Main.hs @@ -12,8 +12,7 @@ import Data.List (find) import qualified Data.Map as Map import Data.Maybe (fromJust, isJust) import qualified Data.Text as T -import Ide.Plugin.Config (Config (..), PluginConfig (..), - hlintOn) +import Ide.Plugin.Config (Config (..), PluginConfig (..)) import qualified Ide.Plugin.Config as Plugin import qualified Ide.Plugin.Hlint as HLint import qualified Language.LSP.Types.Lens as L @@ -251,40 +250,24 @@ suggestionsTests = , "a = id @Int 1" ] + configTests :: TestTree configTests = testGroup "hlint plugin config" [ - testCase "changing hlintOn configuration enables or disables hlint diagnostics" $ runHlintSession "" $ do - let config = def { hlintOn = True } - sendConfigurationChanged (toJSON config) - - doc <- openDoc "Base.hs" "haskell" - testHlintDiagnostics doc - - let config' = def { hlintOn = False } - sendConfigurationChanged (toJSON config') - - diags' <- waitForDiagnosticsFrom doc - - liftIO $ noHlintDiagnostics diags' - - , testCase "changing hlint plugin configuration enables or disables hlint diagnostics" $ runHlintSession "" $ do - let config = def { hlintOn = True } - sendConfigurationChanged (toJSON config) + testCase "changing hlint plugin configuration enables or disables hlint diagnostics" $ runHlintSession "" $ do + enableHlint doc <- openDoc "Base.hs" "haskell" testHlintDiagnostics doc - let config' = pluginGlobalOn config "hlint" False - sendConfigurationChanged (toJSON config') + disableHlint diags' <- waitForDiagnosticsFrom doc liftIO $ noHlintDiagnostics diags' , testCase "adding hlint flags to plugin configuration removes hlint diagnostics" $ runHlintSession "" $ do - let config = def { hlintOn = True } - sendConfigurationChanged (toJSON config) + enableHlint doc <- openDoc "Base.hs" "haskell" testHlintDiagnostics doc @@ -297,8 +280,7 @@ configTests = testGroup "hlint plugin config" [ liftIO $ noHlintDiagnostics diags' , testCase "adding hlint flags to plugin configuration adds hlint diagnostics" $ runHlintSession "" $ do - let config = def { hlintOn = True } - sendConfigurationChanged (toJSON config) + enableHlint doc <- openDoc "Generalise.hs" "haskell" @@ -341,14 +323,19 @@ pluginGlobalOn config pid state = config' hlintConfigWithFlags :: [T.Text] -> Config hlintConfigWithFlags flags = def - { hlintOn = True - , Plugin.plugins = Map.fromList [("hlint", - def { Plugin.plcConfig = unObject $ object ["flags" .= flags] } + { Plugin.plugins = Map.fromList [("hlint", + def { Plugin.plcGlobalOn = True, Plugin.plcConfig = unObject $ object ["flags" .= flags] } )] } where unObject (Object obj) = obj unObject _ = undefined +enableHlint :: Session () +enableHlint = sendConfigurationChanged $ toJSON $ def { Plugin.plugins = Map.fromList [ ("hlint", def { Plugin.plcGlobalOn = True }) ] } + +disableHlint :: Session () +disableHlint = sendConfigurationChanged $ toJSON $ def { Plugin.plugins = Map.fromList [ ("hlint", def { Plugin.plcGlobalOn = False }) ] } + -- We have two main code paths in the plugin depending on how hlint interacts with ghc: -- * One when hlint uses ghc-lib (all ghc versions but the last version supported by hlint) -- * Another one when hlint uses directly ghc (only one version, which not have to be the last version supported by ghcide) diff --git a/test/functional/Diagnostic.hs b/test/functional/Diagnostic.hs index 06d6bf5e03..bf2aab31cd 100644 --- a/test/functional/Diagnostic.hs +++ b/test/functional/Diagnostic.hs @@ -3,9 +3,6 @@ module Diagnostic (tests) where import Control.Lens hiding (List) -import Data.Aeson (toJSON) -import qualified Data.Default -import Ide.Plugin.Config import qualified Language.LSP.Types.Lens as LSP import Test.Hls import Test.Hls.Command @@ -15,7 +12,6 @@ import Test.Hls.Command tests :: TestTree tests = testGroup "diagnostics providers" [ basicTests - , saveTests , warningTests ] @@ -41,24 +37,3 @@ warningTests = testGroup "Warnings are warnings" [ liftIO $ diag ^. LSP.severity @?= Just DsWarning ] -saveTests :: TestTree -saveTests = testGroup "only diagnostics on save" [ - ignoreTestBecause "diagnosticsOnChange parameter is not supported right now" $ testCase "Respects diagnosticsOnChange setting" $ - runSession hlsCommandExamplePlugin codeActionSupportCaps "test/testdata" $ do - let config = Data.Default.def { diagnosticsOnChange = False } :: Config - sendConfigurationChanged (toJSON config) - doc <- openDoc "Hover.hs" "haskell" - diags <- waitForDiagnosticsFrom doc - - liftIO $ do - length diags @?= 0 - - let te = TextEdit (Range (Position 0 0) (Position 0 13)) "" - _ <- applyEdit doc te - skipManyTill loggingNotification noDiagnostics - - sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) - diags2 <- waitForDiagnosticsFrom doc - liftIO $ - length diags2 @?= 1 - ] diff --git a/test/functional/FunctionalLiquid.hs b/test/functional/FunctionalLiquid.hs deleted file mode 100644 index 06a489c523..0000000000 --- a/test/functional/FunctionalLiquid.hs +++ /dev/null @@ -1,31 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module FunctionalLiquid (tests) where - -import Control.Lens hiding (List) -import Data.Aeson -import Ide.Plugin.Config -import Language.LSP.Types.Lens as LSP hiding (contents) -import Test.Hls -import Test.Hls.Command - --- --------------------------------------------------------------------- - -tests :: TestTree -tests = testGroup "liquid haskell diagnostics" [ - ignoreTestBecause "no liquid haskell" - $ testCase "liquid haskell generates diagnostics" $ - runSession hlsCommand codeActionSupportCaps "test/testdata" $ do - doc <- openDoc "liquid/Evens.hs" "haskell" - - let config = def { liquidOn = True, hlintOn = False } - sendConfigurationChanged (toJSON config) - - diags <- waitForDiagnosticsFromSource doc "liquid" - d <- liftIO $ inspectDiagnostic diags ["Liquid Type Mismatch"] - liftIO $ do - length diags @?= 1 - d ^. range @?= Range (Position 8 0) (Position 8 11) - d ^. severity @?= Just DsError - d ^. code @?= Nothing - ] diff --git a/test/functional/Main.hs b/test/functional/Main.hs index 93b243bf03..93072b52ac 100644 --- a/test/functional/Main.hs +++ b/test/functional/Main.hs @@ -9,7 +9,6 @@ import Diagnostic import Format import FunctionalBadProject import FunctionalCodeAction -import FunctionalLiquid import HieBios import Highlight import Progress @@ -31,7 +30,6 @@ main = defaultTestRunner , ignoreInEnv [HostOS Windows, GhcVer GHC90] "Tests gets stuck in ci" $ Format.tests , FunctionalBadProject.tests , FunctionalCodeAction.tests - , FunctionalLiquid.tests , HieBios.tests , Highlight.tests , ignoreInEnv [HostOS Windows, GhcVer GHC90] "Tests gets stuck in ci" $ Progress.tests diff --git a/test/functional/Progress.hs b/test/functional/Progress.hs index 1f8c987cf0..344eb4a98f 100644 --- a/test/functional/Progress.hs +++ b/test/functional/Progress.hs @@ -9,11 +9,10 @@ module Progress (tests) where import Control.Lens hiding ((.=)) import Data.Aeson (Value, decode, encode, object, - toJSON, (.=)) + (.=)) import Data.List (delete) import Data.Maybe (fromJust) import Data.Text (Text, pack) -import Ide.Plugin.Config import Language.LSP.Types.Capabilities import qualified Language.LSP.Types.Lens as L import System.FilePath (()) @@ -52,14 +51,6 @@ tests = expectProgressReports ["Setting up testdata (for Format.hs)", "Processing", "Indexing"] _ <- sendRequest STextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing) expectProgressReports ["Formatting Format.hs"] - , ignoreTestBecause "no liquid Haskell support" $ - testCase "liquid haskell plugin sends progress notifications" $ do - runSession hlsCommand progressCaps "test/testdata" $ do - doc <- openDoc "liquid/Evens.hs" "haskell" - let config = def{liquidOn = True, hlintOn = False} - sendConfigurationChanged (toJSON config) - sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) - expectProgressReports ["Running Liquid Haskell on Evens.hs"] ] formatLspConfig :: Value -> Value