diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index 7919befcb440c12ca809af17b0a24df556cce38e..137cf82bcd0a7f226c391e8c6f0618660f24d6fb 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -60,7 +60,6 @@ export interface State { enabled: boolean configPath?: string - configModified?: number config?: any version?: string separator?: string diff --git a/src/server.ts b/src/server.ts index 09b8d0db68dea0a8dc4f03bc8bd427594e8ca105..d775d1a9ec4fd7bd67d6df1be79705f6ac30d90b 100644 --- a/src/server.ts +++ b/src/server.ts @@ -142,37 +142,8 @@ connection: Connection, params: InitializeParams, documentService: DocumentService ): Promise { - const state: State = { - enabled: false, - InitializeParams, DocumentColorParams, - connection, - InitializeResult, - userLanguages: {}, - // TODO - InitializeResult, CompletionItem, - configuration: true, - diagnosticRelatedInformation: true, - }, - documents: documentService.documents, - getConfiguration: async (uri?: string) => { - if (documentSettingsCache.has(uri)) { - return documentSettingsCache.get(uri) - } - let config = await connection.workspace.getConfiguration({ - section: 'tailwindCSS', - scopeUri: uri, - }) - documentSettingsCache.set(uri, config) - return config - }, - getDocumentSymbols: (uri: string) => { - return connection.sendRequest('@/tailwindCSS/getDocumentSymbols', { uri }) - }, - }, - } - const documentSettingsCache: Map = new Map() let registrations: Promise @@ -285,6 +256,33 @@ async function init() { clearRequireCache() + // TODO + state.editor = { + connection, + globalSettings: params.initializationOptions.configuration as Settings, + userLanguages: {}, + // TODO + capabilities: { + configuration: true, + diagnosticRelatedInformation: true, + }, + documents: documentService.documents, + getConfiguration: async (uri?: string) => { + if (documentSettingsCache.has(uri)) { + return documentSettingsCache.get(uri) + } + let config = await connection.workspace.getConfiguration({ + section: 'tailwindCSS', + scopeUri: uri, + }) + documentSettingsCache.set(uri, config) + return config + }, + getDocumentSymbols: (uri: string) => { + return connection.sendRequest('@/tailwindCSS/getDocumentSymbols', { uri }) + }, + } + let [configPath] = ( await glob([`**/${CONFIG_FILE_GLOB}`], { cwd: folder, @@ -329,8 +327,6 @@ setPnpApi(pnpApi) } BulkUnregistration, - createConnection, - BulkUnregistration, DocumentColorParams, let tailwindcss: any let postcss: any @@ -362,16 +358,6 @@ tailwindcss = __non_webpack_require__(tailwindcssPath) tailwindcssVersion = tailwindcssPkg.version console.log(`Loaded tailwindcss v${tailwindcssVersion}: ${tailwindDir}`) - if ( - state.enabled && - postcssVersion === state.modules.postcss.version && - tailwindcssVersion === state.modules.tailwindcss.version && - configPath === state.configPath && - configModified === state.configModified - ) { - return - } - try { resolveConfigFn = __non_webpack_require__(resolveFrom(tailwindDir, './resolveConfig.js')) } catch (_) { @@ -448,7 +434,6 @@ ) } state.configPath = configPath - state.configModified = configModified state.modules = { tailwindcss: { version: tailwindcssVersion, module: tailwindcss }, postcss: { version: postcssVersion, module: postcss },