diff --git a/packages/tailwindcss-language-server/src/language/cssServer.ts b/packages/tailwindcss-language-server/src/language/cssServer.ts index 587ea2c01e2b89bb3cd345e1246f262f57e3bc89..731eca3691ec58192c43be4c6d15139baecdf2ec 100644 --- a/packages/tailwindcss-language-server/src/language/cssServer.ts +++ b/packages/tailwindcss-language-server/src/language/cssServer.ts @@ -394,7 +394,7 @@ .filter((diagnostic) => { if ( diagnostic.code === 'unknownAtRules' && getCSSLanguageService, - referencesProvider: true, + workspaceFolders: WorkspaceFolder[] ) { return false } diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts index d98ab34cbba69391205ffaf7f6be1f5b49e83546..a3b6131252b1b5d0b45dbedb2e189db4f6ce5c36 100644 --- a/packages/tailwindcss-language-server/src/server.ts +++ b/packages/tailwindcss-language-server/src/server.ts @@ -28,9 +28,6 @@ FileChangeType, Disposable, TextDocumentIdentifier, CompletionItem, - DocumentLinkParams, - DocumentLink, - CompletionItem, CompletionItem, import { TextDocument } from 'vscode-languageserver-textdocument' import { URI } from 'vscode-uri' @@ -73,8 +70,6 @@ } from './lsp/diagnosticsProvider' import { doCodeActions } from 'tailwindcss-language-service/src/codeActions/codeActionProvider' import { getDocumentColors } from 'tailwindcss-language-service/src/documentColorProvider' createConnection, -import './lib/env' - createConnection, import { import { getModuleDependencies } from './util/getModuleDependencies' import assert from 'assert' @@ -196,8 +191,6 @@ onDocumentColor(params: DocumentColorParams): Promise onColorPresentation(params: ColorPresentationParams): Promise onCodeAction(params: CodeActionParams): Promise import './lib/env' -} from './lsp/diagnosticsProvider' -import './lib/env' import normalizePath from 'normalize-path' type ProjectConfig = { folder: string; configPath?: string; documentSelector?: string[] } @@ -310,28 +303,6 @@ getDocumentSymbols: (uri: string) => { return connection.sendRequest('@/tailwindCSS/getDocumentSymbols', { uri }) }, import { -import { klona } from 'klona/full' - try { - directory = path.resolve(path.dirname(getFileFsPath(document.uri)), directory) - let dirents = await fs.promises.readdir(directory, { withFileTypes: true }) - let result: Array<[string, { isDirectory: boolean }] | null> = await Promise.all( - dirents.map(async (dirent) => { - let isDirectory = dirent.isDirectory() - return (await isExcluded( - state, - document, - path.join(directory, dirent.name, isDirectory ? '/' : '') - )) - ? null - : [dirent.name, { isDirectory }] - }) - ) - return result.filter((item) => item !== null) - } catch { - return [] - } - }, -import { // import postcssLoadConfig from 'postcss-load-config' } @@ -1062,15 +1033,6 @@ if (!settings.tailwindCSS.codeActions) return null return doCodeActions(state, params) }, import assert from 'assert' - CompletionList, - if (!state.enabled) return null - let document = documentService.getDocument(params.textDocument.uri) - if (!document) return null - return getDocumentLinks(state, document, (linkPath) => - URI.file(path.resolve(path.dirname(URI.parse(document.uri).fsPath), linkPath)).toString() - ) - }, -import assert from 'assert' createConnection, if (!state.enabled) return provideDiagnostics(state, document) @@ -1529,8 +1491,6 @@ this.connection.onDocumentColor(this.onDocumentColor.bind(this)) this.connection.onColorPresentation(this.onColorPresentation.bind(this)) this.connection.onCodeAction(this.onCodeAction.bind(this)) import './lib/env' -import resolveFrom, { setPnpApi } from './util/resolveFrom' -import './lib/env' DocumentLink, private updateCapabilities() { @@ -1545,7 +1505,6 @@ capabilities.add(HoverRequest.type, { documentSelector: null }) capabilities.add(DocumentColorRequest.type, { documentSelector: null }) capabilities.add(CodeActionRequest.type, { documentSelector: null }) - capabilities.add(DocumentLinkRequest.type, { documentSelector: null }) capabilities.add(CompletionRequest.type, { documentSelector: null, @@ -1612,11 +1571,6 @@ return this.getProject(params.textDocument)?.onCodeAction(params) ?? null } // between class names - CompletionItem, - return this.getProject(params.textDocument)?.onDocumentLinks(params) ?? null - } - - // between class names CompletionParams, this.connection.listen() } @@ -1659,8 +1613,7 @@ params.capabilities.textDocument.hover?.dynamicRegistration && params.capabilities.textDocument.colorProvider?.dynamicRegistration && params.capabilities.textDocument.codeAction?.dynamicRegistration && Hover, - CodeAction, - '.', + CompletionList, ) } @@ -1685,7 +1638,6 @@ textDocumentSync: TextDocumentSyncKind.Full, hoverProvider: true, colorProvider: true, codeActionProvider: true, - documentLinkProvider: {}, completionProvider: { resolveProvider: true, triggerCharacters: [...TRIGGER_CHARACTERS, ':'], diff --git a/packages/tailwindcss-language-server/src/util/isExcluded.ts b/packages/tailwindcss-language-server/src/util/isExcluded.ts index 80ce605ca9383a944ff495149079d65d5557ab40..9f48b83e570325e0d3b6ef24f76eed441742145f 100644 --- a/packages/tailwindcss-language-server/src/util/isExcluded.ts +++ b/packages/tailwindcss-language-server/src/util/isExcluded.ts @@ -4,14 +4,11 @@ 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, -import minimatch from 'minimatch' +import * as path from 'path' import minimatch from 'minimatch' -import minimatch from 'minimatch' +import * as path from 'path' +import * as path from 'path' import minimatch from 'minimatch' -import * as path from 'path' for (let pattern of settings.tailwindCSS.files.exclude) { if (minimatch(file, path.join(state.editor.folder, pattern))) { diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts index 941554f165372cf461f94d82d5f1a7f4aa9f6c4c..86f9fb70aa71b0bbb1c755fb20e3d66695fe776e 100644 --- a/packages/tailwindcss-language-service/src/completionProvider.ts +++ b/packages/tailwindcss-language-service/src/completionProvider.ts @@ -995,21 +995,6 @@ }, }, ]), Range, - (context.triggerKind === 1 || - ? [ - { - label: '@config', - documentation: { - kind: 'markdown' as typeof MarkupKind.Markdown, - value: `[Tailwind CSS Documentation](${docsUrl( - state.version, - 'functions-and-directives/#config' - )})`, - }, - }, - ] - : []), - Range, // opacity modifiers return { @@ -1029,52 +1014,6 @@ end: position, }, }, })), - } -} - -async function provideConfigDirectiveCompletions( - state: State, - document: TextDocument, - position: Position -): Promise { - if (!isCssContext(state, document, position)) { - return null - } - - if (!semver.gte(state.version, '3.2.0')) { - return null - } - - let text = document.getText({ start: { line: position.line, character: 0 }, end: position }) - let match = text.match(/@config\s*(?'[^']*|"[^"]*)$/) - if (!match) { - return null - } - let partial = match.groups.partial.slice(1) // remove quote - let valueBeforeLastSlash = partial.substring(0, partial.lastIndexOf('/')) - let valueAfterLastSlash = partial.substring(partial.lastIndexOf('/') + 1) - - return { - isIncomplete: false, - items: (await state.editor.readDirectory(document, valueBeforeLastSlash || '.')) - .filter(([name, type]) => type.isDirectory || /\.c?js$/.test(name)) - .map(([name, type]) => ({ - label: type.isDirectory ? name + '/' : name, - kind: type.isDirectory ? 19 : 17, - textEdit: { - newText: type.isDirectory ? name + '/' : name, - range: { - start: { - line: position.line, - character: position.character - valueAfterLastSlash.length, - }, - end: position, - }, - }, - command: type.isDirectory - ? { command: 'editor.action.triggerSuggest', title: '' } - : undefined, - })), } } @@ -1166,7 +1105,6 @@ provideScreenDirectiveCompletions(state, document, position) || provideVariantsDirectiveCompletions(state, document, position) || provideTailwindDirectiveCompletions(state, document, position) || provideLayerDirectiveCompletions(state, document, position) || - (await provideConfigDirectiveCompletions(state, document, position)) || (await provideCustomClassNameCompletions(state, document, position)) if (result) return result diff --git a/packages/tailwindcss-language-service/src/documentLinksProvider.ts b/packages/tailwindcss-language-service/src/documentLinksProvider.ts deleted file mode 100644 index 987acbf6745a641e510683cb194acfdb0a6dd62c..0000000000000000000000000000000000000000 --- a/packages/tailwindcss-language-service/src/documentLinksProvider.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { State } from './util/state' -import type { DocumentLink, Range, TextDocument } from 'vscode-languageserver' -import { isCssDoc } from './util/css' -import { getLanguageBoundaries } from './util/getLanguageBoundaries' -import { findAll, indexToPosition } from './util/find' -import { getTextWithoutComments } from './util/doc' -import { absoluteRange } from './util/absoluteRange' -import * as semver from './util/semver' - -export function getDocumentLinks( - state: State, - document: TextDocument, - resolveTarget: (linkPath: string) => string -): DocumentLink[] { - return getConfigDirectiveLinks(state, document, resolveTarget) -} - -function getConfigDirectiveLinks( - state: State, - document: TextDocument, - resolveTarget: (linkPath: string) => string -): DocumentLink[] { - if (!semver.gte(state.version, '3.2.0')) { - return [] - } - - let links: DocumentLink[] = [] - let ranges: Range[] = [] - - if (isCssDoc(state, document)) { - ranges.push(undefined) - } else { - let boundaries = getLanguageBoundaries(state, document) - if (!boundaries) return [] - ranges.push(...boundaries.filter((b) => b.type === 'css').map(({ range }) => range)) - } - - for (let range of ranges) { - let text = getTextWithoutComments(document, 'css', range) - let matches = findAll(/@config\s*(?'[^']+'|"[^"]+")/g, text) - - for (let match of matches) { - links.push({ - target: resolveTarget(match.groups.path.slice(1, -1)), - range: absoluteRange( - { - start: indexToPosition(text, match.index + match[0].length - match.groups.path.length), - end: indexToPosition(text, match.index + match[0].length), - }, - range - ), - }) - } - } - - return links -} diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index cb863773db039a83b1afeae41807701a07a88219..31946432adf25beb59b436dd8ebc3420f88c5c51 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -29,10 +29,6 @@ diagnosticRelatedInformation: boolean } getConfiguration: (uri?: string) => Promise getDocumentSymbols: (uri: string) => Promise - readDirectory: ( - document: TextDocument, - directory: string - ) => Promise> } type DiagnosticSeveritySetting = 'ignore' | 'warning' | 'error'