Skip to content

Commit e7e7828

Browse files
aminyaalexheretic
andcommitted
feat: populate additionalPaths based on definitions
Co-Authored-By: Alex Butler <[email protected]>
1 parent 360d4fb commit e7e7828

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/auto-languageclient.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,23 @@ export default class AutoLanguageClient {
697697
}
698698

699699
this.definitions = this.definitions || new DefinitionAdapter()
700-
return this.definitions.getDefinition(server.connection, server.capabilities, this.getLanguageName(), editor, point)
700+
const query = await this.definitions.getDefinition(
701+
server.connection,
702+
server.capabilities,
703+
this.getLanguageName(),
704+
editor,
705+
point
706+
)
707+
708+
if (query !== null && this.supportsDefinitionsForAdditionalPaths && server.additionalPaths !== undefined) {
709+
// populate additionalPaths based on definitions
710+
// Indicates that the language server can support LSP functionality for out of project files indicated by `textDocument/definition` responses.
711+
for (const def of query.definitions) {
712+
considerAdditionalPath(server as ActiveServer & { additionalPaths: Set<string> }, path.dirname(def.path))
713+
}
714+
}
715+
716+
return query
701717
}
702718

703719
// Outline View via LS documentSymbol---------------------------------
@@ -984,6 +1000,14 @@ export default class AutoLanguageClient {
9841000
.forEach((line) => this.logger.warn(`stderr ${line}`))
9851001
}
9861002

1003+
/**
1004+
* Indicates that the language server can support LSP functionality for out of project files indicated by
1005+
* `textDocument/definition` responses. Set it to `true` if the server supports this feature.
1006+
*
1007+
* @default `false`
1008+
*/
1009+
protected supportsDefinitionsForAdditionalPaths: boolean = false
1010+
9871011
private getServerAdapter<T extends keyof ServerAdapters>(
9881012
server: ActiveServer,
9891013
adapter: T

0 commit comments

Comments
 (0)