Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> It is possible to use the language server for syntax highlighting. I am not aware of any particularly strong reasons why one would want to (or not want to) do this.

This is an area where TS excels. It also supports nesting of different languages so a query can inject other languages [0] and compose different parsers.

As an example, this can be a straight forward as a simple comment parser [1], jsdoc [2], regex [3] etc. Or in more complex cases various DSLs. Each of these can then define their own injections too. When working with CI pipelines in particular it transforms an opaque wall of YAML into slightly more manageable CST which is incredible useful for both humans (syntax highlighting) and any machine parsing you may want to do.

[0]: https://tree-sitter.github.io/tree-sitter/3-syntax-highlight...

[1]: https://github.com/stsewd/tree-sitter-comment

[2]: https://github.com/tree-sitter/tree-sitter-jsdoc

[3]: https://github.com/tree-sitter/tree-sitter-regex



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: