Arborium: Tree-sitter code highlighting with Native and WASM targets
Posted by zdw 10 hours ago
Comments
Comment by joshka 7 hours ago
Comment by brabel 6 hours ago
Comment by solarkraft 3 hours ago
Comment by falcor84 58 minutes ago
Comment by tombh 48 minutes ago
Comment by mg 7 hours ago
The ease of use to highlight static text via Arborium seems nice:
<script src="arborium.iife.js"></script>
<pre><code class="language-python">
def hello(name):
print("Hello " + name);
</code></pre>
But does it support editing highlighted text? If not, one would have to do some trickery by hiding a textarea and updating the <code> element on each keypress, I guess. Which probably has a thousand corner cases one would have to deal with.And how would one add SCAD support?
Comment by debazel 3 hours ago
The code isn't minified so you can see how they do it by looking at the `doHighlight()` function here https://arborium.bearcove.eu/pkg/app.generated.js
Comment by metmac 1 hour ago
Comment by aarol 4 hours ago
I'm happy to see that tree sitter highlighting on the web is finally a thing. This seems really solid although the bundle size is a lot.
Comment by Tepix 5 hours ago
Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.
Comment by jasonjmcghee 8 hours ago
Comment by pseudo_meta 5 hours ago
My favorite is nvim-treesitter-textobjects which gives you dozens of new targets for vim motions, such as a function call or the condition of a loop.
Comment by mintflow 5 hours ago
Comment by teo_zero 8 hours ago
Comment by GolDDranks 5 hours ago
You can use it as a normal Rust library, or you can use the JavaScript/WASM wrapper to highlight source code on a web page.
Comment by oersted 5 hours ago
Just wanted to note that tree-sitter is lower-level and more general: it's an incremental parser that is specialised for gracefully and efficiently parsing partially-correct code snippets or code being edited live.
It's an important building block of the highlighter, but it needs more on top to complete the package. It can be used for anything that requires awareness of code structure in an editor.
Comment by GolDDranks 4 hours ago
Comment by joshka 7 hours ago
Comment by jasonjmcghee 8 hours ago
Or... website text editors which historically have had imperfect syntax highlighting.
Notice the Zed sponsorship.
Comment by tombh 46 minutes ago
That's the best one sentence description there is and it's at the top of the Github README. I think that would fit nice at the top of https://arborium.bearcove.eu too
Comment by discord9 7 hours ago
Comment by Rodmine 8 hours ago
Comment by unrealhoang 8 hours ago
Comment by virajk_31 9 hours ago