Skip to content

Commit 5685afb

Browse files
Use completionSnippetsOn flag (#1195)
* Use completionSnippetsOn flag * Enable testCase "respects lsp configuration" * Update README: haskell.completionSnippetsOn is worked now Co-authored-by: Junyoung/Clare Jang <[email protected]>
1 parent fde10fa commit 5685afb

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ Here is a list of the additional settings currently supported by `haskell-langua
295295
- Format on imports (`haskell.formatOnImportOn`, default true): whether to format after adding an import
296296
- Maximum number of problems to report (`haskell.maxNumberOfProblems`, default 100): the maximum number of problems the server will send to the client
297297
- Diagnostics on change (`haskell.diagnosticsOnChange`, default true): (currently unused)
298-
- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets (currently unused until we have snippets to provide)
298+
- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets
299299
- Liquid Haskell (`haskell.liquidOn`, default false): whether to enable Liquid Haskell support (currently unused until the Liquid Haskell support is functional again)
300300
- Hlint (`haskell.hlintOn`, default true): whether to enable Hlint support
301301

ghcide/src/Development/IDE/Plugin/Completions.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ import Development.IDE.GHC.Util
3030
import Development.IDE.LSP.Server
3131
import TcRnDriver (tcRnImportDecls)
3232
import Data.Maybe
33+
import Ide.Plugin.Config (Config(completionSnippetsOn))
34+
import Ide.PluginUtils (getClientConfig)
3335

3436
#if defined(GHC_LIB)
3537
import Development.IDE.Import.DependencyInformation
3638
#endif
3739

38-
plugin :: Plugin c
40+
plugin :: Plugin Config
3941
plugin = Plugin produceCompletions setHandlersCompletion
4042

4143
produceCompletions :: Rules ()
@@ -116,7 +118,7 @@ instance Binary NonLocalCompletions
116118

117119
-- | Generate code actions.
118120
getCompletionsLSP
119-
:: LSP.LspFuncs cofd
121+
:: LSP.LspFuncs Config
120122
-> IdeState
121123
-> CompletionParams
122124
-> IO (Either ResponseError CompletionResponseResult)
@@ -142,12 +144,13 @@ getCompletionsLSP lsp ide
142144
-> return (Completions $ List [])
143145
(Just pfix', _) -> do
144146
let clientCaps = clientCapabilities $ shakeExtras ide
145-
Completions . List <$> getCompletions ideOpts cci' parsedMod bindMap pfix' clientCaps (WithSnippets True)
147+
snippets <- WithSnippets . completionSnippetsOn <$> getClientConfig lsp
148+
Completions . List <$> getCompletions ideOpts cci' parsedMod bindMap pfix' clientCaps snippets
146149
_ -> return (Completions $ List [])
147150
_ -> return (Completions $ List [])
148151
_ -> return (Completions $ List [])
149152

150-
setHandlersCompletion :: PartialHandlers c
153+
setHandlersCompletion :: PartialHandlers Config
151154
setHandlersCompletion = PartialHandlers $ \WithMessage{..} x -> return x{
152155
LSP.completionHandler = withResponse RspCompletion getCompletionsLSP
153156
}

test/functional/Completion.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ snippetTests = testGroup "snippets" [
296296
item ^. insertTextFormat @?= Just Snippet
297297
item ^. insertText @?= Just "intersperse ${1:a} ${2:[a]}"
298298

299-
, ignoreTestBecause "ghcide does not support the completionSnippetsOn option" $
300-
testCase "respects lsp configuration" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
299+
, testCase "respects lsp configuration" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
301300
doc <- openDoc "Completion.hs" "haskell"
302301

303302
let config = object [ "haskell" .= (object ["completionSnippetsOn" .= False])]

0 commit comments

Comments
 (0)