Commit graph

139 commits

Author SHA1 Message Date
Max Brunsfeld
1d8975319c
Merge pull request #2840 from tree-sitter/language-reference-count
Introduce APIs for managing the lifetimes of languages, allow WASM languages to be deleted
2024-01-30 10:24:37 -08:00
Steven Kalt
d35efd4608
feat(cli): support building WASM via podman
Previously, `tree-sitter build-wasm` had the ability to build WASM
by using docker to pull in an image with a complete emscripten toolchain.
This commit adds the ability to use podman to do the same thing.

Using podman requires two notable changes:
1. Using the fully-qualified image name. Docker defaults to prepending
    `docker.io` to the image name, but podman does not.
2. Podman will mount the `/src/` volume as belonging to root unless
  `--userns=keep-id` is passed. I think podman's different
  volume-ownership is related to podman's daemonless execution and
  `--uidmap` functionality, but I'm not 100% sure.

To test, I ran
```sh
script/fetch-fixtures
script/generate-fixtures
script/generate-fixtures-wasm # <- the important one!
```

which worked as well as the docker version.
2024-01-29 00:50:32 -05:00
Max Brunsfeld
da16cb1459 Introduce language ref-count management C APIs, remove Copy impl for Language in Rust 2023-12-27 14:59:16 -08:00
Max Brunsfeld
13dd76e444 Return an informative error on failing to construct a WasmStore 2023-11-27 17:48:29 -08:00
Max Brunsfeld
473b3c8208 Add a CLI feature flag for wasm runtime support 2023-10-31 16:56:11 -07:00
Max Brunsfeld
f4e2f68f14 Merge branch 'master' into wasm-language 2023-10-27 12:11:43 +01:00
Andrew Hlynskyi
9cc1daafca chore(ffi): remove enum name prefixes from all C enum values 2023-09-03 07:38:27 +03:00
Amaan Qureshi
ce4a9ef4de
feat: allow specifying an input query-paths argument 2023-08-17 22:21:20 -04:00
Amaan Qureshi
9971e5d5f5
feat: allow specifying an input captures-path argument 2023-08-17 22:20:57 -04:00
Amaan Qureshi
8eb92d1c64
feat: add an --apply-all-captures argument to highlight & test 2023-08-17 22:20:57 -04:00
Jake Sarjeant
61b70943b1 feat(cli): add option to select JS runtime other than node 2023-08-03 21:34:47 +03:00
Michael Davis
3e499d675a
CLI: Re-use highlight cancellation flag for HTML highlights
The `html` highlight function created its own cancellation flag which
conflicts with the Ctrl-c handler set up in the CLI's `main` block
for `tree-sitter highlight`. We can re-use the cancellation flag from
that block to avoid a panic that happens when using `tree-sitter
highlight -H <file>`

    thread 'main' panicked at 'Error setting Ctrl-C handler: MultipleHandlers', cli/src/util.rs:31:6

This change also aligns the parameters that `highlight::ansi` and
`highlight::html` take.
2023-08-02 08:56:26 -05:00
Andrew Hlynskyi
a2f834d846 More error contexts + conv panics to errors with context 2023-07-30 21:16:45 +03:00
Patrick Thomson
cb58bc593f
Add --check flag to tree-sitter highlight.
Recently I've been pulling a lot of grammars into GitHub's highlighting backend,
replacing legacy language support with tree-sitter highlighting queries.
Our backend systems have a standard set of highlight captures we expect, very
similar to the standard tagging captures we expect. Though end-user applications
are free to choose whatever tagging nomenclature they want, I think it's nice to
include a checking stage that will help us ensure that we know whether a capture
might be recognized or not. It will also help us figure out where we need to
expand our standard set of captures (see #1539).
2023-07-15 20:49:03 -04:00
Amaan Qureshi
9d669abac4 feat: add encoding flag and automatically check if a file might be utf-16 2023-07-10 16:43:35 -04:00
Andrew Hlynskyi
e966c5ad5b fix: use SIGINT instead of stdin for interruption to don't mess up piped commands 2023-05-02 10:43:46 +03:00
Max Brunsfeld
ff2436a6f8 Add --row-range, --quiet, and --time flags to query subcommand 2023-02-14 14:41:25 -08:00
Max Brunsfeld
97fd990822 Add --dot flag to parse subcommand, for printing tree as DOT graph 2023-02-13 12:33:34 -08:00
Max Brunsfeld
555277a102 Allow testing highlight and tag queries when testing wasm build
Replace non-mutating `ts_parser_wasm_store` function with
`ts_parser_take_wasm_store`, which removes and returns the wasm
store, in order to facilitate single ownership.
2023-01-23 11:46:59 -08:00
Andrew Hlynskyi
c7d431b53e Add setting TREE_SITTER_DEBUG in the test subcommand
Were asked in #1218
2023-01-10 10:47:24 +02:00
Andrew Hlynskyi
108d0ecede loader: add TREE_SITTER_LIBDIR; cli: add --libdir to tree-sitter generate
Closes #1336
2023-01-06 10:28:47 +02:00
Andrew Hlynskyi
5088781ef9 cli: add -b, --build flags for tree-sitter generate 2023-01-06 10:28:47 +02:00
Andrew Hlynskyi
ad45f5cd2c Remove unused no-minimize arg for the generate command 2023-01-06 10:28:47 +02:00
Max Brunsfeld
51720beeb0 Start work on a --wasm flag for the test subcommand 2022-11-15 17:14:33 -08:00
Max Brunsfeld
d47713ee4a Integrate WASM compilation into the CLI's Loader 2022-11-15 17:14:33 -08:00
Max Brunsfeld
3f1a7f9cd4 Start work on ability to load wasm languages from native lib, via wasmtime 2022-11-15 17:14:33 -08:00
Max Brunsfeld
e2fe380a08 Generate parsers with ABI version 14 by default 2022-09-02 12:31:29 -07:00
Max Brunsfeld
5eb0a3090f
Merge pull request #1547 from the-mikedavis/md-test-tags
test tags queries in 'tree-sitter test'
2022-02-24 15:22:15 -08:00
Max Brunsfeld
516fd6f6de Add --abi flag to generate command, generate version 13 by default 2022-01-17 14:50:47 -08:00
Michael Davis
067f742ad3
run test_tag in 'tree-sitter test' when tags test dir exists 2021-12-18 11:07:18 -06:00
Jostein Kjønigsen
d0559ca43f Fix whitespace issues when using paths-file. 2021-10-25 23:51:01 +02:00
Andrew Hlynskyi
16470bc0b1 chore(cli): Rename all internal web_ui stuff to playground 2021-09-22 04:28:08 +03:00
Andrew Hlynskyi
62d79b80e1 feat(cli): add a flag to compile a parser in debug mode with -O0 C/C++ compiler flag 2021-09-13 13:48:02 +03:00
Kolja Lampe
99243ddaf2 Correct quiet description for playground 2021-08-06 01:58:24 +03:00
Max Brunsfeld
59cd1c3962
Merge pull request #1235 from ahlinc/feat/cli-help-messages
feat(cli): Add a lot of help messages for CLI options
2021-07-19 11:32:32 -07:00
Andrew Hlynskyi
b4208ee307 feat(cli): Add a lot of help messages for CLI options 2021-07-03 16:14:57 +03:00
Andrew Hlynskyi
bc94c0cc2f fix(cli): fix theme key loading from config.json, closes #1232 2021-07-03 03:38:24 +03:00
Andrew Hlynskyi
60f0953b65 feat(cli): Set TREE_SITTER_DEBUG env var on 'tree-sitter parse -d' 2021-06-30 18:51:43 +03:00
Andrew Hlynskyi
202a37f1a1 chore(cli): Use DeriveDisplayOrder Clap's setting
To show sub commands in the defined order that looks more accurate
and have more meaning for sub commands use order.
2021-06-27 03:37:56 +03:00
Andrew Hlynskyi
2e2b239c42 fix(cli): Don't silently overwrite existing config file 2021-06-27 03:15:35 +03:00
Vladimir Panteleev
5adf7bdcde
cli/src/main.rs: Fix panic with empty file list to parse
E.g.: tree-sitter parse --paths /dev/null
2021-06-26 18:11:30 +00:00
Andrew Hlynskyi
bd0e60240e fix(cli): Change -h -> -H for the highlight subcommand to don't clash with the help flag 2021-06-24 12:09:00 +03:00
Andrew Hlynskyi
650ee94800 fix(cli): disable help subcommand, -h, --help are enough 2021-06-24 12:04:12 +03:00
Andrew Hlynskyi
1220ec3852 feat(cli): Rename web-ui -> playground with fallback alias 2021-06-24 12:04:12 +03:00
Andrew Hlynskyi
80ee33b073 feat(cli): Add short aliases for frequent subcommands 2021-06-24 11:55:50 +03:00
Andrew Hlynskyi
04badf8a8e feat(cli): Enable clap colored help 2021-06-24 11:55:50 +03:00
Andrew Hlynskyi
421815a68d feat(cli): Make more clearer sub command selection 2021-06-23 10:51:55 +03:00
Andrew Hlynskyi
318b00e437 fix(cli): Don't print 'Error:' prefix 2021-06-14 10:46:39 +03:00
Douglas Creager
b44270efab cli: Missing config file shouldn't be an error
Just fall back on the default values for each configuration option.
2021-06-10 10:22:20 -04:00
Douglas Creager
e841fcfa1b cli: Extract CLI configuration into separate crate
This patch adds the `tree-sitter-config` crate, which manages
tree-sitter's configuration file.  This new setup allows different
components to define their own serializable configuration types, instead
of having to create a single monolithic configuration type.  But the
configuration itself is still stored in a single JSON file.

Before, the default location for the configuration file was
`~/.tree-sitter/config.json`.  This patch updates the default location
to follow the XDG Base Directory spec (or other relevant platform-
specific spec).  So on Linux, for instance, the new default location is
`~/.config/tree-sitter/config.json`.  We will look in the new location
_first_, and fall back on reading from the legacy location if we can't
find anything.
2021-06-10 10:21:22 -04:00