diff --git a/README.md b/README.md index c604295be1..a7d82d9f9e 100644 --- a/README.md +++ b/README.md @@ -295,7 +295,7 @@ Here is a list of the additional settings currently supported by `haskell-langua - Format on imports (`haskell.formatOnImportOn`, default true): whether to format after adding an import - Maximum number of problems to report (`haskell.maxNumberOfProblems`, default 100): the maximum number of problems the server will send to the client - Diagnostics on change (`haskell.diagnosticsOnChange`, default true): (currently unused) -- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets (currently unused until we have snippets to provide) +- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets - Liquid Haskell (`haskell.liquidOn`, default false): whether to enable Liquid Haskell support (currently unused until the Liquid Haskell support is functional again) - Hlint (`haskell.hlintOn`, default true): whether to enable Hlint support diff --git a/ghcide/src/Development/IDE/Plugin/Completions.hs b/ghcide/src/Development/IDE/Plugin/Completions.hs index 4c3ad93f41..6325c050c1 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions.hs @@ -30,12 +30,14 @@ import Development.IDE.GHC.Util import Development.IDE.LSP.Server import TcRnDriver (tcRnImportDecls) import Data.Maybe +import Ide.Plugin.Config (Config(completionSnippetsOn)) +import Ide.PluginUtils (getClientConfig) #if defined(GHC_LIB) import Development.IDE.Import.DependencyInformation #endif -plugin :: Plugin c +plugin :: Plugin Config plugin = Plugin produceCompletions setHandlersCompletion produceCompletions :: Rules () @@ -116,7 +118,7 @@ instance Binary NonLocalCompletions -- | Generate code actions. getCompletionsLSP - :: LSP.LspFuncs cofd + :: LSP.LspFuncs Config -> IdeState -> CompletionParams -> IO (Either ResponseError CompletionResponseResult) @@ -142,12 +144,13 @@ getCompletionsLSP lsp ide -> return (Completions $ List []) (Just pfix', _) -> do let clientCaps = clientCapabilities $ shakeExtras ide - Completions . List <$> getCompletions ideOpts cci' parsedMod bindMap pfix' clientCaps (WithSnippets True) + snippets <- WithSnippets . completionSnippetsOn <$> getClientConfig lsp + Completions . List <$> getCompletions ideOpts cci' parsedMod bindMap pfix' clientCaps snippets _ -> return (Completions $ List []) _ -> return (Completions $ List []) _ -> return (Completions $ List []) -setHandlersCompletion :: PartialHandlers c +setHandlersCompletion :: PartialHandlers Config setHandlersCompletion = PartialHandlers $ \WithMessage{..} x -> return x{ LSP.completionHandler = withResponse RspCompletion getCompletionsLSP } diff --git a/test/functional/Completion.hs b/test/functional/Completion.hs index c6284aaf17..cea08a2981 100644 --- a/test/functional/Completion.hs +++ b/test/functional/Completion.hs @@ -296,8 +296,7 @@ snippetTests = testGroup "snippets" [ item ^. insertTextFormat @?= Just Snippet item ^. insertText @?= Just "intersperse ${1:a} ${2:[a]}" - , ignoreTestBecause "ghcide does not support the completionSnippetsOn option" $ - testCase "respects lsp configuration" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , testCase "respects lsp configuration" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" let config = object [ "haskell" .= (object ["completionSnippetsOn" .= False])]