Boot language servers for nested workspace folders (#642)
parent
2ab6ee7dff
commit
e4239414e3
|
@ -73,20 +73,6 @@ function sortedWorkspaceFolders(): string[] {
|
||||||
return _sortedWorkspaceFolders
|
return _sortedWorkspaceFolders
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
|
|
||||||
let sorted = sortedWorkspaceFolders()
|
|
||||||
for (let element of sorted) {
|
|
||||||
let uri = folder.uri.toString()
|
|
||||||
if (uri.charAt(uri.length - 1) !== '/') {
|
|
||||||
uri = uri + '/'
|
|
||||||
}
|
|
||||||
if (uri.startsWith(element)) {
|
|
||||||
return Workspace.getWorkspaceFolder(Uri.parse(element))!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return folder
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUserLanguages(folder?: WorkspaceFolder): Record<string, string> {
|
function getUserLanguages(folder?: WorkspaceFolder): Record<string, string> {
|
||||||
const langs = Workspace.getConfiguration('tailwindCSS', folder).includeLanguages
|
const langs = Workspace.getConfiguration('tailwindCSS', folder).includeLanguages
|
||||||
return isObject(langs) ? langs : {}
|
return isObject(langs) ? langs : {}
|
||||||
|
@ -217,7 +203,6 @@ export async function activate(context: ExtensionContext) {
|
||||||
if (!folder || isExcluded(uri.fsPath, folder)) {
|
if (!folder || isExcluded(uri.fsPath, folder)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
folder = getOuterMostWorkspaceFolder(folder)
|
|
||||||
bootWorkspaceClient(folder)
|
bootWorkspaceClient(folder)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -231,7 +216,6 @@ export async function activate(context: ExtensionContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (await fileContainsAtConfig(uri)) {
|
if (await fileContainsAtConfig(uri)) {
|
||||||
folder = getOuterMostWorkspaceFolder(folder)
|
|
||||||
bootWorkspaceClient(folder)
|
bootWorkspaceClient(folder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,6 +449,34 @@ export async function activate(context: ExtensionContext) {
|
||||||
outputChannel: outputChannel,
|
outputChannel: outputChannel,
|
||||||
revealOutputChannelOn: RevealOutputChannelOn.Never,
|
revealOutputChannelOn: RevealOutputChannelOn.Never,
|
||||||
middleware: {
|
middleware: {
|
||||||
|
provideCompletionItem(document, position, context, token, next) {
|
||||||
|
let workspaceFolder = Workspace.getWorkspaceFolder(document.uri)
|
||||||
|
if (workspaceFolder !== folder) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return next(document, position, context, token)
|
||||||
|
},
|
||||||
|
provideHover(document, position, token, next) {
|
||||||
|
let workspaceFolder = Workspace.getWorkspaceFolder(document.uri)
|
||||||
|
if (workspaceFolder !== folder) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return next(document, position, token)
|
||||||
|
},
|
||||||
|
handleDiagnostics(uri, diagnostics, next) {
|
||||||
|
let workspaceFolder = Workspace.getWorkspaceFolder(uri)
|
||||||
|
if (workspaceFolder !== folder) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
next(uri, diagnostics)
|
||||||
|
},
|
||||||
|
provideCodeActions(document, range, context, token, next) {
|
||||||
|
let workspaceFolder = Workspace.getWorkspaceFolder(document.uri)
|
||||||
|
if (workspaceFolder !== folder) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return next(document, range, context, token)
|
||||||
|
},
|
||||||
async resolveCompletionItem(item, token, next) {
|
async resolveCompletionItem(item, token, next) {
|
||||||
let result = await next(item, token)
|
let result = await next(item, token)
|
||||||
let selections = Window.activeTextEditor.selections
|
let selections = Window.activeTextEditor.selections
|
||||||
|
@ -506,6 +518,11 @@ export async function activate(context: ExtensionContext) {
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
async provideDocumentColors(document, token, next) {
|
async provideDocumentColors(document, token, next) {
|
||||||
|
let workspaceFolder = Workspace.getWorkspaceFolder(document.uri)
|
||||||
|
if (workspaceFolder !== folder) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
let colors = await next(document, token)
|
let colors = await next(document, token)
|
||||||
let editableColors = colors.filter((color) => {
|
let editableColors = colors.filter((color) => {
|
||||||
let text =
|
let text =
|
||||||
|
@ -666,8 +683,6 @@ export async function activate(context: ExtensionContext) {
|
||||||
if (!folder) {
|
if (!folder) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// If we have nested workspace folders we only start a server on the outer most workspace folder.
|
|
||||||
folder = getOuterMostWorkspaceFolder(folder)
|
|
||||||
|
|
||||||
if (searchedFolders.has(folder.uri.toString())) {
|
if (searchedFolders.has(folder.uri.toString())) {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue