File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { DocumentFilter } from '@volar/vscode'
22import { middleware } from '@volar/vscode'
33import { LanguageClient , TransportKind } from '@volar/vscode/node'
4- import { PACKAGE_JSON_BASENAME , PNPM_WORKSPACE_BASENAME , YARN_WORKSPACE_BASENAME } from 'npmx-language-core/constants'
4+ import { DEPENDENCY_FILE_GLOB } from 'npmx-language-core/constants'
55import { displayName , extensionId } from 'npmx-shared/meta'
66import { Hover , MarkdownString } from 'vscode'
77import { registerRequests } from './request'
88
9- const SUPPORTED_DOCUMENT_PATTERN = `**/{${ PACKAGE_JSON_BASENAME } ,${ PNPM_WORKSPACE_BASENAME } ,${ YARN_WORKSPACE_BASENAME } }`
10-
119const SUPPORTED_LANGUAGES = [
1210 'javascript' ,
1311 'typescript' ,
@@ -60,7 +58,7 @@ export function launch(serverPath: string) {
6058 } ,
6159 } ,
6260 documentSelector : [
63- { scheme : 'file' , pattern : SUPPORTED_DOCUMENT_PATTERN } ,
61+ { scheme : 'file' , pattern : DEPENDENCY_FILE_GLOB } ,
6462 ...SUPPORTED_LANGUAGES . map ( ( language ) => ( { scheme : 'file' , language } satisfies DocumentFilter ) ) ,
6563 ] ,
6664 markdown : {
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ export const PACKAGE_JSON_BASENAME = 'package.json'
22export const PNPM_WORKSPACE_BASENAME = 'pnpm-workspace.yaml'
33export const YARN_WORKSPACE_BASENAME = '.yarnrc.yml'
44
5+ export const DEPENDENCY_FILE_GLOB = `**/{${ PACKAGE_JSON_BASENAME } ,${ PNPM_WORKSPACE_BASENAME } ,${ YARN_WORKSPACE_BASENAME } }`
6+
57export const CACHE_MAX_AGE_ONE_DAY = 60 * 60 * 24
68
79export const NPMX_DEV = 'https://npmx.dev'
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import type { IWorkspaceState } from 'npmx-language-service/types'
44import type { GetPackageManagerRequest } from 'npmx-shared/protocol'
55import { access , readFile } from 'node:fs/promises'
66import { RequestType } from '@volar/language-server'
7- import { PACKAGE_JSON_BASENAME } from 'npmx-language-core/constants'
7+ import { DEPENDENCY_FILE_GLOB , PACKAGE_JSON_BASENAME } from 'npmx-language-core/constants'
88import { isDependencyFile , isPackageManifest , isWorkspaceFile } from 'npmx-language-core/utils'
99import { WorkspaceContext } from 'npmx-language-core/workspace'
1010import { GET_PACKAGE_MANAGER_METHOD } from 'npmx-shared/protocol'
@@ -61,6 +61,10 @@ export class WorkspaceState implements IWorkspaceState {
6161 }
6262
6363 #registerEventListeners( ) {
64+ this . #server. onInitialized ( ( ) => {
65+ this . #server. fileWatcher . watchFiles ( [ DEPENDENCY_FILE_GLOB ] )
66+ } )
67+
6468 this . #server. workspaceFolders . onDidChange ( ( { removed } ) => {
6569 for ( const folder of removed ) {
6670 const folderUri = URI . parse ( folder . uri )
You can’t perform that action at this time.
0 commit comments