CodeEditApp / CodeEditSourceEditor

A code editor view written in Swift powered by tree-sitter.
https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor
MIT License
517 stars 84 forks source link

✨ Injected Languages #16

Closed lukepistrol closed 1 year ago

lukepistrol commented 2 years ago

Injected languages are important for languages like HTML which might embed CSS or JavaScript code blocks.

Example Use Cases

Injections.scm

Some grammars that support injections have an additional injections.scm file in their queries folder.

An example is tree-sitter-html:

((script_element
  (raw_text) @injection.content)
 (#set! injection.language "javascript"))

((style_element
  (raw_text) @injection.content)
 (#set! injection.language "css"))

We need to figure out how to parse and load the associated injected languages in addition to the base language itself.

Resources

austincondiff commented 2 years ago

Good point. I can also see this being useful when writing regex or jsx in javascript.