TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Highlighting Parts of Lua as Bash

22 pointsby xnacly4 months ago

1 comment

mdaniel4 months ago
An alternative approach is to use comments, which allow changing <i>arbitrary</i> string literals into injected contexts, as JetBrains does: <a href="https:&#x2F;&#x2F;www.jetbrains.com&#x2F;help&#x2F;idea&#x2F;using-language-injections.html#use-language-injection-comments" rel="nofollow">https:&#x2F;&#x2F;www.jetbrains.com&#x2F;help&#x2F;idea&#x2F;using-language-injection...</a> I have found that to be more helpful in cases where the data flow can&#x27;t or doesn&#x27;t prove how a string is being used, as in:<p><pre><code> def doit(): # language=SQL s = &quot;SELECT * FROM FOO&quot; run_sql(s) def run_sql(s: str): cur = conn.cursor() cur.execute(s) </code></pre> Although I am not certain if tree-sitter allows matching on comments, but <a href="https:&#x2F;&#x2F;github.com&#x2F;tree-sitter&#x2F;tree-sitter&#x2F;issues&#x2F;1138">https:&#x2F;&#x2F;github.com&#x2F;tree-sitter&#x2F;tree-sitter&#x2F;issues&#x2F;1138</a> seems to imply that it does