Skip to content

Pass URI to configuration call not a file path #982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tailwindcss-language-server/src/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ export async function createProjectService(
if (state.enabled) {
refreshDiagnostics()
}
if (settings.editor.colorDecorators) {
if (settings.editor?.colorDecorators) {
updateCapabilities()
} else {
connection.sendNotification('@/tailwindCSS/clearColors')
Expand Down
21 changes: 7 additions & 14 deletions packages/tailwindcss-language-server/src/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ export class TW {
// NOTE: We should eventually be smart about avoiding duplicate work. We do
// not necessarily need to set up file watchers, search for projects, read
// configs, etc… per folder. Some of this work should be sharable.
let results = await Promise.allSettled(folders.map((basePath) => this._initFolder(basePath)))
let results = await Promise.allSettled(
folders.map((basePath) => this._initFolder(URI.file(basePath))),
)

for (let [idx, result] of results.entries()) {
if (result.status === 'rejected') {
Expand All @@ -164,24 +166,15 @@ export class TW {
await this.listenForEvents()
}

private async _initFolder(base: string): Promise<void> {
private async _initFolder(baseUri: URI): Promise<void> {
let base = baseUri.fsPath
let workspaceFolders: Array<ProjectConfig> = []
let globalSettings = await this.settingsCache.get()
let ignore = globalSettings.tailwindCSS.files.exclude

// Get user languages for the given workspace folder
let userLanguages = globalSettings.tailwindCSS.includeLanguages

try {
let folderSettings = await this.settingsCache.get(base)
userLanguages = folderSettings.tailwindCSS.includeLanguages
} catch (error) {
console.error(
'Unable to get the settings for workspace folder. Using global settings instead.',
error,
)
}

let folderSettings = await this.settingsCache.get(baseUri.toString())
let userLanguages = folderSettings.tailwindCSS.includeLanguages

// Fall back to settings defined in `initializationOptions` if invalid
if (!isObject(userLanguages)) {
Expand Down