MCPcopy
hub / github.com/codeaashu/claude-code / getMatchingLspPlugins

Function getMatchingLspPlugins

src/utils/plugins/lspRecommendation.ts:222–309  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

220 * @returns Array of matching plugin recommendations (empty if none or disabled)
221 */
222export async function getMatchingLspPlugins(
223 filePath: string,
224): Promise<LspPluginRecommendation[]> {
225 // Check if globally disabled
226 if (isLspRecommendationsDisabled()) {
227 logForDebugging('[lspRecommendation] Recommendations are disabled')
228 return []
229 }
230
231 // Extract file extension
232 const ext = extname(filePath).toLowerCase()
233 if (!ext) {
234 logForDebugging('[lspRecommendation] No file extension found')
235 return []
236 }
237
238 logForDebugging(`[lspRecommendation] Looking for LSP plugins for ${ext}`)
239
240 // Get all LSP plugins from marketplaces
241 const allLspPlugins = await getLspPluginsFromMarketplaces()
242
243 // Get config for filtering
244 const config = getGlobalConfig()
245 const neverPlugins = config.lspRecommendationNeverPlugins ?? []
246
247 // Filter to matching plugins
248 const matchingPlugins: Array<{ info: LspPluginInfo; pluginId: string }> = []
249
250 for (const [pluginId, info] of allLspPlugins) {
251 // Check extension match
252 if (!info.extensions.has(ext)) {
253 continue
254 }
255
256 // Filter: not in "never" list
257 if (neverPlugins.includes(pluginId)) {
258 logForDebugging(
259 `[lspRecommendation] Skipping ${pluginId} (in never suggest list)`,
260 )
261 continue
262 }
263
264 // Filter: not already installed
265 if (isPluginInstalled(pluginId)) {
266 logForDebugging(
267 `[lspRecommendation] Skipping ${pluginId} (already installed)`,
268 )
269 continue
270 }
271
272 matchingPlugins.push({ info, pluginId })
273 }
274
275 // Filter: binary must be installed (async check)
276 const pluginsWithBinary: Array<{ info: LspPluginInfo; pluginId: string }> = []
277
278 for (const { info, pluginId } of matchingPlugins) {
279 const binaryExists = await isBinaryInstalled(info.command)

Callers 1

Calls 8

logForDebuggingFunction · 0.85
getGlobalConfigFunction · 0.85
isPluginInstalledFunction · 0.85
isBinaryInstalledFunction · 0.85
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected