@@ -151,13 +151,6 @@ occNameToComKind ty oc
151
151
showModName :: ModuleName -> T. Text
152
152
showModName = T. pack . moduleNameString
153
153
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
-
161
154
mkCompl :: PluginId -> IdeOptions -> CompItem -> CompletionItem
162
155
mkCompl
163
156
pId
@@ -179,10 +172,10 @@ mkCompl
179
172
_tags = Nothing ,
180
173
_detail =
181
174
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 ,
186
179
_documentation = documentation,
187
180
_deprecated = Nothing ,
188
181
_preselect = Nothing ,
@@ -448,12 +441,12 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
448
441
[mkComp id CiVariable Nothing
449
442
| VarPat _ id <- listify (\ (_ :: Pat GhcPs ) -> True ) pat_lhs]
450
443
TyClD _ ClassDecl {tcdLName, tcdSigs} ->
451
- mkComp tcdLName CiInterface Nothing :
444
+ mkComp tcdLName CiInterface ( Just $ ppr tcdLName) :
452
445
[ mkComp id CiFunction (Just $ ppr typ)
453
446
| L _ (ClassOpSig _ _ ids typ) <- tcdSigs
454
447
, id <- ids]
455
448
TyClD _ x ->
456
- let generalCompls = [mkComp id cl Nothing
449
+ let generalCompls = [mkComp id cl ( Just $ ppr $ tcdLName x)
457
450
| id <- listify (\ (_ :: Located (IdP GhcPs )) -> True ) x
458
451
, let cl = occNameToComKind Nothing (rdrNameOcc $ unLoc id )]
459
452
-- here we only have to look at the outermost type
@@ -471,8 +464,12 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
471
464
]
472
465
473
466
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
475
468
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
476
473
pn = ppr n
477
474
doc = SpanDocText (getDocumentation [pm] n) (SpanDocUris Nothing Nothing )
478
475
0 commit comments