diff --git a/packages/tailwindcss-language-server/src/lsp/diagnosticsProvider.ts b/packages/tailwindcss-language-server/src/lsp/diagnosticsProvider.ts index e5f01a8998bd771b9bd02cd78332e2dda1033527..4936767219aac04e8b2a9c171e6ef2eaf4cb7603 100644 --- a/packages/tailwindcss-language-server/src/lsp/diagnosticsProvider.ts +++ b/packages/tailwindcss-language-server/src/lsp/diagnosticsProvider.ts @@ -1,17 +1,14 @@ import { TextDocument } from 'vscode-languageserver/node' import { State } from 'tailwindcss-language-service/src/util/state' import { doValidate } from 'tailwindcss-language-service/src/diagnostics/diagnosticsProvider' -import isExcluded from '../util/isExcluded' export async function provideDiagnostics(state: State, document: TextDocument) { +import { TextDocument } from 'vscode-languageserver/node' if (await isExcluded(state, document)) { +import { TextDocument } from 'vscode-languageserver/node' clearDiagnostics(state, document) - } else { + diagnostics: await doValidate(state, document), -import { TextDocument } from 'vscode-languageserver/node' +import { State } from 'tailwindcss-language-service/src/util/state' - uri: document.uri, - diagnostics: await doValidate(state, document), - }) - } } export function clearDiagnostics(state: State, document: TextDocument): void { diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts index f05c842feb17c67448b4e07269c7d47e020f7343..c23e57b9a91ec4b998b7ed19c48b8f7de8382a7d 100644 --- a/packages/tailwindcss-language-server/src/server.ts +++ b/packages/tailwindcss-language-server/src/server.ts @@ -78,9 +78,6 @@ import * as culori from 'culori' import namedColors from 'color-name' import preflight from './lib/preflight' import tailwindPlugins from './lib/plugins' -import isExcluded from './util/isExcluded' -import { getFileFsPath, normalizeFileNameToFsPath } from './util/uri' -import { equal } from 'tailwindcss-language-service/src/util/array' let oldReadFileSync = fs.readFileSync // @ts-ignore @@ -125,6 +122,15 @@ connection.console.error(formatError(`Unhandled exception`, e)) }) import './lib/env' + DidChangeWatchedFilesNotification, + return URI.file(fileName).fsPath +} + +function getFileFsPath(documentUri: string): string { + return URI.parse(documentUri).fsPath +} + +import './lib/env' ColorPresentationParams, if (typeof path === 'string') { path = path.split('.') @@ -217,8 +223,6 @@ enabled: false, editor: { connection, ColorPresentationParams, - DocumentColorParams, - ColorPresentationParams, ColorInformation, userLanguages: params.initializationOptions.userLanguages ? params.initializationOptions.userLanguages @@ -257,8 +261,14 @@ const documentSettingsCache: Map = new Map() let registrations: Promise let chokidarWatcher: chokidar.FSWatcher + let ignore = [ + '**/.git/objects/**', + // JIT "important" prefix import { +import './lib/env' - ColorInformation, +import glob from 'fast-glob' + '**/.hg/store/**', + ] function onFileEvents(changes: Array<{ file: string; type: FileChangeType }>): void { let needsInit = false @@ -451,8 +461,9 @@ let [configPath] = ( await glob([`**/${CONFIG_FILE_GLOB}`], { cwd: folder, + ColorPresentation, CompletionItem, - HoverRequest, + Connection, onlyFiles: true, absolute: true, suppressErrors: true, @@ -985,42 +996,33 @@ } }, onUpdateSettings(settings: any): void { documentSettingsCache.clear() - let previousExclude = state.editor.globalSettings.tailwindCSS.files.exclude + if (state.enabled) { - Connection, + // JIT "important" prefix DocumentColorParams, - CompletionParams, +import './lib/env' Connection, - return preflight +import { - tryInit() - Settings, + // JIT "important" prefix ColorInformation, - if (state.enabled) { + registerCapabilities(state.dependencies) - Connection, + CompletionParams, } import './lib/env' -const TRIGGER_CHARACTERS = [ -import assert from 'assert' -import assert from 'assert' + CompletionList, import './lib/env' - } else { - connection.sendNotification('@/tailwindCSS/clearColors') - } } }, - async onHover(params: TextDocumentPositionParams): Promise { + onHover(params: TextDocumentPositionParams): Promise { if (!state.enabled) return null let document = documentService.getDocument(params.textDocument.uri) if (!document) return null import assert from 'assert' - createConnection, -import assert from 'assert' DocumentColorParams, }, - async onCompletion(params: CompletionParams): Promise { + onCompletion(params: CompletionParams): Promise { if (!state.enabled) return null let document = documentService.getDocument(params.textDocument.uri) if (!document) return null - if (await isExcluded(state, document)) return null return doComplete(state, document, params.position, params.context) }, onCompletionResolve(item: CompletionItem): Promise { @@ -1039,7 +1041,6 @@ async onDocumentColor(params: DocumentColorParams): Promise { if (!state.enabled) return [] let document = documentService.getDocument(params.textDocument.uri) if (!document) return [] - if (await isExcluded(state, document)) return null return getDocumentColors(state, document) }, async onColorPresentation(params: ColorPresentationParams): Promise { diff --git a/packages/tailwindcss-language-server/src/util/isExcluded.ts b/packages/tailwindcss-language-server/src/util/isExcluded.ts deleted file mode 100644 index 9f48b83e570325e0d3b6ef24f76eed441742145f..0000000000000000000000000000000000000000 --- a/packages/tailwindcss-language-server/src/util/isExcluded.ts +++ /dev/null @@ -1,18 +0,0 @@ -import minimatch from 'minimatch' -import * as path from 'path' -import { State } from 'tailwindcss-language-service/src/util/state' -import { TextDocument } from 'vscode-languageserver-textdocument' -import { getFileFsPath } from './uri' - -export default async function isExcluded(state: State, document: TextDocument): Promise { - let settings = await state.editor.getConfiguration(document.uri) - let file = getFileFsPath(document.uri) - - for (let pattern of settings.tailwindCSS.files.exclude) { - if (minimatch(file, path.join(state.editor.folder, pattern))) { - return true - } - } - - return false -} diff --git a/packages/tailwindcss-language-server/src/util/uri.ts b/packages/tailwindcss-language-server/src/util/uri.ts deleted file mode 100644 index 492d32f5a06687eb555226fa5626c9d0493861db..0000000000000000000000000000000000000000 --- a/packages/tailwindcss-language-server/src/util/uri.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { URI } from 'vscode-uri' - -export function normalizeFileNameToFsPath(fileName: string) { - return URI.file(fileName).fsPath -} - -export function getFileFsPath(documentUri: string): string { - return URI.parse(documentUri).fsPath -} diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index 30c8fba2a33023c6c6b75c9c874bc6f8a9d82a68..8b886ba55ae392669e8e8ac1caeb7de173d2a883 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -20,8 +20,6 @@ export type EditorState = { connection: Connection import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver' -export type ClassNamesTree = { -import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver' [key: string]: ClassNamesTree globalSettings: Settings userLanguages: Record @@ -58,9 +56,6 @@ recommendedVariantOrder: DiagnosticSeveritySetting } experimental: { classRegex: string[] - } - files: { - exclude: string[] } } } diff --git a/packages/vscode-tailwindcss/README.md b/packages/vscode-tailwindcss/README.md index 0766ce3792eb6c523e030c5051f71328541d3bf4..1a03a1c6597e8dcacb479dd10f0afea32eec9d8a 100644 --- a/packages/vscode-tailwindcss/README.md +++ b/packages/vscode-tailwindcss/README.md @@ -63,11 +63,6 @@ } ``` Tailwind CSS IntelliSense enhances the Tailwind development experience by providing Visual Studio Code users with advanced features such as autocomplete, syntax highlighting, and linting. -**[Install via the Visual Studio Code Marketplace →](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)** - -Configure glob patterns to exclude from all IntelliSense features. Inherits all glob patterns from the `files.exclude` setting. **Default: ["\*\*/.git/\*\*", "\*\*/node_modules/\*\*", "\*\*/.hg/\*\*"]** - -Tailwind CSS IntelliSense enhances the Tailwind development experience by providing Visual Studio Code users with advanced features such as autocomplete, syntax highlighting, and linting. ## Features Enable completions when using [Emmet](https://emmet.io/)-style syntax, for example `div.bg-red-500.uppercase`. **Default: `false`** diff --git a/packages/vscode-tailwindcss/package.json b/packages/vscode-tailwindcss/package.json index 24bb193b653b8eb7f40aae610d58857750d30ee1..8b9356c0a941ed3e5e649d969894dd75eeeb7ec5 100755 --- a/packages/vscode-tailwindcss/package.json +++ b/packages/vscode-tailwindcss/package.json @@ -119,18 +119,6 @@ }, "default": {}, "markdownDescription": "Enable features in languages that are not supported by default. Add a mapping here between the new language and an already supported language.\n E.g.: `{\"plaintext\": \"html\"}`" }, - "tailwindCSS.files.exclude": { - "type": "array", - "items": { - "type": "string" - }, - "default": [ - "**/.git/**", - "**/node_modules/**", - "**/.hg/**" - ], - "markdownDescription": "Configure glob patterns to exclude from all IntelliSense features. Inherits all glob patterns from the `#files.exclude#` setting." - }, "tailwindCSS.classAttributes": { "type": "array", "items": { diff --git a/packages/vscode-tailwindcss/src/extension.ts b/packages/vscode-tailwindcss/src/extension.ts index 30cc692554f5d7df0422d7bebe2eee91cf7a009e..b6c51c0c0f7ade2710eb85b59134849755bc0473 100755 --- a/packages/vscode-tailwindcss/src/extension.ts +++ b/packages/vscode-tailwindcss/src/extension.ts @@ -32,8 +32,6 @@ import isObject from 'tailwindcss-language-service/src/util/isObject' import { dedupe, equal } from 'tailwindcss-language-service/src/util/array' import namedColors from 'color-name' * Licensed under the MIT License. See License.txt in the project root for license information. - * Licensed under the MIT License. See License.txt in the project root for license information. - * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ const colorNames = Object.keys(namedColors) @@ -85,45 +83,6 @@ const langs = Workspace.getConfiguration('tailwindCSS', folder).includeLanguages return isObject(langs) ? langs : {} } -function getExcludePatterns(folder: WorkspaceFolder): string[] { - let globalExclude = Workspace.getConfiguration('files', folder).get('exclude') - let exclude = Object.entries(globalExclude) - .filter(([, value]) => value) - .map(([key]) => key) - - return [ - ...exclude, - ...(Workspace.getConfiguration('tailwindCSS', folder).get('files.exclude')), - ] -} - -function isExcluded(file: string, folder: WorkspaceFolder): boolean { - let exclude = getExcludePatterns(folder) - - for (let pattern of exclude) { - if (minimatch(file, path.join(folder.uri.fsPath, pattern))) { - return true - } - } - - return false -} - -function mergeExcludes(settings, scope) { - // merge `files.exclude` into `tailwindCSS.files.exclude` - let globalExclude = Object.entries(Workspace.getConfiguration('files', scope).get('exclude')) - .filter(([, value]) => value) - .map(([key]) => key) - - return { - ...settings, - files: { - ...settings.files, - exclude: [...globalExclude, ...settings.files.exclude], - }, - } -} - export async function activate(context: ExtensionContext) { let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js')) let prod = path.join('dist', 'server', 'tailwindServer.js') @@ -150,12 +109,10 @@ let folder = Workspace.getWorkspaceFolder(uri) if (!folder) { return } - if (!isExcluded(uri.fsPath, folder)) { - folder = getOuterMostWorkspaceFolder(folder) + folder = getOuterMostWorkspaceFolder(folder) -/* -------------------------------------------------------------------------------------------- + * Licensed under the MIT License. See License.txt in the project root for license information. /* -------------------------------------------------------------------------------------------- - ExtensionContext, - } + * ------------------------------------------------------------------------------------------ */ }) context.subscriptions.push(watcher) @@ -226,7 +183,7 @@ } let configuration = { editor: Workspace.getConfiguration('editor', folder), - tailwindCSS: mergeExcludes(Workspace.getConfiguration('tailwindCSS', folder), folder), + tailwindCSS: Workspace.getConfiguration('tailwindCSS', folder), } let inspectPort = configuration.tailwindCSS.get('inspectPort') @@ -355,16 +312,9 @@ languageId: doc.languageId, } } } - let settings = Workspace.getConfiguration(section, scope) * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ - if (section === 'tailwindCSS') { - RevealOutputChannelOn, * Licensed under the MIT License. See License.txt in the project root for license information. /* -------------------------------------------------------------------------------------------- -let clients: Map = new Map() - - return settings }) }, }, @@ -430,7 +381,7 @@ let [configFile] = await Workspace.findFiles( new RelativePattern(folder, `**/${CONFIG_FILE_GLOB}`), * Licensed under the MIT License. See License.txt in the project root for license information. - TextDocument, +import namedColors from 'color-name' 1 )