Skip to content

Commit c43386c

Browse files
committed
Add package.json catalog support for npm completions and hover
Extend the npm extension to recognize the `catalog` section in package.json, enabling IntelliSense completions, version suggestions, and hover information for packages listed under the catalog key. This supports the catalog feature used by pnpm, bun, and yarn for centralizing dependency versions in monorepos. Fixes #294609
1 parent 75f21d0 commit c43386c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

extensions/npm/src/features/packageJSONContribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class PackageJSONContribution implements IJSONContribution {
7070
return null;
7171
}
7272

73-
if ((location.matches(['dependencies']) || location.matches(['devDependencies']) || location.matches(['optionalDependencies']) || location.matches(['peerDependencies']))) {
73+
if ((location.matches(['dependencies']) || location.matches(['devDependencies']) || location.matches(['optionalDependencies']) || location.matches(['peerDependencies']) || location.matches(['catalog']))) {
7474
let queryUrl: string;
7575
if (currentWord.length > 0) {
7676
if (currentWord[0] === '@') {
@@ -184,7 +184,7 @@ export class PackageJSONContribution implements IJSONContribution {
184184
return null;
185185
}
186186

187-
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) {
187+
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']) || location.matches(['catalog', '*']))) {
188188
const currentKey = location.path[location.path.length - 1];
189189
if (typeof currentKey === 'string') {
190190
const info = await this.fetchPackageInfo(currentKey, resource);
@@ -347,7 +347,7 @@ export class PackageJSONContribution implements IJSONContribution {
347347
if (!this.isEnabled()) {
348348
return null;
349349
}
350-
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) {
350+
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']) || location.matches(['catalog', '*']))) {
351351
const pack = location.path[location.path.length - 1];
352352
if (typeof pack === 'string') {
353353
return this.fetchPackageInfo(pack, resource).then(info => {

0 commit comments

Comments
 (0)