diff --git a/book/book.toml b/book/book.toml index 5bcbd9a4..fdd8c6e0 100644 --- a/book/book.toml +++ b/book/book.toml @@ -10,7 +10,7 @@ preferred-dark-theme = "colibri" git-repository-url = "https://github.com/helix-editor/helix" edit-url-template = "https://github.com/helix-editor/helix/edit/master/book/{path}" additional-css = ["custom.css"] -additional-js = ["scheme.min.js"] +additional-js = ["ts-query.js"] [output.html.search] use-boolean-and = true diff --git a/book/custom.css b/book/custom.css index 7ab6d863..d51452de 100644 --- a/book/custom.css +++ b/book/custom.css @@ -173,53 +173,71 @@ code.hljs { /* highlight.js theme, :where() is used to avoid increasing specificity */ +/* Mapped to the helix theme.toml palette */ :where(.colibri) .hljs { - background: hsl(303.5, 22.1%, 9.5%); - color: #a39e9b; + background: #1f1029; /* slightly deeper than --bg revolver */ + color: #a4a0e8; /* lavender — ui.text */ } :where(.colibri) .hljs-comment, :where(.colibri) .hljs-quote { - color: #8d8687; + color: #697C81; /* sirocco — comment */ } -:where(.colibri) .hljs-link, -:where(.colibri) .hljs-meta, +:where(.colibri) .hljs-keyword, :where(.colibri) .hljs-name, -:where(.colibri) .hljs-regexp, -:where(.colibri) .hljs-selector-class, -:where(.colibri) .hljs-selector-id, -:where(.colibri) .hljs-tag, -:where(.colibri) .hljs-template-variable, -:where(.colibri) .hljs-variable { - color: #ef6155; +:where(.colibri) .hljs-selector-tag { + color: #eccdba; /* almond — keyword, tag */ +} + +:where(.colibri) .hljs-meta, +:where(.colibri) .hljs-attribute, +:where(.colibri) .hljs-attr, +:where(.colibri) .hljs-operator, +:where(.colibri) .hljs-tag { + color: #dbbfef; /* lilac — directives, attributes, operators */ } :where(.colibri) .hljs-built_in, -:where(.colibri) .hljs-deletion, -:where(.colibri) .hljs-literal, +:where(.colibri) .hljs-symbol, +:where(.colibri) .hljs-addition { + color: #9ff28f; /* mint — builtins, additions */ +} + +:where(.colibri) .hljs-string, +:where(.colibri) .hljs-bullet, +:where(.colibri) .hljs-link { + color: #cccccc; /* silver — strings */ +} + +:where(.colibri) .hljs-regexp, +:where(.colibri) .hljs-formula { + color: #efba5d; /* honey — regex, special */ +} + :where(.colibri) .hljs-number, -:where(.colibri) .hljs-params, -:where(.colibri) .hljs-type { - color: #f99b15; +:where(.colibri) .hljs-literal, +:where(.colibri) .hljs-params { + color: #E8DCA0; /* chamois — numbers, literals, parameters */ } -:where(.colibri) .hljs-attribute, +:where(.colibri) .hljs-title, :where(.colibri) .hljs-section, -:where(.colibri) .hljs-title { - color: #fec418; +:where(.colibri) .hljs-type, +:where(.colibri) .hljs-class, +:where(.colibri) .hljs-property, +:where(.colibri) .hljs-selector-id, +:where(.colibri) .hljs-selector-class { + color: #ffffff; /* white — types, functions, headings */ } -:where(.colibri) .hljs-addition, -:where(.colibri) .hljs-bullet, -:where(.colibri) .hljs-string, -:where(.colibri) .hljs-symbol { - color: #48b685; +:where(.colibri) .hljs-variable, +:where(.colibri) .hljs-template-variable { + color: #a4a0e8; /* lavender — variables */ } -:where(.colibri) .hljs-keyword, -:where(.colibri) .hljs-selector-tag { - color: #815ba4; +:where(.colibri) .hljs-deletion { + color: #f47868; /* apricot — deletion / error */ } :where(.colibri) .hljs-emphasis { diff --git a/book/scheme.min.js b/book/scheme.min.js deleted file mode 100644 index 6b3884ba..00000000 --- a/book/scheme.min.js +++ /dev/null @@ -1 +0,0 @@ -hljs.registerLanguage("scheme",function(){"use strict";return function(e){var t="[^\\(\\)\\[\\]\\{\\}\",'`;#|\\\\\\s]+",n={$pattern:t,"builtin-name":"case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules ' * + , ,@ - ... / ; < <= = => > >= ` abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"},r={className:"literal",begin:"(#t|#f|#\\\\"+t+"|#\\\\.)"},a={className:"number",variants:[{begin:"(\\-|\\+)?\\d+([./]\\d+)?",relevance:0},{begin:"(\\-|\\+)?\\d+([./]\\d+)?[+\\-](\\-|\\+)?\\d+([./]\\d+)?i",relevance:0},{begin:"#b[0-1]+(/[0-1]+)?"},{begin:"#o[0-7]+(/[0-7]+)?"},{begin:"#x[0-9a-f]+(/[0-9a-f]+)?"}]},i=e.QUOTE_STRING_MODE,c=[e.COMMENT(";","$",{relevance:0}),e.COMMENT("#\\|","\\|#")],s={begin:t,relevance:0},l={className:"symbol",begin:"'"+t},o={endsWithParent:!0,relevance:0},u={variants:[{begin:/'/},{begin:"`"}],contains:[{begin:"\\(",end:"\\)",contains:["self",r,i,a,s,l]}]},g={className:"name",begin:t,keywords:n},d={variants:[{begin:"\\(",end:"\\)"},{begin:"\\[",end:"\\]"}],contains:[{begin:/lambda/,endsWithParent:!0,returnBegin:!0,contains:[g,{begin:/\(/,end:/\)/,endsParent:!0,contains:[s]}]},g,o]};return o.contains=[r,a,i,s,l,u,d].concat(c),{name:"Scheme",aliases:["scm","tsq"],illegal:/\S/,contains:[e.SHEBANG(),a,i,l,u,d].concat(c)}}}()); \ No newline at end of file diff --git a/book/src/editor.md b/book/src/editor.md index 024f8642..158a646e 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -467,7 +467,7 @@ Options for navigating and editing using tab key. Due to lack of support for S-tab in some terminals, the default keybindings don't fully embrace smart-tab editing experience. If you enjoy smart-tab navigation and a terminal that supports the [Enhanced Keyboard protocol](https://github.com/helix-editor/helix/wiki/Terminal-Support#enhanced-keyboard-protocol), consider setting extra keybindings: -``` +```toml [keys.normal] tab = "move_parent_node_end" S-tab = "move_parent_node_start" @@ -484,12 +484,12 @@ S-tab = "extend_parent_node_start" Options for rendering diagnostics inside the text like shown below -``` +```text fn main() { let foo = bar; └─ no such value in this scope } -```` +``` | Key | Description | Default | |------------|-------------|---------| @@ -503,7 +503,7 @@ The allowed values for `cursor-line` and `other-lines` are: `error`, `warning`, The (first) diagnostic with the highest severity that is not shown inline is rendered at the end of the line (as long as its severity is higher than the `end-of-line-diagnostics` config option): -``` +```text fn main() { let baz = 1; let foo = bar; a local variable with a similar name exists: baz diff --git a/book/src/guides/injection.md b/book/src/guides/injection.md index cf2e8921..43b71169 100644 --- a/book/src/guides/injection.md +++ b/book/src/guides/injection.md @@ -15,7 +15,7 @@ An example of a simple query that would highlight all strings as bash in Nix: (#set! injection.language "bash")) ``` Another example is this query, which highlights links in comments and keywords like "TODO", by reusing the dedicated "comment" language: -``` +```scm ((comment) @injection.content (#set! injection.language "comment")) ``` diff --git a/book/src/syntax-aware-motions.md b/book/src/syntax-aware-motions.md index 17f396fb..78e2cfb2 100644 --- a/book/src/syntax-aware-motions.md +++ b/book/src/syntax-aware-motions.md @@ -23,7 +23,7 @@ A function call might be parsed by tree-sitter into a tree like the following. Use `:tree-sitter-subtree` to view the syntax tree of the primary selection. In a more intuitive tree format: -``` +```text ┌────┐ │call│ ┌─────┴────┴─────┐ diff --git a/book/ts-query.js b/book/ts-query.js new file mode 100644 index 00000000..3a9d8807 --- /dev/null +++ b/book/ts-query.js @@ -0,0 +1,25 @@ +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: /[.*+?]/ }, + ], + }; +});