Closed aeschli closed 4 years ago
I addressed the second point but not the first. Feel free to add another section to ## Potential issues
.
primary language that defines the syntax of the document
I don't think we want to drift the focus to syntax highlighting. The linked issue is talking about syntax highlighting.
If people are expecting HTML support to work for PHP, we can either point them to this doc or ask them to try files.associations
and see how it doesn't work for PHP because PHP is not HTML.
I'm not sure what point exactly does "each document has a primary language" convey, as it's something people should already know from reading the previous Language Server guide and also clear from the API TextDocument.languageId
.
Testing https://github.com/microsoft/vscode/issues/93809
Following up the discussion from https://github.com/microsoft/vscode-docs/pull/3508#issuecomment-605211179
Agree, it's not about the parser. I wanted to state that there's always a primary language that defines the syntax of the document. It's an issue that comes up all the time: See https://github.com/microsoft/vscode/issues/92349. Looks like HTML, but is PHP. People just think this can be handled by a HTML language server, but no, it's an embedded scenario, with HTML as an embedded language.
What I find important to understand is that extracting the embedded content involves a transformation of the input to the embeddeded language and a transformation of the result back to the host language. What has been suggested several times, why doesn't the HTML language server just gives back ranges of where JavaScript is and let TypeScript server directly work on it. Again in HTML for
<script>
and<style>
this is very subtle and can even be ignored (in fact our code ignores escaping aspects), but it's important to realize. An example to illustrate that is JavaScript embedded in style attributes:The transformation of LS result (e.g. completions) back to the host language not only involves positions and ranges, but can also mean that you need to adjust the competion item insertText
For example in
<script>
and<style>
you can not have a</
in your content. So when done correctly, the completion items would have to be adjusted as described here: https://www.w3.org/TR/html401/appendix/notes.html#h-B.3.2We should add some examples of different languages.
The techniques how to use services or other LS can come after that.
For the various approaches, a process diagram would help.