@@ -21,12 +21,16 @@ import qualified Language.Haskell.LSP.Types.Lens as J
21
21
import Development.IDE as D
22
22
import Language.Haskell.LSP.Types
23
23
24
+ import qualified Language.Haskell.LSP.Core as LSP
25
+ import qualified Language.Haskell.LSP.VFS as VFS
26
+
24
27
-- ---------------------------------------------------------------------
25
28
26
29
descriptor :: PluginId -> PluginDescriptor
27
30
descriptor plId = (defaultPluginDescriptor plId)
28
31
{ pluginCommands = commands
29
32
, pluginCodeActionProvider = Just codeActionProvider
33
+ , pluginCompletionProvider = Just completion
30
34
}
31
35
32
36
-- ---------------------------------------------------------------------
@@ -160,3 +164,54 @@ possiblePragmas =
160
164
]
161
165
162
166
-- ---------------------------------------------------------------------
167
+
168
+ completion :: CompletionProvider
169
+ completion lspFuncs _ide complParams = do
170
+ let (TextDocumentIdentifier uri) = complParams ^. J. textDocument
171
+ position = complParams ^. J. position
172
+ putStrLn $ " Uri" ++ show uri
173
+ putStrLn $ " nor uri" ++ show (toNormalizedUri uri)
174
+ contents <- LSP. getVirtualFileFunc lspFuncs $ toNormalizedUri uri
175
+ fmap Right $ case (contents, uriToFilePath' uri) of
176
+ (Just cnts, Just _path) -> do
177
+ pfix <- VFS. getCompletionPrefix position cnts
178
+ putStrLn $ " pfix" ++ show pfix
179
+ return $ Completions $ List [r]
180
+ where
181
+ r =
182
+ CompletionItem
183
+ label
184
+ kind
185
+ tags
186
+ detail
187
+ documentation
188
+ deprecated
189
+ preselect
190
+ sortText
191
+ filterText
192
+ insertText
193
+ insertTextFormat
194
+ textEdit
195
+ additionalTextEdits
196
+ commitCharacters
197
+ command
198
+ 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 []
0 commit comments