Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #278.
Currently,
vscode-elixir-ls
handles all template languages without parsing them, which brings a problem that all services, including code completion, hover, go to definition, etc. don't work as expected. Ideally, each template-specific extension should handle their own template and then forward to other services when required, for instance, when inside<style>
,<script>
or elixir expressions inside{ }
or<% %>
.This PR adds the
"embedded-content"
scheme to the list ofdocumentSelector
for all languages handled by this extension. This allows any other extension to properly forward any Elixir-related command to be handled by ElixirLS only when actually necessary.Ideally, this extension (or the next official one) should only handle Elixir language. This way it can work consistently, without having to parse each individual template language. All other templates that have their own syntax should be responsible for handling their own LS requests, even if they, eventually, have to forward the request back to this extension.
A couple of examples of inconsistent code completions, listing Elixir-related suggestions where it shouldn't:
Inside
<style>
Inside
<script>
Inside HTML markup
By properly dealing with
embedded-content
, other extensions can handle their own templates, detect other embedded languages and then forward to the proper service. The service is handle by whatever extension the user has installed that is registered to handle the content type.Here's an example using the Surface extension, which avoids bringing all the suggestions from ElixirLS, even when it makes no sense:
Listing only applicable components and HTML tags
Forwarding to Elixir service when inside expressions
Forwarding to CSS/Tailwind service when inside
<style>
The
vscode-elixir-ls
should do the same when working with embedded templates using~H
or~F
. But that should be addressed on a separate PR.