Visual Studio Code extension to automatically continue inline comments.
Visual Studio Code doesn't support automatic continuation of inline comments
out of the box. This extension adds support for it in various languages (see
Inspired by Auto Comment Next Line
(GitHub) which wasn't
working very well for me.
Here's the default config as seen in
package.json. Feel free
to tweak as you please!
How it works
See the full code in
When a new document is opened or when the language of a document changes
vscode.workspace.onDidOpenTextDocument), we check if the language is
supported by our config. If so, we use
vscode.languages.setLanguageConfiguration to extend the
onEnterRules to add
completion for the inline comments (see hacks below).
On load, we also iterate over
vscode.window.visibleTextEditors to apply the
onEnterRules because otherwise the editors already opened when the extension
is loaded would not trigger
onEnterRules is pretty hacky to do. Because
vscode.languages.setLanguageConfiguration overwrites the properties we
give to it, it means that by setting our custom
onEnterRules entry, we're
effectively removing all the other
onEnterRules defined by the original
language definition. Not good.
To avoid that, we need to get the existing language configuration to add our
custom rule on top of the existing ones.
The problem is that there's no way to get the existing language
configuration from the extensions API
see), so we have to resort
to a dirty hack where we manually identify the language configuration files
of the installed extensions, load that file manually with jsonc-parser,
and translate the JSON representation of
API) so that we can use it in
And while it's annoying AF and a pretty dirty hack in my opinion, it does work
pretty fucking well.
jsonc-parser is not bundled
with esbuild because of this issue.
repository needs to be set to
github:valeriangalliat/vscode-continue-inline-comments instead of
valeriangalliat/vscode-continue-inline-comments (which are
semantically equivalent) because
vsce doesn't support the latter
UNLICENSE file needs to be symlinked as
npm run watch
See publishing extensions.
npm install -g vsce