# `tree-sitter` Injections Are Cool Tree-sitter is really cool (and it can do lots more cool stuff than just highlighting) and having it accessible to users is really fun. I have been working on embedding SQL inside of OCaml to give type-safe SQL queries in OCaml (parameterized, corresponding to modules, etc). However, it's kind of lame to write SQL in unhighlighted green string text.... so, it can be fixed in just a few lines of tree-sitter queries. In neovim, if you include a file in something like `queries/<lang>/injections.scm` somewhere in your `runtimepath`, Neovim will automatically load this for the `<lang>` and then Neovim can inject the highlighting inside of the current file. ```neovim {"update":true,"path":"_/code/17254851306760.scheme","timestamp":1725485211417} <pre> <span class="Normal">((value_definition</span> <span class="schemeForm"> </span><span class="Normal">(attribute_id)</span><span class="schemeForm"> </span><span class="Normal">@_attribute_id</span> <span class="schemeForm"> </span><span class="Normal">(let_binding</span> <span class="schemeForm"> </span><span class="Normal">body:</span><span class="schemeForm"> </span><span class="Normal">(</span><span class="Function">string</span><span class="schemeForm"> </span><span class="Normal">(string_content)</span><span class="schemeForm"> </span><span class="Normal">@injection.content)))</span> <span class="schemeForm"> </span><span class="Normal">(#contains?</span><span class="schemeForm"> </span><span class="Normal">@_attribute_id</span><span class="schemeForm"> </span><span class="String">&quot;query&quot;</span><span class="Normal">)</span> <span class="schemeForm"> </span><span class="Normal">(#set!</span><span class="schemeForm"> </span><span class="Normal">injection.language</span><span class="schemeForm"> </span><span class="String">&quot;sql&quot;</span><span class="Normal">))</span> </pre> ``` ^17254851306760 In the code snippet, you can see that we set the injection.language to "sql", which instructs Neovim to highlight everything in the injection.content range as SQL. That gives us the beautiful SQL highlighting you can see here: ![[Pasted image 20240703150052.png]]