@@ -59,7 +59,7 @@ import GHC.Plugins (Depth (AllTheWay),
59
59
#endif
60
60
import Ide.PluginUtils (mkLspCommand , lookupPluginId )
61
61
import Ide.Types (CommandId (.. ),
62
- IdePlugins )
62
+ IdePlugins , PluginId )
63
63
import Language.LSP.Types
64
64
import Language.LSP.Types.Capabilities
65
65
import qualified Language.LSP.VFS as VFS
@@ -161,9 +161,10 @@ occNameToComKind ty oc
161
161
showModName :: ModuleName -> T. Text
162
162
showModName = T. pack . moduleNameString
163
163
164
- mkCompl :: IdePlugins a -> IdeOptions -> CompItem -> CompletionItem
164
+ mkCompl :: Maybe PluginId -- ^ Plugin to use for the extend import command
165
+ -> IdeOptions -> CompItem -> CompletionItem
165
166
mkCompl
166
- plugins
167
+ pId
167
168
IdeOptions {.. }
168
169
CI
169
170
{ compKind,
@@ -175,7 +176,7 @@ mkCompl
175
176
docs,
176
177
additionalTextEdits
177
178
} = do
178
- let mbCommand = mkAdditionalEditsCommand plugins =<< additionalTextEdits
179
+ let mbCommand = mkAdditionalEditsCommand pId =<< additionalTextEdits
179
180
let ci = CompletionItem
180
181
{_label = label,
181
182
_kind = kind,
@@ -217,12 +218,9 @@ mkCompl
217
218
" line " <> printOutputable (srcLocLine loc) <> " , column " <> printOutputable (srcLocCol loc)
218
219
219
220
220
- mkAdditionalEditsCommand :: IdePlugins a -> ExtendImport -> Maybe Command
221
- mkAdditionalEditsCommand plugins edits = case lookupPluginId extendImportCommand plugins of
222
- Just pId -> Just $ mkLspCommand pId (CommandId extendImportCommandId) " extend import" (Just [toJSON edits])
223
- Nothing -> Nothing
224
- where
225
- extendImportCommand = CommandId extendImportCommandId
221
+ mkAdditionalEditsCommand :: Maybe PluginId -> ExtendImport -> Maybe Command
222
+ mkAdditionalEditsCommand (Just pId) edits = Just $ mkLspCommand pId (CommandId extendImportCommandId) " extend import" (Just [toJSON edits])
223
+ mkAdditionalEditsCommand _ _ = Nothing
226
224
227
225
mkNameCompItem :: Uri -> Maybe T. Text -> OccName -> Provenance -> Maybe Type -> Maybe Backtick -> SpanDoc -> Maybe (LImportDecl GhcPs ) -> CompItem
228
226
mkNameCompItem doc thingParent origName provenance thingType isInfix docs ! imp = CI {.. }
@@ -666,7 +664,8 @@ getCompletions plugins ideOpts CC {allModNamesAsNS, anyQualCompls, unqualCompls,
666
664
| otherwise -> do
667
665
-- assumes that nubOrdBy is stable
668
666
let uniqueFiltCompls = nubOrdBy (uniqueCompl `on` snd . Fuzzy. original) filtCompls
669
- let compls = (fmap . fmap . fmap ) (mkCompl plugins ideOpts) uniqueFiltCompls
667
+ let compls = (fmap . fmap . fmap ) (mkCompl pId ideOpts) uniqueFiltCompls
668
+ pId = lookupPluginId (CommandId extendImportCommandId) plugins
670
669
return $
671
670
(fmap . fmap ) snd $
672
671
sortBy (compare `on` lexicographicOrdering) $
0 commit comments