1
0
mirror of https://github.com/helix-editor/helix synced 2026-07-25 22:40:56 +02:00
Files
helix/book/ts-query.js
2026-06-07 23:21:58 +09:00

26 lines
1003 B
JavaScript

hljs.registerLanguage("tsq", function (hljs) {
const IDENT = /[A-Za-z_][\w-]*/;
return {
name: "Tree-sitter Query",
aliases: ["scm"],
contains: [
hljs.COMMENT(";", "$"),
hljs.QUOTE_STRING_MODE,
// @capture.name (with dots and dashes)
{ className: "variable", begin: /@[\w.\-]+/ },
// #predicate? — #eq?, #match?, #any-of?, #kind-eq?, #same-line?, ...
{ className: "built_in", begin: /#[\w\-]+\?/ },
// #directive! — #set!, #select-adjacent!, #strip!, #trim!, #gsub!
{ className: "meta", begin: /#[\w\-]+!/ },
// field name: or negated !field:
{ className: "attr", begin: /!?[A-Za-z_][\w-]*:/ },
// wildcard and special node kinds
{ className: "literal", begin: /\b(?:_|MISSING|ERROR)\b/ },
// named node kind (must come after field/wildcard rules)
{ className: "title", begin: IDENT },
// anchors and quantifiers: . * + ?
{ className: "operator", begin: /[.*+?]/ },
],
};
});