Skip to content
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

How to parse only certain regions of a file for multi-language documents? #1366

Closed
gushogg-blake opened this issue Oct 21, 2021 · 5 comments
Closed
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@gushogg-blake
Copy link

gushogg-blake commented Oct 21, 2021

Does the LSP protocol support parsing certain regions of a file, e.g. to parse JavaScript/CSS within an HTML file? Or is there some mechanism for passing the actual code of a file instead of the URI? (Which would enable the technique of replacing other regions with whitespace and parsing the whole file with different language servers, as VS Code seems to do.)

This was addressed in #505 but wasn't really answered except to mark as out-of-scope -- but VS Code must be achieving the functionality somehow, so I'm wondering how it works. The LSP spec only seems to mention passing URIs, and doesn't mention much about different schemes e.g. data: URIs, but it also seems unlikely that VS Code is writing a temp file to disk to achieve this functionality.

@rcjsuen
Copy link
Contributor

rcjsuen commented Oct 21, 2021

Does the LSP protocol support parsing certain regions of a file, e.g. to parse JavaScript/CSS within an HTML file? Or is there some mechanism for passing the actual code of a file instead of the URI?

The client includes the content of the file in the textDocument/didOpen notification so it could technically lie to the server by simply including what's inside the <script> tag to the JavaScript language engine and the other other stuff to the HTML language server.

@KamasamaK
Copy link
Contributor

VS Code must be achieving the functionality somehow, so I'm wondering how it works.

There's a VS Code guide for Language Server for Embedded Programming Languages.

@dbaeumer
Copy link
Member

I will close the issue as a question. I think LSP should not promote a model how to do this. I think both using forwards or embedded services is a valid solution.

@dbaeumer dbaeumer added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Oct 27, 2021
@rcjsuen
Copy link
Contributor

rcjsuen commented Oct 27, 2021

@dbaeumer There is also #1252 about this.

@dbaeumer
Copy link
Member

@rcjsuen thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

4 participants