@@ -23,6 +23,7 @@ import Language.Haskell.LSP.Types
23
23
24
24
import qualified Language.Haskell.LSP.Core as LSP
25
25
import qualified Language.Haskell.LSP.VFS as VFS
26
+ import Development.IDE.Core.Shake (ShakeExtras (logger ))
26
27
27
28
-- ---------------------------------------------------------------------
28
29
@@ -165,20 +166,33 @@ possiblePragmas =
165
166
166
167
-- ---------------------------------------------------------------------
167
168
169
+ logStuff :: IdeState -> T. Text -> IO ()
170
+ logStuff ide = logInfo (logger (shakeExtras ide))
171
+
168
172
completion :: CompletionProvider
169
173
completion lspFuncs _ide complParams = do
170
174
let (TextDocumentIdentifier uri) = complParams ^. J. textDocument
171
175
position = complParams ^. J. position
176
+ logStuff _ide (T. pack " test ---------------------......." )
172
177
putStrLn $ " Uri" ++ show uri
173
178
putStrLn $ " nor uri" ++ show (toNormalizedUri uri)
179
+ logStuff _ide (T. pack " --------------------------------......." )
174
180
contents <- LSP. getVirtualFileFunc lspFuncs $ toNormalizedUri uri
175
181
fmap Right $ case (contents, uriToFilePath' uri) of
176
182
(Just cnts, Just _path) -> do
177
183
pfix <- VFS. getCompletionPrefix position cnts
178
- putStrLn $ " pfix" ++ show pfix
179
- return $ Completions $ List [r]
184
+ logStuff _ide (T. pack " test &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&......." )
185
+ logStuff _ide $ " pfix" <> (T. pack. show $ pfix)
186
+ logStuff _ide (T. pack " test &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&......." )
187
+ return $ result pfix
180
188
where
181
- r =
189
+ result (Just pfix)
190
+ | " {-# LANGUAGE" `T.isPrefixOf` VFS. fullLine pfix
191
+ = Completions $ List $ map buildCompletion possiblePragmas
192
+ | otherwise
193
+ = Completions $ List []
194
+ result Nothing = Completions $ List []
195
+ buildCompletion p =
182
196
CompletionItem
183
197
label
184
198
kind
@@ -196,22 +210,21 @@ completion lspFuncs _ide complParams = do
196
210
commitCharacters
197
211
command
198
212
xd
199
- label = " Example Pragma completion"
200
- kind = Nothing
201
- tags = List []
202
- detail = Nothing
203
- documentation = Nothing
204
- deprecated = Nothing
205
- preselect = Nothing
206
- sortText = Nothing
207
- filterText = Nothing
208
- insertText = Nothing
209
- insertTextFormat = Nothing
210
- textEdit = Nothing
211
- additionalTextEdits = Nothing
212
- commitCharacters = Nothing
213
- command = Nothing
214
- xd = Nothing
215
- _ -> do
216
- putStrLn $ " Need to handle this path" '
217
- return $ Completions $ List []
213
+ where
214
+ label = p
215
+ kind = Nothing
216
+ tags = List []
217
+ detail = Nothing
218
+ documentation = Nothing
219
+ deprecated = Nothing
220
+ preselect = Nothing
221
+ sortText = Nothing
222
+ filterText = Nothing
223
+ insertText = Nothing
224
+ insertTextFormat = Nothing
225
+ textEdit = Nothing
226
+ additionalTextEdits = Nothing
227
+ commitCharacters = Nothing
228
+ command = Nothing
229
+ xd = Nothing
230
+ _ -> return $ Completions $ List []
0 commit comments