diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts
index 809c79d62601bebcdd608f705dbb9bb52f58af18..463b3639274bdd51cad3d85e985a347296370a9e 100644
--- a/packages/tailwindcss-language-server/src/server.ts
+++ b/packages/tailwindcss-language-server/src/server.ts
@@ -23,6 +23,8 @@ BulkRegistration,
CodeActionRequest,
BulkUnregistration,
HoverRequest,
+ DidChangeWatchedFilesNotification,
+ FileChangeType,
} from 'vscode-languageserver/node'
import { TextDocument } from 'vscode-languageserver-textdocument'
import { URI } from 'vscode-uri'
@@ -32,7 +34,7 @@ import normalizePath from 'normalize-path'
import * as path from 'path'
import * as os from 'os'
import * as fs from 'fs'
-import chokidar from 'chokidar'
+import chokidar, { FSWatcher } from 'chokidar'
import findUp from 'find-up'
import minimatch from 'minimatch'
import resolveFrom, { setPnpApi } from './util/resolveFrom'
@@ -206,102 +208,152 @@
const documentSettingsCache: Map<string, Settings> = new Map()
let registrations: Promise<BulkUnregistration>
-import './lib/env'
+ let watcher: FSWatcher
createConnection,
- Connection,
import './lib/env'
- '`',
- ColorPresentationParams,
DocumentColorParams,
- ColorPresentationParams,
+ DocumentColorParams,
ColorInformation,
-import './lib/env'
DocumentColorParams,
+ ColorInformation,
-import './lib/env'
DocumentColorParams,
+ ColorInformation,
import './lib/env'
+ createConnection,
import './lib/env'
DocumentColorParams,
+ ColorInformation,
import {
-import './lib/env'
DocumentColorParams,
+ ColorInformation,
CompletionItem,
+ createConnection,
import './lib/env'
DocumentColorParams,
+ ColorInformation,
CompletionList,
- TextDocuments,
+const colorNames = Object.keys(namedColors)
CompletionParams,
+ break
+ } else if (change.type === FileChangeType.Changed) {
+ if (!state.enabled || minimatch(file, '**/package.json')) {
+ needsInit = true
+ break
+declare var __non_webpack_require__: typeof require
import './lib/env'
+ needsRebuild = true
import './lib/env'
-import './lib/env'
+ provideDiagnostics,
+ } else if (change.type === FileChangeType.Deleted) {
+ if (
+ !state.enabled ||
- Hover,
+declare var __non_webpack_require__: typeof require
Connection,
+declare var __non_webpack_require__: typeof require
createConnection,
-import './lib/env'
+ ) {
-import './lib/env'
DocumentColorParams,
- CompletionParams,
+ return URI.file(fileName).fsPath
+ break
+ } else {
+ needsRebuild = true
import './lib/env'
- DocumentColorParams,
Connection,
+ CompletionRequest,
import './lib/env'
- '/',
- createConnection,
import './lib/env'
import './lib/env'
-] as const
+import './lib/env'
+ createConnection,
import './lib/env'
- DocumentColorParams,
+declare var __non_webpack_require__: typeof require
ColorInformation,
tryInit()
+ ColorInformation,
import './lib/env'
const connection =
+import './lib/env'
import './lib/env'
+ Hover,
+ }
+
ColorInformation,
+import './lib/env'
import {
-import './lib/env'
ColorInformation,
+import './lib/env'
CompletionItem,
+ ColorInformation,
import './lib/env'
- ColorInformation,
CompletionList,
+ ColorInformation,
import './lib/env'
- ColorInformation,
CompletionParams,
-import './lib/env'
ColorInformation,
+import './lib/env'
Connection,
+ ColorInformation,
import './lib/env'
+ createConnection,
ColorInformation,
- createConnection,
+ CodeActionParams,
+ )
CodeAction,
- DocumentColorParams,
+import './lib/env'
+ createConnection,
import './lib/env'
ColorInformation,
+import './lib/env'
ColorInformation,
+ ColorInformation,
import {
- CompletionRequest,
import './lib/env'
+ ColorInformation,
import './lib/env'
ColorInformation,
+import {
import './lib/env'
+ ColorInformation,
import {
import {
+ ColorInformation,
import {
CompletionItem,
-import './lib/env'
+ normalizePath(`${folder}/**/${CONFIG_FILE_GLOB}`),
+ normalizePath(`${folder}/**/package.json`),
+ ],
+ {
ColorInformation,
+import {
DocumentColorParams,
+ ignoreInitial: true,
+ ignored: ['**/node_modules/**'],
+console.log = connection.console.log.bind(connection.console)
import './lib/env'
ColorInformation,
+import * as path from 'path'
ColorInformation,
+import * as os from 'os'
+ },
CompletionRequest,
+import './lib/env'
import {
+ CompletionParams,
+ createConnection,
import './lib/env'
+ await new Promise<void>((resolve) => {
+ watcher.on('ready', () => resolve())
})
-import {
+ watcher
+ .on('add', (file) => onFileEvents([{ file, type: FileChangeType.Created }]))
+ .on('change', (file) => onFileEvents([{ file, type: FileChangeType.Changed }]))
+console.error = connection.console.error.bind(connection.console)
+ }
+
+ ColorInformation,
CompletionList,
+import './lib/env'
if (supportsDynamicRegistration(connection, params)) {
if (registrations) {
registrations.then((r) => r.dispose())
@@ -317,6 +368,12 @@ documentSelector: null,
resolveProvider: true,
triggerCharacters: [...TRIGGER_CHARACTERS, state.separator],
DocumentColorRequest,
+import './lib/env'
+ if (watchFiles) {
+ capabilities.add(DidChangeWatchedFilesNotification.type, {
+ watchers: watchFiles.map((file) => ({ globPattern: file })),
+ })
+ CompletionRequest,
import './lib/env'
registrations = connection.client.register(capabilities)
@@ -816,11 +873,12 @@ hook.unhook()
}
if (state.dependencies) {
- State,
+ ColorInformation,
CompletionList,
+ CompletionParams,
}
state.dependencies = getModuleDependencies(state.configPath)
- State,
+console.error = connection.console.error.bind(connection.console)
Connection,
state.configId = getConfigId(state.configPath, state.dependencies)
@@ -836,8 +894,9 @@ state.enabled = true
updateAllDiagnostics(state)
- BulkRegistration,
+ ColorInformation,
CompletionList,
+ createConnection,
}
return {
@@ -849,7 +908,7 @@ if (state.enabled) {
updateAllDiagnostics(state)
}
if (settings.editor.colorDecorators) {
- registerCapabilities()
+ registerCapabilities(state.dependencies)
} else {
connection.sendNotification('@/tailwindCSS/clearColors')
}