Injection grammar for VSCode #456
Replies: 2 comments 5 replies
-
Thanks mark! Think we are on the same wavelength. I set up a custom treesitter extensions for my editor (neovim), but have been meaning to look into the same mechanism for VS Code. I think VS Code is based on TextMate (sp?), so I don't think the same mechansim can be reused. Sharing for other treesitter users. https://github.com/manzt/dotfiles/blob/main/.config/nvim/queries/python/injections.scm ![]() |
Beta Was this translation helpful? Give feedback.
-
In JS, it's nice that multi-line comments can comment/uncomment within a line, which allows for catching syntactic nodes easier. For example, I've seen this extension used a lot to highlight HTML strings in JS via: let html = /* html */ `<h1>Hello, world</h1>`; Which is nice because you capture the comment in the AST and look for a string assignment. We couldn't do the same in Python because the whole thing becomes a comment: _esm = # js """
export default { render() {} };
""" but depending on the syntax tree, it might be possible to look for sibling comment/variable. # js
_esm = """
export default { render() {} };
""" |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
If anyone is knowledgeable about VSCode extensions and injection grammars, it would be awesome to have an injection grammar for JS-inside-Python-multiline-strings when developing widgets. While using a .js file is an option, I like the simplicity of writing the JS in a string, and also when prototyping widgets in a notebook.
Resources
Beta Was this translation helpful? Give feedback.
All reactions