View Source TreeSitter (tree_sitter v0.0.3)

TreeSitter is an installer and runner for tree_sitter.

treesitter-configuration

TreeSitter configuration

There are two global configurations for the tree_sitter application:

  • :version - the expected tree_sitter version

  • :cacerts_path - the directory to find certificates for https connections

  • :path - the path to find the tree_sitter executable at. By default, it is automatically downloaded and placed inside the _build directory of your current app

Overriding the :path is not recommended, as we will automatically download and manage tree-sitter for you. But in case you can't download it (for example, the npm registry is behind a proxy), you may want to set the :path to a configurable system location.

For instance, you can install tree-sitter globally with npm:

$ npm install -g tree-sitter

On Unix, the executable will be at:

NPM_ROOT/tree-sitter/node_modules/@tree-sitter/TARGET/bin/tree_sitter

On Windows, it will be at:

NPM_ROOT/tree-sitter/node_modules/@tree-sitter/win32-x(32|64)/tree_sitter.exe

Where NPM_ROOT is the result of npm root -g and TARGET is your system target architecture.

Once you find the location of the executable, you can store it in a MIX_TREE_SITTER_PATH environment variable, which you can then read in your configuration file:

config :tree_sitter, path: System.get_env("MIX_TREE_SITTER_PATH")

Link to this section Summary

Functions

Returns the path to the executable.

Returns the version of the tree_sitter executable.

Returns the configured tree_sitter version.

Installs tree_sitter with configured_version/0.

Installs, if not available, and then runs tree_sitter.

Runs the given command with args.

Link to this section Functions

Returns the path to the executable.

The executable may not be available if it was not yet installed.

Returns the version of the tree_sitter executable.

Returns {:ok, version_string} on success or :error when the executable is not available.

Returns the configured tree_sitter version.

Link to this function

highlight_html(text, lang)

View Source

Installs tree_sitter with configured_version/0.

Installs, if not available, and then runs tree_sitter.

Returns the same as run/1.

Runs the given command with args.

The given args will be appended to the configured args. The task output will be streamed directly to stdio. It returns the status of the underlying call.