Open tgrelka opened 1 year ago
While I agree that embedded languages would be great to support, there is a major problem with doing so, that is just figuring out where the language is, where it starts and ends and what the embedded language is to even parse its comments to begin with.
With a quick look into how the html language support, and the vue language support are set up, it may be possible to know the different options for what languages may be embedded, but that still leaves us with the problems of finding what language in particular it is that is embedded, where exactly it is embedded for any languages which supports embedded languages which could vary between different languages. This means we would need to parse for specific tokens I think, but I have no idea how that will work or if its efficient enough to do constantly for documents you are editing.
You'll notice that in the extension mine is based off of, BetterComments, there is also an issue talking about this very subject. Since I do parse tokens in my version, it may be possible, but for now, without more free time or someone like @Ak-Shaw in https://github.com/aaron-bond/better-comments/issues/442#issuecomment-1319656270_, I dont think this issue will be addressed anytime soon, sorry.
@Ak-Shaw I see you saw my comment, would you be interested in being assigned to work on this? If so let me know and I will. I know I certainly wont have the time to work on this nor do I ever work with embedded languages so I wouldn't be familiar with the syntax or anything.
Hi @Zxynine, sure, I wanna work on this, since I've had a recent requirement working with embedded languages. Also, it'll be a nice-to-have feature for all those working on embedded languages. That said, I'm not yet familiar with the codebase TBH, but yeah, will have fun with it if assigned. Eager to work on this! Thanks for asking!
Hi @Zxynine, sure, I wanna work on this, since I've had a recent requirement working with embedded languages. Also, it'll be a nice-to-have feature for all those working on embedded languages. That said, I'm not yet familiar with the codebase TBH, but yeah, will have fun with it if assigned. Eager to work on this! Thanks for asking!
Its all yours, I would recommend you use the branch "Cleaning For Publish" as the main branch is just my testing grounds and is filled with un used code/partially worked on ideas and is a complete mess. You may also find unused code in the cleaned branch that I forgot to remove, but it should be far cleaner than the main.
Its all yours, I would recommend you use the branch "Cleaning For Publish" as the main branch is just my testing grounds and is filled with un used code/partially worked on ideas and is a complete mess. You may also find unused code in the cleaned branch that I forgot to remove, but it should be far cleaner than the main.
Got it! Thanks @Zxynine!
Just a note, I've changed my username from @Ak-Shaw to @YourAKShaw.
Update on the task: Have started going through the codebase and understanding the major flows. Will keep updating here.
Saw this version had some success, but seemed to have some issues with the extension working in every instance/restart. https://marketplace.visualstudio.com/items?itemName=EdwinHuiSH.better-comments-next
Thought I'd share here in case it's helpful, plus their repo has no Issues enabled :/
Great find, I appreciate the help. I took a look at it and I'm sad to report that it is not exactly the solution most people would want. I may add it as an experimental option you have to enable (its not really a difficult change), but from what I see the way they make it work is by just adding the other languages comment rules to the parser, so the entire document would have the rules for all imbedded languages enabled everywhere which will create some... funky... looking documents for some people.
I did find some additional commands while looking into all of this that I might be able to use to add proper support for embedded languages though, so we shall see.
Happy to help test things out if you decide to go down the experimental route, etc.
Some files, especially many web technologies, contain multiple languages in the same file. This is called “embedded languages”. Examples include HTML files with
<style>
and<script>
tags or.vue
files for the Vue.js framework, among others. In some of these cases, especially for vue single file components, the extensions is not fully usable, as comments are not recognized correctly in embedded languages.<!--
is not a configured keyword) (3) should work and does, but for a slightly different reason. Vue SFC files use a basic tag syntax and thus allow comments with<!-- -->
, which coincidently is also used in HTML code to mark comments, so nothing seems off. From a technical perspective, HTML here is an embedded language inside the<template>
region.VScode has built-in support for embedded languages using various means. Maybe these could also be used to properly support mixed languages like Vue SFC files, as especially for the TypeScript parts, comment highlighting would greatly improve the development experience.