TreeSitter
module TreeSitter| Assembly | Nacara.Plugin.Highlight.TreeSitter |
| Attributes | [<RequireQualifiedAccess>] |
Declared inside
TreeSitterHighlighter | A highlighter backed by tree-sitter grammars compiled to wasm |
Functions and values
aliases (names: string list) (grammar: TreeSitterGrammar) : TreeSitterGrammar
aliases (names: string list) (grammar: TreeSitterGrammar) : TreeSitterGrammarNames this grammar answers to besides its own.
| Parameter | |
|---|---|
names | The other names a fence may write. |
grammar | The grammar so far. |
autoBuild (value: bool) (options: TreeSitterOptions) : TreeSitterOptions
autoBuild (value: bool) (options: TreeSitterOptions) : TreeSitterOptionsBuild a grammar named by repository when it is not already built.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |
browser (value: string list) (options: TreeSitterOptions) : TreeSitterOptions
browser (value: string list) (options: TreeSitterOptions) : TreeSitterOptionsThe languages <nacara-highlight> can colour in the browser.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |
browserAssets (languages: string list) : Result<TreeSitterBrowserAssets,string>
browserAssets (languages: string list) : Result<TreeSitterBrowserAssets,string>Everything a browser needs to colour these languages, with the grammars this package ships.
| Parameter | |
|---|---|
languages | The languages to emit a grammar for. |
browserAssetsWith (options: TreeSitterOptions) (languages: string list) : Result<TreeSitterBrowserAssets,string>
browserAssetsWith (options: TreeSitterOptions) (languages: string list) : Result<TreeSitterBrowserAssets,string>Everything a browser needs to colour these languages itself.
The wasm build of tree-sitter is fetched once per machine, and a grammar is read from wherever the options say it comes from - the same place the build reads it.
| Parameter | |
|---|---|
options | Which grammar is which, and what may be fetched or built. |
languages | The languages to emit a grammar for. |
Returns. What to emit and what the browser can ask for, or why none of it could be had.
bundled (language: string) : TreeSitterGrammar
bundled (language: string) : TreeSitterGrammarOne of the grammars this package ships.
bundledGrammar (language: string) : byte array
bundledGrammar (language: string) : byte arrayThe parse tables of a shipped language, gzipped as they are stored.
| Parameter | |
|---|---|
language | The language whose grammar is wanted. |
bundledLanguages: Lazy<string list>
bundledLanguages: Lazy<string list>The languages this package ships a grammar for.
Inside the assembly, so the first site built on a machine colours its F#, its shell commands and its configuration files without compiling anything.
bundledQueries (language: string) : byte array
bundledQueries (language: string) : byte arrayThe queries a shipped language is coloured by, with any it builds on.
What the language adds comes last: a later pattern wins the bytes it covers, so a node both queries claim is coloured the way the more specific one asked.
| Parameter | |
|---|---|
language | The language whose queries are wanted. |
classMap (queries: string) : (string * string) list
classMap (queries: string) : (string * string) listEvery capture the queries use, paired with the class the build would give it.
Read out of the queries and answered by className, so a browser colours a block the way the build coloured the one above it. Deriving it beats copying the table into JavaScript, where the two would drift apart the first time a capture was added.
| Parameter | |
|---|---|
queries | The highlights query of a grammar. |
className (capture: string) : string option
className (capture: string) : string optionWhat a capture name means to the theme.
Capture names are a convention rather than a standard, and they nest: variable.parameter falls back to variable when nothing claims the whole of it. What comes out is the vocabulary the stylesheet is written against.
cliSource (value: string) (options: TreeSitterOptions) : TreeSitterOptions
cliSource (value: string) (options: TreeSitterOptions) : TreeSitterOptionsWhere the tree-sitter CLI is published, with {version} and {platform} in it.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |
continuedFrom (text: string) (grammar: TreeSitterGrammar) : TreeSitterGrammar
continuedFrom (text: string) (grammar: TreeSitterGrammar) : TreeSitterGrammarWhat a snippet of this language continues from, when it is a fragment.
| Parameter | |
|---|---|
text | What to parse ahead of the snippet, so a fragment stands alone. |
grammar | The grammar so far. |
create () : IPlugin
create () : IPluginThe plugin, with the grammars this package ships.
createWith (configure: TreeSitterOptions -> TreeSitterOptions) : IPlugin
createWith (configure: TreeSitterOptions -> TreeSitterOptions) : IPluginThe plugin, configured.
defaults: TreeSitterOptionsfromGitHub (language: string) (repository: string) (reference: string) : TreeSitterGrammar
fromGitHub (language: string) (repository: string) (reference: string) : TreeSitterGrammarA grammar, from the repository it lives in.
Fetched and compiled to wasm the first time, then kept. Nothing has to be installed, and nothing installed is used.
| Parameter | |
|---|---|
language | What a fence writes after its backticks. |
repository | The repository, as its web address. |
reference | A branch, a tag or a commit. A commit is the one that cannot move under a site. |
grammar (language: string) (wasm: string) (queries: string) : TreeSitterGrammar
grammar (language: string) (wasm: string) (queries: string) : TreeSitterGrammarA grammar, from the two files it takes.
| Parameter | |
|---|---|
language | The name a fence writes to ask for it. |
wasm | The compiled grammar. |
queries | The highlights query saying what its nodes mean. |
grammars (value: TreeSitterGrammar list) (options: TreeSitterOptions) : TreeSitterOptions
grammars (value: TreeSitterGrammar list) (options: TreeSitterOptions) : TreeSitterOptionsThe grammars to load, one per language.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |
inDirectory (subdirectory: string) (grammar: TreeSitterGrammar) : TreeSitterGrammar
inDirectory (subdirectory: string) (grammar: TreeSitterGrammar) : TreeSitterGrammarWhich directory of the repository holds the grammar, when it is not the top one.
| Parameter | |
|---|---|
subdirectory | Where in the repository the grammar lives. |
grammar | The grammar so far. |
namesOf (grammar: TreeSitterGrammar) : Set<string>
namesOf (grammar: TreeSitterGrammar) : Set<string>Every name a grammar answers to: its own, the ones it lists, and their family.
queriesAt (path: string) (grammar: TreeSitterGrammar) : TreeSitterGrammar
queriesAt (path: string) (grammar: TreeSitterGrammar) : TreeSitterGrammarWhich file of the repository says what the nodes mean, when it is not where they usually are.
| Parameter | |
|---|---|
path | Where the highlights query is, inside the repository. |
grammar | The grammar so far. |
registerWith (configure: TreeSitterOptions -> TreeSitterOptions) (site: Site) : Site
registerWith (configure: TreeSitterOptions -> TreeSitterOptions) (site: Site) : SiteColour code blocks with tree-sitter, with languages of your own.
| Parameter | |
|---|---|
configure | Given the defaults, the options to use. |
site | The site you are describing. |
runtimePath (value: string option) (options: TreeSitterOptions) : TreeSitterOptions
runtimePath (value: string option) (options: TreeSitterOptions) : TreeSitterOptionsWhere the two native libraries are: tree-sitter and wasmtime.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |
runtimeSource (value: string) (options: TreeSitterOptions) : TreeSitterOptions
runtimeSource (value: string) (options: TreeSitterOptions) : TreeSitterOptionsWhere that pair is published, with {version} and {rid} in it.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |
useBundledGrammars (value: bool) (options: TreeSitterOptions) : TreeSitterOptions
useBundledGrammars (value: bool) (options: TreeSitterOptions) : TreeSitterOptionsFall back to the grammars this package ships.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |
wasiSdkSource (value: string) (options: TreeSitterOptions) : TreeSitterOptions
wasiSdkSource (value: string) (options: TreeSitterOptions) : TreeSitterOptionsWhere the wasi-sdk is published, with {major}, {version} and {platform} in it.
| Parameter | |
|---|---|
value | The value to use. |
options | The options so far. |