@@ -46,6 +46,8 @@ import StaticLS.HieView.Query qualified as HieView.Query
4646import StaticLS.Hir qualified as Hir
4747import StaticLS.IDE.AllExtensions (allExtensions )
4848import StaticLS.IDE.CodeActions.AutoImport qualified as IDE.CodeActions.AutoImport
49+ import StaticLS.IDE.CompletionItemKind (CompletionItemKind )
50+ import StaticLS.IDE.CompletionItemKind qualified as CompletionItemKind
4951import StaticLS.IDE.Monad
5052import StaticLS.IDE.Utils qualified as IDE.Utils
5153import StaticLS.Logger (logInfo )
@@ -120,7 +122,7 @@ getFileCompletions cx = do
120122 hieView <- getHieView path
121123 let symbols = fmap HieView.Name. toText $ HieView.Query. fileSymbolsList hieView
122124 let symbolsNubbed = nubOrd symbols
123- let completions = fmap textCompletion symbolsNubbed
125+ let completions = fmap ( textCompletion CompletionItemKind. File ) symbolsNubbed
124126 pure completions
125127 fileCompletions <- pure $ Maybe. fromMaybe [] fileCompletions
126128 pure fileCompletions
@@ -132,12 +134,12 @@ getUnqualifiedImportCompletions cx = do
132134 let imports = prog. imports
133135 let unqualifiedImports = filter (\ imp -> not imp. qualified) imports
134136 completions <- getCompletionsForMods $ (. mod . text) <$> unqualifiedImports
135- pure $ fmap textCompletion completions
137+ pure $ fmap ( textCompletion CompletionItemKind. Module ) completions
136138
137139-- Why don't we need the text for this?
138140getLangextCompletions :: Text -> StaticLsM [Completion ]
139141getLangextCompletions _ = do
140- pure (textCompletion <$> (allExtensions <> [" LANGUAGE" ]))
142+ pure (textCompletion CompletionItemKind. Module <$> (allExtensions <> [" LANGUAGE" ]))
141143
142144data CompletionMode
143145 = ImportMode ! (Maybe Text )
@@ -247,7 +249,7 @@ formatQualifiedAs mod alias = "import qualified " <> mod <> " as " <> alias
247249getFlyImports :: Context -> HashSet Text -> Text -> Text -> StaticLsM [Completion ]
248250getFlyImports cx qualifiedCompletions prefix match = do
249251 let expandedPrefix = Maybe. fromMaybe prefix (defaultAlias prefix)
250- let bootCompletions = [mkBootCompletion expandedPrefix prefix match cx. path | isBootModule expandedPrefix]
252+ let bootCompletions = [mkBootCompletion CompletionItemKind. Module expandedPrefix prefix match cx. path | isBootModule expandedPrefix]
251253 mods <- getModules
252254 mods <- pure $ filter (expandedPrefix `isModSuffixOf` ) mods
253255 completions <- for mods \ mod -> do
@@ -263,7 +265,7 @@ getFlyImports cx qualifiedCompletions prefix match = do
263265 pure $
264266 fmap
265267 ( \ completion ->
266- (textCompletion completion)
268+ (textCompletion CompletionItemKind. Module completion)
267269 { description = Just $ formatQualifiedAs mod prefix
268270 , msg = Just $ CompletionMessage {path = cx. path, kind = FlyImportCompletionKind mod prefix}
269271 }
@@ -283,13 +285,13 @@ getCompletion cx = do
283285 let modsWithoutPrefix = case modPrefix of
284286 Just prefix -> Maybe. mapMaybe (T. stripPrefix (prefix <> " ." )) mods
285287 Nothing -> mods
286- pure (False , textCompletion <$> modsWithoutPrefix)
288+ pure (False , textCompletion CompletionItemKind. Module <$> modsWithoutPrefix)
287289 HeaderMode mod -> do
288290 let label = " module " <> mod <> " where"
289291 pure
290292 ( False
291293 ,
292- [ (mkCompletion label (label <> " \n $0" ))
294+ [ (mkCompletion CompletionItemKind. Text label (label <> " \n $0" ))
293295 { isSnippet = True
294296 }
295297 ]
@@ -307,7 +309,7 @@ getCompletion cx = do
307309 flyImports <- case match of
308310 " " -> pure []
309311 _ -> getFlyImports cx (HashSet. fromList qualifiedCompletions) mod match
310- pure (match == " " , (textCompletion <$> qualifiedCompletions) ++ flyImports)
312+ pure (match == " " , (textCompletion CompletionItemKind. Module <$> qualifiedCompletions) ++ flyImports)
311313 LangextMode match -> do
312314 comps <- getLangextCompletions match
313315 pure (True , comps)
@@ -355,12 +357,13 @@ data Completion = Completion
355357 , edit :: ! Edit
356358 , msg :: Maybe CompletionMessage
357359 , isSnippet :: ! Bool
360+ , completionItemKind :: CompletionItemKind
358361 }
359362 deriving (Show , Eq , Ord )
360363
361- mkBootCompletion :: Text -> Text -> Text -> AbsPath -> Completion
362- mkBootCompletion mod alias match path =
363- (mkCompletion match " " )
364+ mkBootCompletion :: CompletionItemKind -> Text -> Text -> Text -> AbsPath -> Completion
365+ mkBootCompletion completionItemKind mod alias match path =
366+ (mkCompletion completionItemKind match " " )
364367 { description = Just $ formatQualifiedAs mod alias
365368 , msg =
366369 Just $
@@ -370,11 +373,11 @@ mkBootCompletion mod alias match path =
370373 }
371374 }
372375
373- textCompletion :: Text -> Completion
374- textCompletion text = mkCompletion text text
376+ textCompletion :: CompletionItemKind -> Text -> Completion
377+ textCompletion completionItemKind text = mkCompletion completionItemKind text text
375378
376- mkCompletion :: Text -> Text -> Completion
377- mkCompletion label insertText =
379+ mkCompletion :: CompletionItemKind -> Text -> Text -> Completion
380+ mkCompletion completionItemKind label insertText =
378381 Completion
379382 { label
380383 , detail = Nothing
@@ -384,6 +387,7 @@ mkCompletion label insertText =
384387 , edit = Edit. empty
385388 , msg = Nothing
386389 , isSnippet = False
390+ , completionItemKind
387391 }
388392
389393data TriggerKind = TriggerCharacter | TriggerUnknown
0 commit comments