@@ -151,13 +151,6 @@ occNameToComKind ty oc
151151showModName :: ModuleName -> T. Text
152152showModName = T. pack . moduleNameString
153153
154- -- mkCompl :: IdeOptions -> CompItem -> CompletionItem
155- -- mkCompl IdeOptions{..} CI{compKind,insertText, importedFrom,typeText,label,docs} =
156- -- CompletionItem label kind (List []) ((colon <>) <$> typeText)
157- -- (Just $ CompletionDocMarkup $ MarkupContent MkMarkdown $ T.intercalate sectionSeparator docs')
158- -- Nothing Nothing Nothing Nothing (Just insertText) (Just Snippet)
159- -- Nothing Nothing Nothing Nothing Nothing
160-
161154mkCompl :: PluginId -> IdeOptions -> CompItem -> CompletionItem
162155mkCompl
163156 pId
@@ -179,10 +172,10 @@ mkCompl
179172 _tags = Nothing ,
180173 _detail =
181174 case (typeText, provenance) of
182- (Just t,_) -> Just $ colon <> t
183- (_, ImportedFrom mod ) -> Just $ " from " <> mod
184- (_, DefinedIn mod ) -> Just $ " from " <> mod
185- _ -> Nothing ,
175+ (Just t,_) | not ( T. null t) -> Just $ colon <> t
176+ (_, ImportedFrom mod ) -> Just $ " from " <> mod
177+ (_, DefinedIn mod ) -> Just $ " from " <> mod
178+ _ -> Nothing ,
186179 _documentation = documentation,
187180 _deprecated = Nothing ,
188181 _preselect = Nothing ,
@@ -448,12 +441,12 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
448441 [mkComp id CiVariable Nothing
449442 | VarPat _ id <- listify (\ (_ :: Pat GhcPs ) -> True ) pat_lhs]
450443 TyClD _ ClassDecl {tcdLName, tcdSigs} ->
451- mkComp tcdLName CiInterface Nothing :
444+ mkComp tcdLName CiInterface ( Just $ ppr tcdLName) :
452445 [ mkComp id CiFunction (Just $ ppr typ)
453446 | L _ (ClassOpSig _ _ ids typ) <- tcdSigs
454447 , id <- ids]
455448 TyClD _ x ->
456- let generalCompls = [mkComp id cl Nothing
449+ let generalCompls = [mkComp id cl ( Just $ ppr $ tcdLName x)
457450 | id <- listify (\ (_ :: Located (IdP GhcPs )) -> True ) x
458451 , let cl = occNameToComKind Nothing (rdrNameOcc $ unLoc id )]
459452 -- here we only have to look at the outermost type
@@ -471,8 +464,12 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
471464 ]
472465
473466 mkLocalComp pos n ctyp ty =
474- CI ctyp pn (Local pos) ty pn Nothing doc (ctyp `elem` [CiStruct , CiInterface ]) Nothing
467+ CI ctyp pn (Local pos) ensureTypeText pn Nothing doc (ctyp `elem` [CiStruct , CiInterface ]) Nothing
475468 where
469+ -- when sorting completions, we use the presence of typeText
470+ -- to tell local completions and global completions apart
471+ -- instead of using the empty string here, we should probably introduce a new field...
472+ ensureTypeText = Just $ fromMaybe " " ty
476473 pn = ppr n
477474 doc = SpanDocText (getDocumentation [pm] n) (SpanDocUris Nothing Nothing )
478475
0 commit comments