I followed this tutorial from the visual studio code on how to create a language server to a validate an extension file. I proceeded to make a copy of the lsp-sample project and got it running.
In my analysis of this project, I noticed that only open or changed files in the workspace are validated.
// The content of a text document has changed. This event is emitted
// when the text document first opened or when its content has changed.
documents.onDidChangeContent((change) => {
validateTextDocument(change.document);
});
This is all fine for most cases, but I think that when the workspace is opened all files (regardless of being open by the editor or not) should be validated in order to have a richer IDE experiencie in vscode.
Can anyone experienced in the Language Server protocol help me on how to do this? As far as I know the "documents" object is only populated with opened files.
Many thanks, Ricardo
You need to inspect the rootPath
or rootUri
from the initial initialize
request from the client. From there, you can validate all of its files and report errors as necessary. Of course, it is possible that both of those are null
.
If the client supports workspace folders, then you will need to interact with the workspace/workspaceFolders
and workspace/didChangeWorkspaceFolders
and extract the relevant information from there to determine how to validate your files.