Skip to content

Commit

Permalink
Pass URI to configuration call not a file path (#982)
Browse files Browse the repository at this point in the history
* Pass URI to configuration call not a file path

oops. Works fine in VSCode but not in some other LSPs (like Zed). It’s technically a malformed request on our side

* Don’t break when `settings.editor` is not defined

Also fixes an issue in Zed
  • Loading branch information
thecrypticace authored Jun 18, 2024
1 parent d561031 commit bb72017
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
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

0 comments on commit bb72017

Please sign in to comment.